Skip to content

Commit

Permalink
Always extract all affiliations for each author (close #160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangWoW123 authored Oct 29, 2024
1 parent 5866025 commit b2d0402
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions pubmed_parser/medline_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,14 @@ def parse_author_affiliation(medline):
else:
identifier = ""
if author.find("AffiliationInfo/Affiliation") is not None:
affiliation = author.find("AffiliationInfo/Affiliation").text or ""
affiliation = affiliation.replace(
"For a full list of the authors' affiliations please see the Acknowledgements section.",
"",
)
affiliation = list(chain(*([c.text] for c in author.findall("AffiliationInfo/Affiliation")))) or []
affiliation = [
c.replace(
"For a full list of the authors' affiliations please see the Acknowledgements section.",
"",
) for c in affiliation
]
affiliation = "|".join(affiliation)
else:
affiliation = ""
authors.append(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_medline_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_affiliations():
"""This is a test for the affiliations field."""
affiliations_36400559 = 'Department of Neurological Surgery, The Ohio State Wexner Medical Center, 410 West 10th Street, Columbus, OH 43210, USA; The Ohio State University College of Medicine, 370 West 9th street, Columbus, OH 43210, USA.;Department of Neurological Surgery, The Ohio State Wexner Medical Center, 410 West 10th Street, Columbus, OH 43210, USA.;Department of Neurological Surgery, Baylor College of Medicine, 1 Baylor Plaza, Houston, TX 77030, USA.;Department of Neurological Surgery, The Ohio State Wexner Medical Center, 410 West 10th Street, Columbus, OH 43210, USA; Department of Neurological Surgery, Baylor College of Medicine, 1 Baylor Plaza, Houston, TX 77030, USA. Electronic address: [email protected].'
assert article_36400559['affiliations'] == affiliations_36400559
affiliations_28786991 = 'Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.;Centers for Disease Control and Prevention, Division of Tuberculosis Elimination, Atlanta, Georgia, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.'
affiliations_28786991 = 'Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.|Global Health Sciences, University of California, San Francisco, San Francisco, California, United States of America.|The Consortium for the Assessment of Prevention Economics (CAPE), University of California, San Francisco, San Francisco, California, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.|The Consortium for the Assessment of Prevention Economics (CAPE), University of California, San Francisco, San Francisco, California, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.|The Consortium for the Assessment of Prevention Economics (CAPE), University of California, San Francisco, San Francisco, California, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.|Global Health Sciences, University of California, San Francisco, San Francisco, California, United States of America.|The Consortium for the Assessment of Prevention Economics (CAPE), University of California, San Francisco, San Francisco, California, United States of America.;Centers for Disease Control and Prevention, Division of Tuberculosis Elimination, Atlanta, Georgia, United States of America.;Phillip R. Lee Institute for Health Policy Studies, University of California, San Francisco, San Francisco, California, United States of America.|Global Health Sciences, University of California, San Francisco, San Francisco, California, United States of America.|The Consortium for the Assessment of Prevention Economics (CAPE), University of California, San Francisco, San Francisco, California, United States of America.'
assert article_28786991['affiliations'] == affiliations_28786991


Expand Down

0 comments on commit b2d0402

Please sign in to comment.