lib/relaton_ietf/bibxml_parser.rb in relaton-ietf-1.13.2 vs lib/relaton_ietf/bibxml_parser.rb in relaton-ietf-1.13.3
- old
+ new
@@ -1,10 +1,29 @@
module RelatonIetf
module BibXMLParser
include RelatonBib::BibXMLParser
extend BibXMLParser
+ FULLNAMEORG = [
+ "IAB", "Internet Architecture Board", "IAB and IESG", "IESG",
+ "IAB Advisory Committee", "Internet Engineering Steering Group",
+ "Network Information Center. Stanford Research Institute",
+ "Information Sciences Institute University of Southern California",
+ "International Telegraph and Telephone Consultative Committee of the International Telecommunication Union",
+ "National Bureau of Standards", "International Organization for Standardization",
+ "National Research Council", "Gateway Algorithms and Data Structures Task Force",
+ "National Science Foundation", "Network Technical Advisory Group",
+ "NetBIOS Working Group in the Defense Advanced Research Projects Agency",
+ "Internet Activities Board", "End-to-End Services Task Force",
+ "Defense Advanced Research Projects Agency", "The North American Directory Forum",
+ "ESCC X.500/X.400 Task Force", "ESnet Site Coordinating Comittee (ESCC)",
+ "Energy Sciences Network (ESnet)", "RARE WG-MSG Task Force 88",
+ "Internet Assigned Numbers Authority (IANA)", "Federal Networking Council",
+ "Audio-Video Transport Working Group", "KOI8-U Working Group",
+ "The Internet Society", "Sun Microsystems"
+ ].freeze
+
# @param attrs [Hash]
# @return [RelatonIetf::IetfBibliographicItem]
def bib_item(**attrs)
unless attrs.delete(:is_relation)
# attrs[:fetched] = Date.today.to_s
@@ -44,9 +63,42 @@
entity: new_org("Internet Engineering Task Force", "IETF"),
role: [type: "publisher"],
}
end
contribs + super
- # persons(reference) + organizations(reference)
+ end
+
+ #
+ # Overrade RelatonBib::BibXMLParser#full_name method
+ #
+ # @param author [Nokogiri::XML::Element]
+ # @param reference [Nokogiri::XML::Element]
+ #
+ # @return [RelatonBib::FullName]
+ #
+ def full_name(author, reference)
+ lang = language reference
+ sname, inits = parse_surname_initials author
+ initials = localized_string(inits, lang)
+ RelatonBib::FullName.new(
+ completename: localized_string(author[:fullname], lang),
+ initials: initials, forename: forename(inits, lang),
+ surname: localized_string(sname, lang)
+ )
+ end
+
+ def parse_surname_initials(author)
+ regex = /(?:[A-Z]{1,2}(?:\.[\s-]?|\s))+/
+ surname = author[:surname] || author[:fullname].sub(regex, "").strip
+ inits = author[:initials] || regex.match(author[:fullname])&.to_s&.strip
+ [surname, inits]
+ end
+
+ def parse_surname(fullname)
+ fullname.sub(/(?:[A-Z]{1,2}(?:\.[\s-]?|\s))+/, "").strip
+ end
+
+ def parse_initials(fullname)
+ fullname.match(/(?:[A-Z]{1,2}(?:\.[\s-]?|\s))+/).to_s.strip
end
end
end