Class: Relaton::Ieee::IdamsParser
- Inherits:
-
Object
- Object
- Relaton::Ieee::IdamsParser
- Includes:
- Core::ArrayWrapper
- Defined in:
- lib/relaton/ieee/idams_parser.rb
Constant Summary collapse
- ATTRS =
%i[ docnumber title date docidentifier contributor abstract copyright status relation source keyword ext ].freeze
Instance Method Summary collapse
-
#create_committee_contributor(committee) ⇒ Relaton::Bib::Contributor
Create a committee contributor.
-
#docnumber ⇒ String
Parse docnumber.
-
#initialize(doc, fetcher, errors = {}) ⇒ IdamsParser
constructor
A new instance of IdamsParser.
-
#parse ⇒ Relaton::Ieee::ItemData
Parse IEEE document.
-
#parse_abstract ⇒ Array<Relaton::Bib::LocalizedMarkedUpString>
Parse abstract.
-
#parse_committee_contributors ⇒ Array<Relaton::Bib::Contributor>
Parse committee contributors from editorial group.
-
#parse_contributor ⇒ Array<Relaton::Bib::Contributor>
Parse contributors.
-
#parse_copyright ⇒ Array<Relaton::Bib::Copyright>
Parse copyright.
-
#parse_date ⇒ Array<Relaton::Bib::Date>
Parse date.
-
#parse_docidentifier ⇒ Array<Relaton::Bib::Docidentifier>
Parse identifiers.
- #parse_docnumber ⇒ Object
-
#parse_keyword ⇒ Array<Strign>
Parse keyword.
-
#parse_relation ⇒ Array<Relaton::Bib::Relation>
Parse relation.
-
#parse_source ⇒ Array<Relaton::Bib::Uri>
Parce source link.
-
#parse_status ⇒ Relaton::Bib::Status?
Parse status.
-
#parse_title ⇒ Array<Relaton::Bib::Title>
Parse title.
-
#pubid ⇒ Relaton::Ieee::RawbibIdParser
Create PubID.
Constructor Details
#initialize(doc, fetcher, errors = {}) ⇒ IdamsParser
Returns a new instance of IdamsParser.
14 15 16 17 18 |
# File 'lib/relaton/ieee/idams_parser.rb', line 14 def initialize(doc, fetcher, errors = {}) @doc = doc @fetcher = fetcher @errors = errors end |
Instance Method Details
#create_committee_contributor(committee) ⇒ Relaton::Bib::Contributor
Create a committee contributor
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/relaton/ieee/idams_parser.rb', line 140 def create_committee_contributor(committee) desc = Bib::LocalizedMarkedUpString.new(content: "committee", language: "en", script: "Latn") role = Bib::Contributor::Role.new(type: "author", description: [desc]) # Create IEEE organization with committee as subdivision orgname = Bib::TypedLocalizedString.new( content: "Institute of Electrical and Electronics Engineers", language: "en", script: "Latn" ) abbr = Bib::LocalizedString.new(content: "IEEE") # Create subdivision for the committee subdiv_name = Bib::TypedLocalizedString.new(content: CGI.unescapeHTML(committee), language: "en", script: "Latn") subdivision = Bib::Subdivision.new(type: "committee", name: [subdiv_name]) org = Bib::Organization.new(name: [orgname], abbreviation: abbr, subdivision: [subdivision]) Relaton::Bib::Contributor.new(organization: org, role: [role]) end |
#docnumber ⇒ String
Parse docnumber
42 43 44 |
# File 'lib/relaton/ieee/idams_parser.rb', line 42 def docnumber @docnumber ||= pubid&.to_id end |
#parse ⇒ Relaton::Ieee::ItemData
Parse IEEE document
25 26 27 28 29 |
# File 'lib/relaton/ieee/idams_parser.rb', line 25 def parse args = { type: "standard", language: ["en"], script: ["Latn"] } ATTRS.each { |attr| args[attr] = send("parse_#{attr}") } ItemData.new(**args) end |
#parse_abstract ⇒ Array<Relaton::Bib::LocalizedMarkedUpString>
Parse abstract
163 164 165 166 167 168 169 170 171 |
# File 'lib/relaton/ieee/idams_parser.rb', line 163 def parse_abstract result = @doc.volume.article.articleinfo.abstract.each_with_object([]) do |abs, acc| next unless abs.abstract_type == "Standard" acc << Bib::Abstract.new(content: abs.value, language: "en", script: "Latn") end @errors[:abstract] &&= result.empty? result end |
#parse_committee_contributors ⇒ Array<Relaton::Bib::Contributor>
Parse committee contributors from editorial group
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/relaton/ieee/idams_parser.rb', line 122 def parse_committee_contributors committees = @doc.editorialgroup return [] unless committees result = committees.map do |committee| create_committee_contributor(committee) end @errors[:committee] &&= result.empty? result end |
#parse_contributor ⇒ Array<Relaton::Bib::Contributor>
Parse contributors
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/relaton/ieee/idams_parser.rb', line 102 def parse_contributor contributors = [] # Add publisher contributor name, addr = @doc.contrib_name_addr { |args| Relaton::Bib::Address.new(**args) } org = create_org name, addr role = Bib::Contributor::Role.new type: "publisher" contributors << Relaton::Bib::Contributor.new(organization: org, role: [role]) # Add committee contributors from editorial group result = contributors + parse_committee_contributors @errors[:contributor] &&= result.empty? result end |
#parse_copyright ⇒ Array<Relaton::Bib::Copyright>
Parse copyright
178 179 180 181 182 183 184 185 |
# File 'lib/relaton/ieee/idams_parser.rb', line 178 def parse_copyright result = @doc.copyright.map do |owner, year| contrib = owner.map { |own| Bib::ContributionInfo.new organization: create_org(own) } Bib::Copyright.new(owner: contrib, from: year) end @errors[:copyright] &&= result.empty? result end |
#parse_date ⇒ Array<Relaton::Bib::Date>
Parse date
75 76 77 78 79 |
# File 'lib/relaton/ieee/idams_parser.rb', line 75 def parse_date result = @doc.bdate.map { |args| Bib::Date.new(type: args[:type], at: args[:on]) } @errors[:date] &&= result.empty? result end |
#parse_docidentifier ⇒ Array<Relaton::Bib::Docidentifier>
Parse identifiers
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/relaton/ieee/idams_parser.rb', line 86 def parse_docidentifier # rubocop:disable Metrics/MethodLength ids = @doc.isbn_doi.map { |id| id[:content] = id.delete(:id); id } ids.unshift(content: pubid.to_s(trademark: true), scope: "trademark", type: "IEEE", primary: true) ids.unshift(content: pubid.to_s, type: "IEEE", primary: true) result = ids.map { |dcid| Bib::Docidentifier.new(**dcid) } @errors[:docidentifier] &&= result.empty? result end |
#parse_docnumber ⇒ Object
31 32 33 34 35 |
# File 'lib/relaton/ieee/idams_parser.rb', line 31 def parse_docnumber result = docnumber @errors[:docnumber] &&= result.nil? result end |
#parse_keyword ⇒ Array<Strign>
Parse keyword
234 235 236 237 238 239 240 |
# File 'lib/relaton/ieee/idams_parser.rb', line 234 def parse_keyword result = @doc.keyword.map do |kw| Bib::Keyword.new(vocab: Bib::LocalizedString.new(content: CGI.unescapeHTML(kw), language: "en", script: "Latn")) end @errors[:keyword] &&= result.empty? result end |
#parse_relation ⇒ Array<Relaton::Bib::Relation>
Parse relation
205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/relaton/ieee/idams_parser.rb', line 205 def parse_relation # rubocop:disable Metrics/AbcSize result = array(@doc.publicationinfo.standard_relationship).each_with_object([]) do |relation, acc| if (ref = @fetcher.backrefs[relation.date_string]) rel = @fetcher.create_relation(relation.type, ref) acc << rel if rel elsif !relation.date_string.include?("Inactive Date") && docnumber @fetcher.add_crossref(docnumber, relation) end end @errors[:relation] &&= result.empty? result end |
#parse_source ⇒ Array<Relaton::Bib::Uri>
Parce source link
223 224 225 226 227 |
# File 'lib/relaton/ieee/idams_parser.rb', line 223 def parse_source result = @doc.link { |url| Bib::Uri.new(content: url, type: "src") } @errors[:source] &&= result.empty? result end |
#parse_status ⇒ Relaton::Bib::Status?
Parse status
192 193 194 195 196 197 198 |
# File 'lib/relaton/ieee/idams_parser.rb', line 192 def parse_status return if @doc.docstatus.nil? || @doc.docstatus.empty? @errors[:status] &&= @doc.docstatus[:stage].nil? stage = Bib::Status::Stage.new content: @doc.docstatus[:stage] Bib::Status.new stage: stage end |
#parse_title ⇒ Array<Relaton::Bib::Title>
Parse title
64 65 66 67 68 |
# File 'lib/relaton/ieee/idams_parser.rb', line 64 def parse_title result = @doc.btitle.map { |args| Bib::Title.new(**args) } @errors[:title] &&= result.empty? result end |
#pubid ⇒ Relaton::Ieee::RawbibIdParser
Create PubID
51 52 53 54 55 56 57 |
# File 'lib/relaton/ieee/idams_parser.rb', line 51 def pubid @pubid ||= begin normtitle = @doc.normtitle stdnumber = @doc.publicationinfo.stdnumber RawbibIdParser.parse(normtitle, stdnumber) end end |