-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle names consistently when formatting
- if no `cited_as` and no `name`, make some cultural assumptions and try building a name from parts (TODO in the future: stop using name parts at all) - correct ordering contributors for oai_dc
- Loading branch information
Showing
6 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
def build_name_from_parts(agent_node): | ||
"""construct some name from parts, making wild cultural assumptions | ||
@param agent_node: share.util.graph.MutableNode with concrete type 'abstractagent' | ||
@returns string (possibly empty) | ||
""" | ||
# filter out falsy parts | ||
name_parts = filter(None, [ | ||
agent_node['given_name'], | ||
agent_node['additional_name'], | ||
agent_node['family_name'], | ||
agent_node['suffix'], | ||
]) | ||
return ' '.join(name_parts).strip() | ||
|
||
|
||
def get_related_agent_name(relation_node): | ||
"""get the name to refer to a related agent | ||
@param relation_node: share.util.graph.MutableNode with concrete type 'abstractagentworkrelation' | ||
@returns string (possibly empty) | ||
""" | ||
return ( | ||
relation_node['cited_as'] | ||
or relation_node['agent']['name'] | ||
or build_name_from_parts(relation_node['agent']) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters