Class: Relaton::Ieee::DataFetcher
- Inherits:
-
Core::DataFetcher
- Object
- Core::DataFetcher
- Relaton::Ieee::DataFetcher
- Defined in:
- lib/relaton/ieee/data_fetcher.rb
Constant Summary collapse
- RELATION_TYPES =
{ "S" => { type: "obsoletedBy" }, "V" => { type: "updates", description: "revises" }, "T" => { type: "updates", description: "amends" }, "C" => { type: "updates", description: "corrects" }, "O" => { type: "adoptedFrom" }, "P" => { type: "complementOf", description: "supplement" }, "N" => false, "G" => false, "F" => false, "I" => false, "E" => false, "B" => false, "W" => false }.freeze
Instance Method Summary collapse
-
#add_crossref(docnumber, amsid) ⇒ Object
Save unresolved relation reference.
-
#backrefs ⇒ Hash
List of AMSID => PubID.
-
#create_relation(type, fref) ⇒ RelatonBib::DocumentRelation
Create relation instance.
-
#fetch(_source = nil) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
-
#log_error(msg) ⇒ Object
Convert documents from ‘ieee-rawbib` dir (IEEE dataset) to BibYAML/BibXML.
Instance Method Details
#add_crossref(docnumber, amsid) ⇒ Object
Save unresolved relation reference
55 56 57 58 59 60 |
# File 'lib/relaton/ieee/data_fetcher.rb', line 55 def add_crossref(docnumber, amsid) return if RELATION_TYPES[amsid.type] == false ref = { amsid: amsid.date_string, type: amsid.type } crossrefs[docnumber] << ref end |
#backrefs ⇒ Hash
Returns list of AMSID => PubID.
45 46 47 |
# File 'lib/relaton/ieee/data_fetcher.rb', line 45 def backrefs @backrefs ||= {} end |
#create_relation(type, fref) ⇒ RelatonBib::DocumentRelation
Create relation instance
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/relaton/ieee/data_fetcher.rb', line 70 def create_relation(type, fref) unless RELATION_TYPES.key? type Util.warn "Unknown relation type: '#{type}' for reference '#{fref}'", key: fref return end return if RELATION_TYPES[type] == false docid = Bib::Docidentifier.new(type: "IEEE", content: fref, primary: true) bib = ItemData.new formattedref: Bib::Formattedref.new(content: fref), docidentifier: [docid] description = create_relation_description type Bib::Relation.new(type: RELATION_TYPES[type][:type], description: description, bibitem: bib) end |
#fetch(_source = nil) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/relaton/ieee/data_fetcher.rb', line 29 def fetch(_source = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength Dir["ieee-rawbib/**/*.{xml,zip}"].reject { |f| f["Deleted_"] }.each do |f| xml = case File.extname(f) when ".zip" then read_zip f when ".xml" then File.read f, encoding: "UTF-8" end fetch_doc xml, f rescue StandardError => e Util.error "File: #{f}\n#{e.}\n#{e.backtrace}" end # File.write "normtitles.txt", @normtitles.join("\n") update_relations report_errors end |
#log_error(msg) ⇒ Object
Convert documents from ‘ieee-rawbib` dir (IEEE dataset) to BibYAML/BibXML
25 26 27 |
# File 'lib/relaton/ieee/data_fetcher.rb', line 25 def log_error(msg) Util.error msg end |