lib/commonmeta/author_utils.rb in commonmeta-ruby-3.2.3 vs lib/commonmeta/author_utils.rb in commonmeta-ruby-3.2.4

- old
+ new

@@ -47,10 +47,12 @@ # DataCite metadata type = type[0..-3] if type.is_a?(String) && type.end_with?('al') if type.blank? && id.is_a?(String) && URI.parse(id).host == 'ror.org' type = 'Organization' + elsif type.blank? && author['type'] == 'Organization' + type = 'Organization' elsif type.blank? && id.is_a?(String) && URI.parse(id).host == 'orcid.org' type = 'Person' elsif type.blank? && (given_name.present? || family_name.present?) type = 'Person' elsif type.blank? && is_personal_name?(name: name) && name.to_s.exclude?(';') @@ -105,9 +107,18 @@ # check if given name is in the database of known given names: # https://github.com/bmuller/gender_detector def is_personal_name?(name: nil) 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" + return false if name.to_s.split(' ').size == 1 + + # check of name can be parsed into given/family name + Namae.options[:include_particle_in_family] = true + names = Namae.parse(name) + parsed_name = names.first + return true if parsed_name && parsed_name.given false end # recognize given name if we have loaded ::NameDetector data, e.g. in a Rails initializer