diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-20 15:04:39 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-20 15:04:39 -0700 |
commit | deb0926c14d9ce2ca90d4d4e983683e158e76432 (patch) | |
tree | 8ba47be769d3dea6bc4091ce277609d8b4b3fbf7 /python/fatcat_tools/transforms | |
parent | 9f25c2b4bd1e600448512fa6c4553acb6a3d92d6 (diff) | |
download | fatcat-deb0926c14d9ce2ca90d4d4e983683e158e76432.tar.gz fatcat-deb0926c14d9ce2ca90d4d4e983683e158e76432.zip |
improved CSL transform (structured author names)
Diffstat (limited to 'python/fatcat_tools/transforms')
-rw-r--r-- | python/fatcat_tools/transforms/csl.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/python/fatcat_tools/transforms/csl.py b/python/fatcat_tools/transforms/csl.py index 989629ab..f94fa372 100644 --- a/python/fatcat_tools/transforms/csl.py +++ b/python/fatcat_tools/transforms/csl.py @@ -34,31 +34,30 @@ def release_to_csl(entity): contribs = [] for contrib in (entity.contribs or []): if contrib.creator: - # TODO: should we actually be pulling creator metadata? or just - # using release-local raw metadata? - family = contrib.creator.surname - if not family: - if not contrib.raw_name: - raise ValueError("CSL requires some surname (family name)") - family = contrib.raw_name.split()[-1] + # Default to "local" (publication-specific) metadata; fall back to + # creator-level + family = contrib.surname or contrib.creator.surname or (contrib.raw_name and contrib.raw_name.split()[-1]) + if not contrib.raw_name: + raise ValueError("CSL requires some surname (family name)") c = dict( - family=contrib.creator.surname, - given=contrib.creator.given_name, + family=family, + given=contrib.given_name or contrib.creator.given_name, #dropping-particle #non-dropping-particle #suffix #comma-suffix #static-ordering - literal=contrib.raw_name, # or display_name? + literal=contrib.raw_name or contrib.creator.display_name, #parse-names, role=contrib.role, ) else: + family = contrib.surname or (contrib.raw_name and contrib.raw_name.split()[-1]) if not contrib.raw_name: raise ValueError("CSL requires some surname (family name)") c = dict( - # XXX: possible inclusion of full name metadata in release_contrib - family=contrib.raw_name.split()[-1], + family=family, + given=contrib.given_name, literal=contrib.raw_name, role=contrib.role, ) |