lib/commonmeta/author_utils.rb in commonmeta-ruby-3.11.0 vs lib/commonmeta/author_utils.rb in commonmeta-ruby-3.12.0
- old
+ new
@@ -23,12 +23,12 @@
"ResearchGroup" => "Other",
"RightsHolder" => "Other",
"Researcher" => "Other",
"Sponsor" => "Other",
"Supervisor" => "Supervision",
- "WorkPackageLeader" => "Other"
- }
+ "WorkPackageLeader" => "Other",
+ }
def get_one_author(author)
# basic sanity checks
return nil if author.blank?
@@ -53,24 +53,24 @@
# parse author identifier
id = parse_attributes(author.fetch("id", nil), first: true) ||
parse_attributes(author.fetch("identifier", nil), first: true) ||
parse_attributes(author.fetch("sameAs", nil), first: true)
id = normalize_orcid(id) || normalize_ror(id) if id.present?
-
+
# DataCite metadata
if id.nil? && author["nameIdentifiers"].present?
id = Array.wrap(author.dig("nameIdentifiers")).find do |ni|
normalize_name_identifier(ni).present?
end
id = normalize_name_identifier(id) if id.present?
- # Crossref metadata
+ # Crossref metadata
elsif id.nil? && author["ORCID"].present?
id = author.fetch("ORCID")
id = normalize_orcid(id)
- # JSON Feed metadata
+ # JSON Feed metadata
elsif id.nil? && author["url"].present?
- id = author.fetch("url")
+ id = author.fetch("url")
end
# parse author type, i.e. "Person", "Organization" or not specified
type = author.fetch("type", nil)
type = type.first if type.is_a?(Array)
@@ -165,9 +165,12 @@
return true if name_exists?(name.to_s.split.first) || name_exists?(name.to_s.split(", ").last)
# check if a name has only one word, e.g. "FamousOrganization", not including commas
return false if name.to_s.split(" ").size == 1 && name.to_s.exclude?(",")
+
+ # check if name contains words known to be used in organization names
+ return false if %w[University College Institute School Center Department Laboratory Library Museum Foundation Society Association Company Corporation Collaboration Consortium Incorporated Inc. Institut Research Science].any? { |word| name.to_s.include?(word) }
# check for suffixes, e.g. "John Smith, MD"
return true if name && %w[MD PhD].include?(name.split(", ").last)
# check of name can be parsed into given/family name