Class: RelatonIeee::IdamsParser

Inherits:
Object
  • Object
show all
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

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

#docnumberString

Parse docnumber

Returns:

  • (String)

    PubID



36
37
38
# File 'lib/relaton_ieee/idams_parser.rb', line 36

def docnumber
  @docnumber ||= pubid&.to_id
end

#parseRelatonIeee::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_abstractArray<RelatonBib::FormattedString>

Parse abstract

Returns:

  • (Array<RelatonBib::FormattedString>)


102
103
104
105
106
# File 'lib/relaton_ieee/idams_parser.rb', line 102

def parse_abstract
  @doc.volume.article..abstract.map do |abs|
    RelatonBib::FormattedString.new(content: abs.value, language: "en", script: "Latn")
  end
end

#parse_contributorArray<RelatonBib::ContributionInfo>

Parse contributors

Returns:

  • (Array<RelatonBib::ContributionInfo>)


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

Returns:

  • (Array<RelatonBib::CopyrightAssociation>)


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_dateArray<RelatonBib::BibliographicDate>

Parse date

Returns:

  • (Array<RelatonBib::BibliographicDate>)


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_docidArray<RelatonBib::DocumentIdentifier>

Parse identifiers

Returns:

  • (Array<RelatonBib::DocumentIdentifier>)


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_docnumberObject



27
28
29
# File 'lib/relaton_ieee/idams_parser.rb', line 27

def parse_docnumber
  docnumber
end

#parse_docstatusRelatonIee::DocumentStatus?

Parse status

Returns:

  • (RelatonIee::DocumentStatus, nil)


125
126
127
# File 'lib/relaton_ieee/idams_parser.rb', line 125

def parse_docstatus
  @doc.docstatus { |args| DocumentStatus.new(**args) }
end

#parse_doctypeString

Parse doctype

Returns:

  • (String)

    doctype



224
225
226
# File 'lib/relaton_ieee/idams_parser.rb', line 224

def parse_doctype
  DocumentType.new type: @doc.doctype
end

#parse_editorialgroupRelatonIeee::EditorialGroup?

Parse editorialgroup

Returns:



179
180
181
# File 'lib/relaton_ieee/idams_parser.rb', line 179

def parse_editorialgroup
  @doc.editorialgroup { |committee| EditorialGroup.new committee: committee }
end

#parse_holdstatusString?

Pasrse holdstatus

Returns:

  • (String, nil)

    holdstatus or nil



215
216
217
# File 'lib/relaton_ieee/idams_parser.rb', line 215

def parse_holdstatus
  @doc.publicationinfo.holdstatus
end

#parse_icsArray<RelatonBib::ICS>

Parse ICS

Returns:

  • (Array<RelatonBib::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_keywordArray<Strign>

Parse keyword

Returns:

  • (Array<Strign>)


161
162
163
# File 'lib/relaton_ieee/idams_parser.rb', line 161

def parse_keyword
  @doc.keyword
end

Parce link

Returns:

  • (Array<RelatonBib::TypedUri>)


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_pubstatusString?

Parse pubstatus

Returns:

  • (String, nil)

    pubstatus or nil



206
207
208
# File 'lib/relaton_ieee/idams_parser.rb', line 206

def parse_pubstatus
  @doc.publicationinfo.pubstatus
end

#parse_relationRelatonBib::DocRelationCollection

Parse relation

Returns:

  • (RelatonBib::DocRelationCollection)


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_modifiedString?

Parse standard modifier

Returns:

  • (String, nil)

    standard modifier or nil



197
198
199
# File 'lib/relaton_ieee/idams_parser.rb', line 197

def parse_standard_modified
  @doc.standard_modifier
end

#parse_standard_statusString?

Parse standard status

Returns:

  • (String, nil)

    standard status or nil



188
189
190
# File 'lib/relaton_ieee/idams_parser.rb', line 188

def parse_standard_status
  @doc.publicationinfo.standard_status
end

#parse_titleArray<RelatonBib::TypedTitleString>

Parse title

Returns:

  • (Array<RelatonBib::TypedTitleString>)


58
59
60
# File 'lib/relaton_ieee/idams_parser.rb', line 58

def parse_title
  @doc.btitle.map { |args| RelatonBib::TypedTitleString.new(**args) }
end

#pubidRelatonIeee::RawbibIdParser

Create PubID

Returns:



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