Skip to content

Commit

Permalink
implement welcome.parse_abstracts()
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantisan committed Sep 27, 2023
1 parent 01a36f8 commit ebe0530
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
20 changes: 20 additions & 0 deletions mind_palace/welcome.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
from typing import List

from docs import Section


def parse_abstracts(nodes) -> List[str]:
"""Returns a list of abstract texts from a list of nodes."""
return [
node.get_text()
for node in nodes
if node.metadata["section"] == str(Section.ABSTRACT)
]


def summarize(texts):
# TODO:
return


def get_welcome_message(nodes):
# TODO:
return "Ask me a question about these PDFs"
3 changes: 2 additions & 1 deletion tests/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../mind_palace/"))
)

import extract
import docs
import extract
import index
import measure
import welcome
17 changes: 17 additions & 0 deletions tests/unit/test_welcome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from tests.context import docs
from tests.context import welcome as w


def test_parse_abstracts():
nodes = [
docs.create_text_node(
text="this is abstract", node_id=1, section=docs.Section.ABSTRACT
),
docs.create_text_node(
text="this is not abstract", node_id=2, section=docs.Section.BODY
),
]
abstracts = w.parse_abstracts(nodes)
assert len(abstracts) == 1
assert isinstance(abstracts, list)
assert all(isinstance(abstract, str) for abstract in abstracts)

0 comments on commit ebe0530

Please sign in to comment.