Skip to content

Commit

Permalink
Accomodate date-type in parse_date
Browse files Browse the repository at this point in the history
  • Loading branch information
enjalot authored Oct 16, 2024
1 parent 3ae0bb6 commit 5866025
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pubmed_parser/pubmed_oa_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ def parse_date(tree, date_type):
def get_text(node):
return node.text if node is not None else None

pub_date_path = f".//pub-date[@pub-type=\"{date_type}\"]"
pub_date_path = f".//pub-date[@pub-type='{date_type}' or @date-type='{date_type}']"
date_node = tree.xpath(pub_date_path)

if not date_node:
return {}

date_dict = {}
for part in ["year", "month", "day"]:
text = get_text(tree.find(f"{pub_date_path}/{part}"))
text = get_text(date_node[0].find(part))
if text is not None:
date_dict[part] = text

Expand Down

0 comments on commit 5866025

Please sign in to comment.