Skip to content

Commit

Permalink
Update publication_parser.py
Browse files Browse the repository at this point in the history
for arrow errors, fallback to regex year extraction
  • Loading branch information
tZimmermann98 authored Feb 3, 2025
1 parent 568d4ad commit a16d8b2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scholarly/publication_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ def fill(self, publication: Publication)->Publication:
'YYYY/M/DD',
'YYYY/M/D',
'YYYY/MM/D']
publication['bib']['pub_year'] = arrow.get(val.text, patterns).year
try:
publication['bib']['pub_year'] = arrow.get(val.text, patterns).year
except ValueError:
# fallback to regex year extraction if arrow fails
publication['bib']['pub_year'] = re.search(r'\d{4}', val.text).group()
publication['bib']['pub_date'] = val.text
elif key == 'description':
# try to find all the gsh_csp if they exist
Expand Down

0 comments on commit a16d8b2

Please sign in to comment.