Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added another delimiter type for splitting citations #210

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion paperqa/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,19 @@ def markdown(self) -> Tuple[str, str]:
index = 1
for citation in iter_citations(self.answer):
compound = ""
for c in citation.split(","):
for c in citation.split(",;"):
c = c.strip("() ")
if c == "Extra background information":
continue
if c in refs:
compound += f"[^{refs[c]}]"
continue
# check if it is a citation
try:
self.get_citation(c)
except ValueError:
# not a citation
continue
refs[c] = index
compound += f"[^{index}]"
index += 1
Expand Down
2 changes: 1 addition & 1 deletion paperqa/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.13.0"
__version__ = "3.13.1"
7 changes: 4 additions & 3 deletions tests/test_paperqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ def test_iter_citations():
"time. For instance, the effectiveness of COVID-19 vaccines against severe "
"COVID-19 declined to 64% after 121 days, compared to around 90% initially "
"(Chemaitelly2022WaningEO, Foo2019Bar). Despite this, vaccines still provide "
"significant protection against severe outcomes."
"significant protection against severe outcomes (Bar2000Foo pg 1-3; Far2000 pg 2-5)."
)
ref = [
"(Dorabawila2022EffectivenessOT)",
"(Bernal2021EffectivenessOC pg. 1-3)",
"(Thompson2021EffectivenessOC pg. 3-5, Goo2031Foo pg. 3-4)",
"(Marfé2021EffectivenessOC)",
"(Chemaitelly2022WaningEO, Foo2019Bar)",
"(Bar2000Foo pg 1-3; Far2000 pg 2-5)",
]
assert list(iter_citations(text)) == ref

Expand Down Expand Up @@ -130,13 +131,13 @@ def test_markdown():
answer = Answer(
question="What was Fredic's greatest accomplishment?",
answer="Frederick Bates's greatest accomplishment was his role in resolving land disputes "
"and his service as governor of Missouri (Wiki2023 chunk 1).",
"and his service as governor of Missouri (Wiki2023 chunk 1). It is said (in 2010) that foo.",
contexts=[
Context(
context="",
text=Text(
text="Frederick Bates's greatest accomplishment was his role in resolving land disputes "
"and his service as governor of Missouri (Wiki2023 chunk 1).",
"and his service as governor of Missouri.",
name="Wiki2023 chunk 1",
doc=Doc(
name="Wiki2023",
Expand Down
Loading