Class: RelatonIeee::IdamsParser
- Inherits:
-
Object
- Object
- RelatonIeee::IdamsParser
- Defined in:
- lib/relaton_ieee/idams_parser.rb
Constant Summary collapse
- ATTRS =
%i[ docnumber title date docid contributor abstract copyright docstatus relation link keyword ics editorialgroup standard_status standard_modified pubstatus holdstatus doctype ].freeze
Instance Method Summary collapse
-
#docnumber ⇒ String
Parse docnumber.
-
#initialize(doc, fetcher) ⇒ IdamsParser
constructor
A new instance of IdamsParser.
-
#parse ⇒ RelatonIeee::IeeeBibliographicItem
Parse IEEE document.
-
#parse_abstract ⇒ Array<RelatonBib::FormattedString>
Parse abstract.
-
#parse_contributor ⇒ Array<RelatonBib::ContributionInfo>
Parse contributors.
-
#parse_copyright ⇒ Array<RelatonBib::CopyrightAssociation>
Parse copyright.
-
#parse_date ⇒ Array<RelatonBib::BibliographicDate>
Parse date.
-
#parse_docid ⇒ Array<RelatonBib::DocumentIdentifier>
Parse identifiers.
- #parse_docnumber ⇒ Object
-
#parse_docstatus ⇒ RelatonIee::DocumentStatus?
Parse status.
-
#parse_doctype ⇒ String
Parse doctype.
-
#parse_editorialgroup ⇒ RelatonIeee::EditorialGroup?
Parse editorialgroup.
-
#parse_holdstatus ⇒ String?
Pasrse holdstatus.
-
#parse_ics ⇒ Array<RelatonBib::ICS>
Parse ICS.
-
#parse_keyword ⇒ Array<Strign>
Parse keyword.
-
#parse_link ⇒ Array<RelatonBib::TypedUri>
Parce link.
-
#parse_pubstatus ⇒ String?
Parse pubstatus.
-
#parse_relation ⇒ RelatonBib::DocRelationCollection
Parse relation.
-
#parse_standard_modified ⇒ String?
Parse standard modifier.
-
#parse_standard_status ⇒ String?
Parse standard status.
-
#parse_title ⇒ Array<RelatonBib::TypedTitleString>
Parse title.
-
#pubid ⇒ RelatonIeee::RawbibIdParser
Create PubID.
Constructor Details
#initialize(doc, fetcher) ⇒ IdamsParser
Returns a new instance of IdamsParser.
11 12 13 14 |
# File 'lib/relaton_ieee/idams_parser.rb', line 11 def initialize(doc, fetcher) @doc = doc @fetcher = fetcher end |
Instance Method Details
#docnumber ⇒ String
Parse docnumber
36 37 38 |
# File 'lib/relaton_ieee/idams_parser.rb', line 36 def docnumber @docnumber ||= pubid&.to_id end |
#parse ⇒ RelatonIeee::IeeeBibliographicItem
Parse IEEE document
21 22 23 24 25 |
# File 'lib/relaton_ieee/idams_parser.rb', line 21 def parse args = { type: "standard", language: ["en"], script: ["Latn"] } ATTRS.each { |attr| args[attr] = send("parse_#{attr}") } IeeeBibliographicItem.new(**args) end |
#parse_abstract ⇒ Array<RelatonBib::FormattedString>
Parse abstract
102 103 104 105 106 |
# File 'lib/relaton_ieee/idams_parser.rb', line 102 def parse_abstract @doc.volume.article.articleinfo.abstract.map do |abs| RelatonBib::FormattedString.new(content: abs.value, language: "en", script: "Latn") end end |
#parse_contributor ⇒ Array<RelatonBib::ContributionInfo>
Parse contributors
90 91 92 93 94 95 |
# File 'lib/relaton_ieee/idams_parser.rb', line 90 def parse_contributor name, addr = @doc.contrib_name_addr { |args| RelatonBib::Address.new(**args) } entity = create_org name, addr [RelatonBib::ContributionInfo.new(entity: entity, role: [type: "publisher"])] end |
#parse_copyright ⇒ Array<RelatonBib::CopyrightAssociation>
Parse copyright
113 114 115 116 117 118 |
# File 'lib/relaton_ieee/idams_parser.rb', line 113 def parse_copyright @doc.copyright.map do |owner, year| contrib = owner.map { |own| RelatonBib::ContributionInfo.new entity: create_org(own) } RelatonBib::CopyrightAssociation.new(owner: contrib, from: year) end end |
#parse_date ⇒ Array<RelatonBib::BibliographicDate>
Parse date
67 68 69 |
# File 'lib/relaton_ieee/idams_parser.rb', line 67 def parse_date @doc.bdate.map { |args| RelatonBib::BibliographicDate.new(**args) } end |
#parse_docid ⇒ Array<RelatonBib::DocumentIdentifier>
Parse identifiers
76 77 78 79 80 81 82 83 |
# File 'lib/relaton_ieee/idams_parser.rb', line 76 def parse_docid # rubocop:disable Metrics/MethodLength ids = @doc.isbn_doi ids.unshift(id: pubid.to_s(trademark: true), scope: "trademark", type: "IEEE", primary: true) ids.unshift(id: pubid.to_s, type: "IEEE", primary: true) ids.map { |dcid| RelatonBib::DocumentIdentifier.new(**dcid) } end |
#parse_docnumber ⇒ Object
27 28 29 |
# File 'lib/relaton_ieee/idams_parser.rb', line 27 def parse_docnumber docnumber end |
#parse_docstatus ⇒ RelatonIee::DocumentStatus?
Parse status
125 126 127 |
# File 'lib/relaton_ieee/idams_parser.rb', line 125 def parse_docstatus @doc.docstatus { |args| DocumentStatus.new(**args) } end |
#parse_doctype ⇒ String
Parse doctype
224 225 226 |
# File 'lib/relaton_ieee/idams_parser.rb', line 224 def parse_doctype DocumentType.new type: @doc.doctype end |
#parse_editorialgroup ⇒ RelatonIeee::EditorialGroup?
Parse editorialgroup
179 180 181 |
# File 'lib/relaton_ieee/idams_parser.rb', line 179 def parse_editorialgroup @doc.editorialgroup { |committee| EditorialGroup.new committee: committee } end |
#parse_holdstatus ⇒ String?
Pasrse holdstatus
215 216 217 |
# File 'lib/relaton_ieee/idams_parser.rb', line 215 def parse_holdstatus @doc.publicationinfo.holdstatus end |
#parse_ics ⇒ Array<RelatonBib::ICS>
Parse ICS
170 171 172 |
# File 'lib/relaton_ieee/idams_parser.rb', line 170 def parse_ics @doc.ics { |ics| RelatonBib::ICS.new(**ics) } end |
#parse_keyword ⇒ Array<Strign>
Parse keyword
161 162 163 |
# File 'lib/relaton_ieee/idams_parser.rb', line 161 def parse_keyword @doc.keyword end |
#parse_link ⇒ Array<RelatonBib::TypedUri>
Parce link
152 153 154 |
# File 'lib/relaton_ieee/idams_parser.rb', line 152 def parse_link @doc.link { |url| RelatonBib::TypedUri.new(content: url, type: "src") } end |
#parse_pubstatus ⇒ String?
Parse pubstatus
206 207 208 |
# File 'lib/relaton_ieee/idams_parser.rb', line 206 def parse_pubstatus @doc.publicationinfo.pubstatus end |
#parse_relation ⇒ RelatonBib::DocRelationCollection
Parse relation
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/relaton_ieee/idams_parser.rb', line 134 def parse_relation # rubocop:disable Metrics/AbcSize rels = [] @doc.publicationinfo.standard_relationship&.each do |relation| if (ref = @fetcher.backrefs[relation.date_string]) rel = @fetcher.create_relation(relation.type, ref) rels << rel if rel elsif !relation.date_string.include?("Inactive Date") && docnumber @fetcher.add_crossref(docnumber, relation) end end RelatonBib::DocRelationCollection.new rels end |
#parse_standard_modified ⇒ String?
Parse standard modifier
197 198 199 |
# File 'lib/relaton_ieee/idams_parser.rb', line 197 def parse_standard_modified @doc.standard_modifier end |
#parse_standard_status ⇒ String?
Parse standard status
188 189 190 |
# File 'lib/relaton_ieee/idams_parser.rb', line 188 def parse_standard_status @doc.publicationinfo.standard_status end |
#parse_title ⇒ Array<RelatonBib::TypedTitleString>
Parse title
58 59 60 |
# File 'lib/relaton_ieee/idams_parser.rb', line 58 def parse_title @doc.btitle.map { |args| RelatonBib::TypedTitleString.new(**args) } end |
#pubid ⇒ RelatonIeee::RawbibIdParser
Create PubID
45 46 47 48 49 50 51 |
# File 'lib/relaton_ieee/idams_parser.rb', line 45 def pubid @pubid ||= begin normtitle = @doc.normtitle stdnumber = @doc.publicationinfo.stdnumber RawbibIdParser.parse(normtitle, stdnumber) end end |