From 6955d603734440835e28f7ab218b24e569523780 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 4 Sep 2020 18:16:36 -0700 Subject: fixes to refs transform (for non-str author fields) --- fatcat_scholar/transform.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fatcat_scholar') diff --git a/fatcat_scholar/transform.py b/fatcat_scholar/transform.py index 158ed6f..a21abf9 100644 --- a/fatcat_scholar/transform.py +++ b/fatcat_scholar/transform.py @@ -454,12 +454,14 @@ def refs_from_grobid(release: ReleaseEntity, tei_dict: dict) -> Sequence[RefStru ref_year: Optional[int] = None if ref_date and len(ref_date) > 4 and ref_date[:4].isdigit(): ref_year = int(ref_date[:4]) + authors = ref.get("authors") or [] + authors = [a for a in authors if type(a) == str] output.append( RefStructured( biblio=RefBiblio( title=ref.get("title"), # subtitle - contrib_raw_names=ref.get("authors") or [], + contrib_raw_names=authors, year=ref_year, container_name=ref.get("journal"), volume=ref.get("volume"), @@ -495,12 +497,14 @@ def refs_from_release_refs(release: ReleaseEntity) -> Sequence[RefStructured]: elif release.extra and release.extra.get("datacite"): ref_source = "datacite" extra = ref.extra or dict() + authors = extra.get("authors") or [] + authors = [a for a in authors if type(a) == str] output.append( RefStructured( biblio=RefBiblio( title=ref.title, subtitle=extra.get("subtitle"), - contrib_raw_names=extra.get("authors") or [], + contrib_raw_names=authors, year=ref.year, container_name=ref.container_name, volume=extra.get("volume"), -- cgit v1.2.3