Skip to content

Commit

Permalink
add "section" metadata to nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantisan committed Sep 27, 2023
1 parent 195ce33 commit 1168cde
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mind_palace/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ def title(xml, doc_id):
return TextNode(
text=xml.header.title,
id_=f"{doc_id}-title",
metadata={"section": "title"},
excluded_embed_metadata_keys=["section"],
)


def abstract(xml, doc_id):
return TextNode(
text=xml.abstract,
id_=f"{doc_id}-abstract",
metadata={"section": "abstract"},
excluded_embed_metadata_keys=["section"],
)


Expand All @@ -60,7 +64,8 @@ def body(xml, doc_id):
return [
TextNode(
text=line,
metadata={"paragraph_number": index + 1},
metadata={"section": "body", "paragraph_number": index + 1},
excluded_embed_metadata_keys=["section"],
id_=f"{doc_id}-body-paragraph-{index}",
)
for index, line in enumerate(xml.body.split("\n"))
Expand Down

0 comments on commit 1168cde

Please sign in to comment.