Skip to content

Commit

Permalink
fallback to regex year extraction or empty String when arrow fails
Browse files Browse the repository at this point in the history
  • Loading branch information
tZimmermann98 authored Feb 3, 2025
1 parent a16d8b2 commit 5f79200
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scholarly/publication_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def fill(self, publication: Publication)->Publication:
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()
match = re.search(r'\d{4}', val.text)
publication['bib']['pub_year'] = match.group() if match else ""
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 5f79200

Please sign in to comment.