Skip to content

Commit

Permalink
Drop all_paragraph from parse_pubmed_paragraph() (close #147)
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-herrmann authored Aug 30, 2024
1 parent a6e846d commit a7e88c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions pubmed_parser/pubmed_oa_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def parse_pubmed_references(path):
return dict_refs


def parse_pubmed_paragraph(path, all_paragraph=False):
def parse_pubmed_paragraph(path):
"""
Give path to a given PubMed OA file, parse and return
a dictionary of all paragraphs, section that it belongs to,
Expand All @@ -377,13 +377,6 @@ def parse_pubmed_paragraph(path, all_paragraph=False):
----------
path: str
A string to an XML path.
all_paragraph: bool
By default, this function will only append a paragraph if there is at least
one reference made in a paragraph (to aviod noisy parsed text).
A boolean indicating if you want to include paragraph with no references made or not
if True, include all paragraphs
if False, include only paragraphs that have references
default: False
Return
------
Expand Down Expand Up @@ -421,8 +414,8 @@ def parse_pubmed_paragraph(path, all_paragraph=False):
"section": section,
"text": paragraph_text,
}
if len(ref_ids) >= 1 or all_paragraph:
dict_pars.append(dict_par)

dict_pars.append(dict_par)

return dict_pars

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pubmed_oa_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_parse_pubmed_paragraph():
paragraphs = pp.parse_pubmed_paragraph(pubmed_xml_3460867)
assert isinstance(paragraphs, list)
assert isinstance(paragraphs[0], dict)
assert len(paragraphs) == 29, "Expected number of paragraphs to be 29"
assert len(paragraphs) == 58, "Expected number of paragraphs to be 58"
assert (
len(paragraphs[0]["reference_ids"]) == 11
), "Expected number of references in the first paragraph to be 11"
Expand Down

0 comments on commit a7e88c8

Please sign in to comment.