Commit 9bd364f5 authored by Kantz's avatar Kantz
Browse files

anpassung, das auch suhbseciton und section als source-type angezeigt werden

parent 2bcba69b
...@@ -301,7 +301,7 @@ class SourceID(BaseModel): ...@@ -301,7 +301,7 @@ class SourceID(BaseModel):
return f"[{string_rep}|{self.doc_type}]" return f"[{string_rep}|{self.doc_type}]"
def _row_to_retrieved(row: Dict[str, Any]) -> Retrieved: def _row_to_retrieved(row: Dict[str, Any], source_type: Optional[str] = None) -> Retrieved:
meta = { meta = {
"uid": row["uid"], "uid": row["uid"],
"doc_type": row["doc_type"], "doc_type": row["doc_type"],
...@@ -311,7 +311,7 @@ def _row_to_retrieved(row: Dict[str, Any]) -> Retrieved: ...@@ -311,7 +311,7 @@ def _row_to_retrieved(row: Dict[str, Any]) -> Retrieved:
"section_title": row["section_title"], "section_title": row["section_title"],
"subsection_title": row["subsection_title"], "subsection_title": row["subsection_title"],
"title": row["title"], "title": row["title"],
"source_type": row["source_type"], "source_type": row["source_type"] or source_type,
"path": row["path"], "path": row["path"],
} }
return Retrieved( return Retrieved(
...@@ -429,7 +429,7 @@ def retrieve( ...@@ -429,7 +429,7 @@ def retrieve(
""", """,
{"sec": most_common_sec, "sub": most_common_sub, "sub_doc_types": ["subsection", "chapter"]}, {"sec": most_common_sec, "sub": most_common_sub, "sub_doc_types": ["subsection", "chapter"]},
) )
subsections = [_row_to_retrieved(row) for row in cur.fetchall()] subsections = [_row_to_retrieved(row, source_type="subsection") for row in cur.fetchall()]
cur.execute( cur.execute(
""" """
...@@ -445,7 +445,7 @@ def retrieve( ...@@ -445,7 +445,7 @@ def retrieve(
""", """,
{"sec": most_common_sec, "sec_doc_types": ["section", "oberchapter"]}, {"sec": most_common_sec, "sec_doc_types": ["section", "oberchapter"]},
) )
sections_docs = [_row_to_retrieved(row) for row in cur.fetchall()] sections_docs = [_row_to_retrieved(row, source_type="section") for row in cur.fetchall()]
cur.execute( cur.execute(
""" """
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment