relaton-bipm 2.0.0.pre.alpha.3 → 2.0.0.pre.alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/grammars/basicdoc.rng +14 -1
- data/grammars/biblio.rng +8 -8
- data/lib/relaton/bipm/data_fetcher.rb +6 -1
- data/lib/relaton/bipm/data_outcomes_parser.rb +44 -12
- data/lib/relaton/bipm/rawdata_bipm_metrologia/article_parser.rb +74 -38
- data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +3 -3
- data/lib/relaton/bipm/si_brochure_parser.rb +4 -1
- data/lib/relaton/bipm/version.rb +1 -1
- data/relaton_bipm.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9be07b442d7fb5c0abcb1fca8c2beffc61253b1722905d2d98e6fdec7652646f
|
|
4
|
+
data.tar.gz: 001f747904436a23b994399cf2879425f0537f9ceb4e93b2db44df33a187f488
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: badf68210731ae52ff277e813a5ebe89ca43a90deae861f9d036fa7f861b2ee2683713d4803a6b08fc1b68aa04faa4645182ffcbd4be869228ef105c75994c30
|
|
7
|
+
data.tar.gz: d66a7a99a3ae2d9634c501a7afdcd461ad48858e32f2c2d0bed5c55d22c3b567fc24ec51ca21960a87df5eceb052ea8726867f2b2f3df9a92c83b65b48236f5d
|
data/grammars/basicdoc.rng
CHANGED
|
@@ -187,6 +187,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
187
187
|
<a:documentation>Optional caption of this block</a:documentation>
|
|
188
188
|
</attribute>
|
|
189
189
|
</optional>
|
|
190
|
+
<optional>
|
|
191
|
+
<attribute name="position">
|
|
192
|
+
<a:documentation>For an "add" change, whether the change is added before or after the location</a:documentation>
|
|
193
|
+
<choice>
|
|
194
|
+
<value>before</value>
|
|
195
|
+
<value>after</value>
|
|
196
|
+
</choice>
|
|
197
|
+
</attribute>
|
|
198
|
+
</optional>
|
|
190
199
|
<optional>
|
|
191
200
|
<element name="location">
|
|
192
201
|
<a:documentation>The location(s) in the original document which have undergone the change described in this block</a:documentation>
|
|
@@ -208,11 +217,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
208
217
|
</zeroOrMore>
|
|
209
218
|
<optional>
|
|
210
219
|
<element name="newcontent">
|
|
211
|
-
<a:documentation>New content to be added to the document; applicable to add and modify
|
|
220
|
+
<a:documentation>New content to be added to the document; applicable to add and modify.
|
|
221
|
+
Can be blocks and/or sections</a:documentation>
|
|
212
222
|
<ref name="OptionalId"/>
|
|
213
223
|
<zeroOrMore>
|
|
214
224
|
<ref name="BasicBlock"/>
|
|
215
225
|
</zeroOrMore>
|
|
226
|
+
<zeroOrMore>
|
|
227
|
+
<ref name="section"/>
|
|
228
|
+
</zeroOrMore>
|
|
216
229
|
</element>
|
|
217
230
|
</optional>
|
|
218
231
|
<zeroOrMore>
|
data/grammars/biblio.rng
CHANGED
|
@@ -1142,11 +1142,11 @@ NOTE: This should preferably be encoded as a URI or short identifier, rather th
|
|
|
1142
1142
|
<a:documentation>Information about how long the current description of the bibliographic item is valid for</a:documentation>
|
|
1143
1143
|
</ref>
|
|
1144
1144
|
</optional>
|
|
1145
|
-
<
|
|
1145
|
+
<zeroOrMore>
|
|
1146
1146
|
<ref name="depiction">
|
|
1147
1147
|
<a:documentation>Depiction of the bibliographic item, typically an image</a:documentation>
|
|
1148
1148
|
</ref>
|
|
1149
|
-
</
|
|
1149
|
+
</zeroOrMore>
|
|
1150
1150
|
</define>
|
|
1151
1151
|
<define name="ReducedBibliographicItem">
|
|
1152
1152
|
<a:documentation>Reduced description of a bibliographic resource, without mandatory title and docidentifier, used for document relations
|
|
@@ -1939,10 +1939,10 @@ Detailed in https://www.relaton.org/model/relations/</a:documentation>
|
|
|
1939
1939
|
<value>hasAnnotation</value>
|
|
1940
1940
|
<value>draftOf</value>
|
|
1941
1941
|
<value>hasDraft</value>
|
|
1942
|
-
<value>
|
|
1943
|
-
<value>
|
|
1944
|
-
<value>
|
|
1945
|
-
<value>
|
|
1942
|
+
<value>predecessorDraftOf</value>
|
|
1943
|
+
<value>hasPredecessorDraft</value>
|
|
1944
|
+
<value>successorDraftOf</value>
|
|
1945
|
+
<value>hasSuccessorDraft</value>
|
|
1946
1946
|
<value>editionOf</value>
|
|
1947
1947
|
<value>hasEdition</value>
|
|
1948
1948
|
<value>updates</value>
|
|
@@ -2063,13 +2063,13 @@ provided that it is not the entire bibliographic item that is so related</a:docu
|
|
|
2063
2063
|
<ref name="LocalizedString"/>
|
|
2064
2064
|
</element>
|
|
2065
2065
|
</optional>
|
|
2066
|
-
<
|
|
2066
|
+
<zeroOrMore>
|
|
2067
2067
|
<element name="taxon">
|
|
2068
2068
|
<a:documentation>The keywords as a hierarchical taxonomy. For example, the sequence of `taxon` elements
|
|
2069
2069
|
`pump`, `centrifugal pump`, `line shaft pump` represents a taxonomic classification</a:documentation>
|
|
2070
2070
|
<ref name="LocalizedString"/>
|
|
2071
2071
|
</element>
|
|
2072
|
-
</
|
|
2072
|
+
</zeroOrMore>
|
|
2073
2073
|
<zeroOrMore>
|
|
2074
2074
|
<ref name="vocabid">
|
|
2075
2075
|
<a:documentation>Identifiers for the keyword as a controlled vocabulary</a:documentation>
|
|
@@ -6,12 +6,16 @@ require_relative "rawdata_bipm_metrologia/fetcher"
|
|
|
6
6
|
|
|
7
7
|
module Relaton::Bipm
|
|
8
8
|
class DataFetcher < Relaton::Core::DataFetcher
|
|
9
|
-
attr_reader :output, :format, :ext, :files, :index
|
|
9
|
+
attr_reader :output, :format, :ext, :files, :index, :errors
|
|
10
10
|
|
|
11
11
|
def index
|
|
12
12
|
@index ||= Relaton::Index.find_or_create :bipm, file: INDEXFILE
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def log_error(msg)
|
|
16
|
+
Util.error msg
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
#
|
|
16
20
|
# Fetch bipm-data-outcomes or si-brochure
|
|
17
21
|
#
|
|
@@ -24,6 +28,7 @@ module Relaton::Bipm
|
|
|
24
28
|
when "rawdata-bipm-metrologia" then RawdataBipmMetrologia::Fetcher.fetch(self)
|
|
25
29
|
end
|
|
26
30
|
index.save
|
|
31
|
+
report_errors
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
#
|
|
@@ -167,6 +167,7 @@ module Relaton::Bipm
|
|
|
167
167
|
args[:en]["resolutions"].each.with_index do |r, i| # rubocop:disable Metrics/BlockLength
|
|
168
168
|
num = r["identifier"].to_s # .split("-").last
|
|
169
169
|
date = r["dates"].first.to_s
|
|
170
|
+
@data_fetcher.errors[:resolution_date] &&= date.nil? || date.empty?
|
|
170
171
|
year = date.split("-").first
|
|
171
172
|
num = "0" if num == year
|
|
172
173
|
|
|
@@ -179,8 +180,8 @@ module Relaton::Bipm
|
|
|
179
180
|
|
|
180
181
|
fr_r = args.dig(:fr, "resolutions", i) # @TODO: create a GH issue when fr is missing
|
|
181
182
|
hash[:title] = resolution_title r, fr_r
|
|
182
|
-
hash[:source] =
|
|
183
|
-
hash[:date] =
|
|
183
|
+
hash[:source] = resolution_source r, fr_r, args[:src]
|
|
184
|
+
hash[:date] = create_date(type: "published", at: date)
|
|
184
185
|
num_justed = num.rjust 2, "0"
|
|
185
186
|
type = r["type"].capitalize
|
|
186
187
|
docnum = create_resolution_docnum args[:body], type, num, date
|
|
@@ -190,6 +191,7 @@ module Relaton::Bipm
|
|
|
190
191
|
hash[:language] = %w[en fr]
|
|
191
192
|
hash[:script] = ["Latn"]
|
|
192
193
|
hash[:contributor] = contributors date, args[:body]
|
|
194
|
+
@data_fetcher.errors[:resolution_contributor] &&= hash[:contributor].size < 2 # BIPM + committee
|
|
193
195
|
item = ItemData.new(**hash)
|
|
194
196
|
file = "#{year}-#{num_justed}.#{@data_fetcher.ext}"
|
|
195
197
|
out_dir = File.join args[:dir], r["type"].downcase
|
|
@@ -225,6 +227,7 @@ module Relaton::Bipm
|
|
|
225
227
|
title = []
|
|
226
228
|
title << create_title(en_r["title"], "en") if en_r["title"] && !en_r["title"].empty?
|
|
227
229
|
title << create_title(fr_r["title"], "fr") if fr_r && fr_r["title"] && !fr_r["title"].empty?
|
|
230
|
+
@data_fetcher.errors[:resolution_title] &&= title.empty?
|
|
228
231
|
title
|
|
229
232
|
end
|
|
230
233
|
|
|
@@ -237,14 +240,28 @@ module Relaton::Bipm
|
|
|
237
240
|
#
|
|
238
241
|
# @return [Array<Hash>] links
|
|
239
242
|
#
|
|
240
|
-
def
|
|
241
|
-
|
|
242
|
-
if
|
|
243
|
-
|
|
243
|
+
def resolution_source(en_r, fr_r, src)
|
|
244
|
+
source = []
|
|
245
|
+
if en_r["url"] && !en_r["url"].empty?
|
|
246
|
+
source << Relaton::Bib::Uri.new(type: "citation", content: en_r["url"], language: "en", script: "Latn")
|
|
247
|
+
@data_fetcher.errors[:resolution_source_citation_en] = false
|
|
248
|
+
else
|
|
249
|
+
@data_fetcher.errors[:resolution_source_citation] &&= true
|
|
250
|
+
end
|
|
251
|
+
if fr_r && fr_r["url"] && !fr_r["url"].empty?
|
|
252
|
+
source << Relaton::Bib::Uri.new(type: "citation", content: fr_r["url"], language: "fr", script: "Latn")
|
|
253
|
+
@data_fetcher.errors[:resolution_source_citation_fr] = false
|
|
254
|
+
else
|
|
255
|
+
@data_fetcher.errors[:resolution_source_citation_fr] &&= true
|
|
256
|
+
end
|
|
257
|
+
source += src if src
|
|
258
|
+
if en_r["reference"]
|
|
259
|
+
source << Relaton::Bib::Uri.new(type: "pdf", content: en_r["reference"])
|
|
260
|
+
@data_fetcher.errors[:resolution_source_pdf] = false
|
|
261
|
+
else
|
|
262
|
+
@data_fetcher.errors[:resolution_source_pdf] &&= true
|
|
244
263
|
end
|
|
245
|
-
|
|
246
|
-
link << Relaton::Bib::Uri.new(type: "pdf", content: en_r["reference"]) if en_r["reference"]
|
|
247
|
-
link
|
|
264
|
+
source
|
|
248
265
|
end
|
|
249
266
|
|
|
250
267
|
#
|
|
@@ -446,21 +463,32 @@ module Relaton::Bipm
|
|
|
446
463
|
ext: create_ext(args[:type], args[:num]),
|
|
447
464
|
}
|
|
448
465
|
hash[:title] = create_titles args.slice(:en, :fr)
|
|
449
|
-
hash[:date] =
|
|
466
|
+
hash[:date] = create_date(type: "published", at: args[:en]["date"])
|
|
467
|
+
@data_fetcher.errors[:meeting_date] &&= hash[:date].empty?
|
|
450
468
|
hash[:docidentifier] = create_meeting_docids docnum
|
|
451
469
|
hash[:docnumber] = docnum # .sub(" --", "").sub(/\s\(\d{4}\)/, "")
|
|
452
470
|
hash[:id] = create_id(body: args[:body], type: args[:type], num: args[:num], date: args[:en]["date"])
|
|
453
471
|
hash[:source] = create_links(**args)
|
|
472
|
+
@data_fetcher.errors[:meeting_source] &&= hash[:source].empty?
|
|
454
473
|
hash[:language] = %w[en fr]
|
|
455
474
|
hash[:script] = ["Latn"]
|
|
456
475
|
hash[:contributor] = contributors args[:en]["date"], args[:body]
|
|
476
|
+
@data_fetcher.errors[:meeting_contributor] &&= hash[:contributor].size < 2 # BIPM + committee
|
|
457
477
|
hash
|
|
458
478
|
end
|
|
459
479
|
|
|
480
|
+
def create_date(**args)
|
|
481
|
+
return [] if args[:at].nil? || args[:at].empty?
|
|
482
|
+
|
|
483
|
+
[Relaton::Bib::Date.new(**args)]
|
|
484
|
+
end
|
|
485
|
+
|
|
460
486
|
def create_titles(data)
|
|
461
|
-
data.each_with_object([]) do |(lang, md), mem|
|
|
487
|
+
result = data.each_with_object([]) do |(lang, md), mem|
|
|
462
488
|
mem << create_title(md["title"], lang.to_s) if md && md["title"]
|
|
463
489
|
end
|
|
490
|
+
@data_fetcher.errors[:meeting_title] &&= result.empty?
|
|
491
|
+
result
|
|
464
492
|
end
|
|
465
493
|
|
|
466
494
|
#
|
|
@@ -555,6 +583,8 @@ module Relaton::Bipm
|
|
|
555
583
|
ids = []
|
|
556
584
|
resolution_short_ids(body, type, num, year) { |id| ids << id }
|
|
557
585
|
resolution_long_ids(body, type, num, year) { |id| ids << id }
|
|
586
|
+
@data_fetcher.errors[:resolution_docidentifier] &&= ids.empty?
|
|
587
|
+
ids
|
|
558
588
|
end
|
|
559
589
|
|
|
560
590
|
def resolution_short_ids(body, type, num, year, &_block)
|
|
@@ -600,11 +630,13 @@ module Relaton::Bipm
|
|
|
600
630
|
def create_meeting_docids(en_id)
|
|
601
631
|
fr_id = en_id.sub(/(\d+)(?:st|nd|rd|th)/, '\1e').sub("Meeting", "réunion")
|
|
602
632
|
fr_id_sup = fr_id.sub(/(\d+)(e)/, '\1<sup>\2</sup>')
|
|
603
|
-
[
|
|
633
|
+
result = [
|
|
604
634
|
make_docid(content: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
|
|
605
635
|
make_docid(content: fr_id_sup, type: "BIPM", primary: true, language: "fr", script: "Latn"),
|
|
606
636
|
make_docid(content: "#{en_id} / #{fr_id_sup}", type: "BIPM", primary: true),
|
|
607
637
|
]
|
|
638
|
+
@data_fetcher.errors[:meeting_docidentifier] &&= result.empty?
|
|
639
|
+
result
|
|
608
640
|
end
|
|
609
641
|
|
|
610
642
|
#
|
|
@@ -10,10 +10,10 @@ module Relaton::Bipm
|
|
|
10
10
|
#
|
|
11
11
|
# @return [Relaton::Bipm::ItemDate] document
|
|
12
12
|
#
|
|
13
|
-
def self.parse(path)
|
|
13
|
+
def self.parse(path, errors = {})
|
|
14
14
|
doc = Nokogiri::XML(File.read(path, encoding: "UTF-8"))
|
|
15
15
|
journal, volume, article = path.split("/")[-2].split("_")[1..]
|
|
16
|
-
new(doc, journal, volume, article).parse
|
|
16
|
+
new(doc, journal, volume, article, errors).parse
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
#
|
|
@@ -23,13 +23,15 @@ module Relaton::Bipm
|
|
|
23
23
|
# @param [String] journal journal
|
|
24
24
|
# @param [String] volume volume
|
|
25
25
|
# @param [String] article article
|
|
26
|
+
# @param [Hash] errors errors hash
|
|
26
27
|
#
|
|
27
|
-
def initialize(doc, journal, volume, article)
|
|
28
|
+
def initialize(doc, journal, volume, article, errors = {})
|
|
28
29
|
@doc = doc.at "/article"
|
|
29
30
|
@journal = journal
|
|
30
31
|
@volume = volume
|
|
31
32
|
@article = article
|
|
32
33
|
@meta = doc.at("/article/front/article-meta")
|
|
34
|
+
@errors = errors
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
#
|
|
@@ -50,9 +52,11 @@ module Relaton::Bipm
|
|
|
50
52
|
def parse_docidentifier
|
|
51
53
|
pubid = "#{journal_title} #{volume_issue_article}"
|
|
52
54
|
primary_id = create_docidentifier pubid, "BIPM", true
|
|
53
|
-
@meta.xpath("./article-id[@pub-id-type='doi']").each_with_object([primary_id]) do |id, m|
|
|
55
|
+
result = @meta.xpath("./article-id[@pub-id-type='doi']").each_with_object([primary_id]) do |id, m|
|
|
54
56
|
m << create_docidentifier(id.text, id["pub-id-type"])
|
|
55
57
|
end
|
|
58
|
+
@errors[:article_docidentifier] &&= result.empty?
|
|
59
|
+
result
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
#
|
|
@@ -74,7 +78,11 @@ module Relaton::Bipm
|
|
|
74
78
|
# @return [String] journal title
|
|
75
79
|
#
|
|
76
80
|
def journal_title
|
|
77
|
-
@
|
|
81
|
+
return @journal_title if defined? @journal_title
|
|
82
|
+
|
|
83
|
+
@journal_title = @doc.at("./front/journal-meta/journal-title-group/journal-title")&.text
|
|
84
|
+
@errors[:journal_title] &&= @journal_title.nil? || @journal_title.empty?
|
|
85
|
+
@journal_title
|
|
78
86
|
end
|
|
79
87
|
|
|
80
88
|
#
|
|
@@ -96,11 +104,13 @@ module Relaton::Bipm
|
|
|
96
104
|
# @return [Array<Relaton::Bib::TypedTitleString>] array of title strings
|
|
97
105
|
#
|
|
98
106
|
def parse_title
|
|
99
|
-
@meta.xpath("./title-group/article-title").map do |t|
|
|
107
|
+
result = @meta.xpath("./title-group/article-title").map do |t|
|
|
100
108
|
next if t.text.empty?
|
|
101
109
|
|
|
102
110
|
Relaton::Bib::Title.new(content: t.inner_html, language: t[:"xml:lang"], script: "Latn")
|
|
103
111
|
end.compact
|
|
112
|
+
@errors[:article_title] &&= result.empty?
|
|
113
|
+
result
|
|
104
114
|
end
|
|
105
115
|
|
|
106
116
|
#
|
|
@@ -109,23 +119,27 @@ module Relaton::Bipm
|
|
|
109
119
|
# @return [Array<Relaton::Bib::Contributor>] array of contributors
|
|
110
120
|
#
|
|
111
121
|
def parse_contributor
|
|
112
|
-
@meta.xpath("./contrib-group/contrib").map do |c|
|
|
122
|
+
result = @meta.xpath("./contrib-group/contrib").map do |c|
|
|
113
123
|
role = Relaton::Bib::Contributor::Role.new(type: c[:"contrib-type"])
|
|
114
124
|
attrs = { person: create_person(c), organization: create_organization(c), role: [role] }
|
|
115
125
|
Relaton::Bib::Contributor.new(**attrs)
|
|
116
126
|
end
|
|
127
|
+
@errors[:article_contributor] &&= result.empty?
|
|
128
|
+
result
|
|
117
129
|
end
|
|
118
130
|
|
|
119
131
|
def create_person(contrib)
|
|
120
132
|
name = contrib.at("./name")
|
|
121
|
-
|
|
133
|
+
@errors[:article_contributor_person] &&= name.nil? || name.text.empty?
|
|
134
|
+
return if name.nil? || name.text.empty?
|
|
122
135
|
|
|
123
136
|
Relaton::Bib::Person.new name: fullname(name), affiliation: affiliation(contrib)
|
|
124
137
|
end
|
|
125
138
|
|
|
126
139
|
def create_organization(contrib)
|
|
127
140
|
org = contrib.at("./collab")
|
|
128
|
-
|
|
141
|
+
@errors[:article_contributor_organization] &&= org.nil? || org.text.empty?
|
|
142
|
+
return if org.nil? || org.text.empty?
|
|
129
143
|
|
|
130
144
|
name = Relaton::Bib::TypedLocalizedString.new(content: org.text)
|
|
131
145
|
Relaton::Bib::Organization.new name: [name]
|
|
@@ -139,10 +153,12 @@ module Relaton::Bipm
|
|
|
139
153
|
# @return [Array<Relaton::Bib::Affiliation>] array of affiliations
|
|
140
154
|
#
|
|
141
155
|
def affiliation(contrib)
|
|
142
|
-
contrib.xpath("./xref[@ref-type='aff']").map do |x|
|
|
156
|
+
aff = contrib.xpath("./xref[@ref-type='aff']").map do |x|
|
|
143
157
|
a = @meta.at("./contrib-group/aff[@id='#{x[:rid]}']") # /label/following-sibling::node()")
|
|
144
158
|
parse_affiliation a
|
|
145
159
|
end.compact
|
|
160
|
+
@errors[:article_affiliation] &&= aff.empty?
|
|
161
|
+
aff
|
|
146
162
|
end
|
|
147
163
|
|
|
148
164
|
def parse_affiliation(aff)
|
|
@@ -170,6 +186,7 @@ module Relaton::Bipm
|
|
|
170
186
|
|
|
171
187
|
def parse_division(aff)
|
|
172
188
|
div = aff.xpath("text()[following-sibling::institution]").text.gsub(/^\W*|\W*$/, "")
|
|
189
|
+
@errors[:article_affiliation_division] &&= div.empty?
|
|
173
190
|
return [] if div.empty?
|
|
174
191
|
|
|
175
192
|
name = Relaton::Bib::TypedLocalizedString.new(content: div, language: "en", script: "Latn")
|
|
@@ -183,6 +200,7 @@ module Relaton::Bipm
|
|
|
183
200
|
country = aff.at('country')
|
|
184
201
|
address << country.text if country && !country.text.empty?
|
|
185
202
|
address = address.join(", ")
|
|
203
|
+
@errors[:article_affiliation_address] &&= address.empty?
|
|
186
204
|
return [] if address.empty?
|
|
187
205
|
|
|
188
206
|
[Relaton::Bib::Address.new(formatted_address: address)]
|
|
@@ -197,6 +215,9 @@ module Relaton::Bipm
|
|
|
197
215
|
#
|
|
198
216
|
def fullname(name)
|
|
199
217
|
cname = [name.at("./given-names"), name.at("./surname")].compact.map(&:text).join(" ")
|
|
218
|
+
@errors[:article_fullname] &&= cname.empty?
|
|
219
|
+
return if cname.empty?
|
|
220
|
+
|
|
200
221
|
completename = Relaton::Bib::LocalizedString.new content: cname, language: "en", script: "Latn"
|
|
201
222
|
Relaton::Bib::FullName.new completename: completename
|
|
202
223
|
end
|
|
@@ -230,6 +251,9 @@ module Relaton::Bipm
|
|
|
230
251
|
#
|
|
231
252
|
def parse_date
|
|
232
253
|
at = dates.min
|
|
254
|
+
@errors[:article_date] &&= at.nil?
|
|
255
|
+
return [] unless at
|
|
256
|
+
|
|
233
257
|
[Relaton::Bib::Date.new(type: "published", at: at)]
|
|
234
258
|
end
|
|
235
259
|
|
|
@@ -262,7 +286,7 @@ module Relaton::Bipm
|
|
|
262
286
|
# @return [Array<Relaton::Bib::Copyright>] array of copyright associations
|
|
263
287
|
#
|
|
264
288
|
def parse_copyright
|
|
265
|
-
@meta.xpath("./permissions").each_with_object([]) do |l, m|
|
|
289
|
+
result = @meta.xpath("./permissions").each_with_object([]) do |l, m|
|
|
266
290
|
from = l.at("./copyright-year")
|
|
267
291
|
next unless from
|
|
268
292
|
|
|
@@ -274,6 +298,8 @@ module Relaton::Bipm
|
|
|
274
298
|
end
|
|
275
299
|
m << Relaton::Bib::Copyright.new(owner: owner, from: from.text)
|
|
276
300
|
end
|
|
301
|
+
@errors[:article_copyright] &&= result.empty?
|
|
302
|
+
result
|
|
277
303
|
end
|
|
278
304
|
|
|
279
305
|
#
|
|
@@ -282,11 +308,13 @@ module Relaton::Bipm
|
|
|
282
308
|
# @return [Array<Relaton::Bib::LocalizedMarkedUpString>] array of abstracts
|
|
283
309
|
#
|
|
284
310
|
def parse_abstract
|
|
285
|
-
@meta.xpath("./abstract").map do |a|
|
|
286
|
-
Relaton::Bib::
|
|
311
|
+
result = @meta.xpath("./abstract").map do |a|
|
|
312
|
+
Relaton::Bib::Abstract.new(
|
|
287
313
|
content: a.inner_html, language: a[:"xml:lang"], script: "Latn",
|
|
288
314
|
)
|
|
289
315
|
end
|
|
316
|
+
@errors[:article_abstract] &&= result.empty?
|
|
317
|
+
result
|
|
290
318
|
end
|
|
291
319
|
|
|
292
320
|
#
|
|
@@ -298,6 +326,7 @@ module Relaton::Bipm
|
|
|
298
326
|
rels = dates do |d, t|
|
|
299
327
|
Relaton::Bib::Relation.new(type: "hasManifestation", bibitem: bibitem(d, t))
|
|
300
328
|
end
|
|
329
|
+
@errors[:article_relation] &&= refs.empty?
|
|
301
330
|
rels + parse_references
|
|
302
331
|
end
|
|
303
332
|
|
|
@@ -307,12 +336,14 @@ module Relaton::Bipm
|
|
|
307
336
|
# @return [Array<Relaton::Bib::Relation>] array of "cites" relations
|
|
308
337
|
#
|
|
309
338
|
def parse_references
|
|
310
|
-
@doc.xpath("./back/ref-list/ref").filter_map do |ref|
|
|
339
|
+
refs = @doc.xpath("./back/ref-list/ref").filter_map do |ref|
|
|
311
340
|
citation = ref.at("./element-citation")
|
|
312
341
|
next unless citation
|
|
313
342
|
|
|
314
343
|
Relaton::Bib::Relation.new(type: "cites", bibitem: citation_bibitem(citation))
|
|
315
344
|
end
|
|
345
|
+
@errors[:article_references] &&= refs.empty?
|
|
346
|
+
refs
|
|
316
347
|
end
|
|
317
348
|
|
|
318
349
|
#
|
|
@@ -324,18 +355,27 @@ module Relaton::Bipm
|
|
|
324
355
|
#
|
|
325
356
|
def citation_bibitem(citation)
|
|
326
357
|
attrs = {}
|
|
327
|
-
doi = citation.at("./pub-id[@pub-id-type='doi']")
|
|
328
|
-
if doi
|
|
329
|
-
|
|
330
|
-
attrs[:
|
|
358
|
+
doi = citation.at("./pub-id[@pub-id-type='doi']")&.text
|
|
359
|
+
if doi && !doi.empty?
|
|
360
|
+
@errors[:article_citation_doi] &&= false
|
|
361
|
+
attrs[:docidentifier] = [Relaton::Bib::Docidentifier.new(content: doi, type: "doi")]
|
|
362
|
+
attrs[:source] = [Relaton::Bib::Uri.new(content: "https://doi.org/#{doi}", type: "doi")]
|
|
363
|
+
else
|
|
364
|
+
@errors[:article_citation_doi] &&= true
|
|
331
365
|
end
|
|
332
|
-
source = citation.at("./source")
|
|
333
|
-
if source
|
|
334
|
-
|
|
366
|
+
source = citation.at("./source")&.text
|
|
367
|
+
if source && !source.empty?
|
|
368
|
+
@errors[:article_citation_title] &&= false
|
|
369
|
+
attrs[:title] = [Relaton::Bib::Title.new(content: source)]
|
|
370
|
+
else
|
|
371
|
+
@errors[:article_citation_title] &&= true
|
|
335
372
|
end
|
|
336
|
-
year = citation.at("./year")
|
|
337
|
-
if year
|
|
338
|
-
|
|
373
|
+
year = citation.at("./year")&.text
|
|
374
|
+
if year && !year.empty?
|
|
375
|
+
@errors[:article_citation_date] &&= false
|
|
376
|
+
attrs[:date] = [Relaton::Bib::Date.new(type: "published", at: year)]
|
|
377
|
+
else
|
|
378
|
+
@errors[:article_citation_date] &&= true
|
|
339
379
|
end
|
|
340
380
|
ItemData.new(**attrs)
|
|
341
381
|
end
|
|
@@ -380,31 +420,27 @@ module Relaton::Bipm
|
|
|
380
420
|
end
|
|
381
421
|
Relaton::Bib::Locality.new type: type, reference_from: e.text, reference_to: to
|
|
382
422
|
end
|
|
383
|
-
[
|
|
384
|
-
|
|
385
|
-
# Relaton::Bib::Locality.new t, volume_issue_page[i]
|
|
386
|
-
# end
|
|
387
|
-
end
|
|
423
|
+
@errors[:article_extent] &&= locs.empty?
|
|
424
|
+
return [] if locs.empty?
|
|
388
425
|
|
|
389
|
-
|
|
390
|
-
"article"
|
|
426
|
+
[Relaton::Bib::Extent.new(locality: locs)]
|
|
391
427
|
end
|
|
392
428
|
|
|
393
|
-
def
|
|
394
|
-
Doctype.new content: "article"
|
|
395
|
-
end
|
|
429
|
+
def parse_type = "article"
|
|
396
430
|
|
|
397
431
|
def parse_source
|
|
398
|
-
@meta.xpath("./article-id[@pub-id-type='doi']").each_with_object([]) do |l, a|
|
|
432
|
+
result = @meta.xpath("./article-id[@pub-id-type='doi']").each_with_object([]) do |l, a|
|
|
399
433
|
url = "https://doi.org/#{l.text}"
|
|
400
434
|
a << Relaton::Bib::Uri.new(content: url, type: "src")
|
|
401
435
|
a << Relaton::Bib::Uri.new(content: url, type: "doi")
|
|
402
436
|
end
|
|
437
|
+
@errors[:article_source] &&= result.empty?
|
|
438
|
+
result
|
|
403
439
|
end
|
|
404
440
|
|
|
405
|
-
def parse_ext
|
|
406
|
-
|
|
407
|
-
|
|
441
|
+
def parse_ext = Ext.new(doctype: parse_doctype)
|
|
442
|
+
|
|
443
|
+
def parse_doctype = Doctype.new(content: "article")
|
|
408
444
|
end
|
|
409
445
|
end
|
|
410
446
|
end
|
|
@@ -34,7 +34,7 @@ module Relaton::Bipm
|
|
|
34
34
|
def fetch_articles # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
35
35
|
# aff = Affiliations.parse DIR
|
|
36
36
|
Dir["#{DIR}/**/*.xml"].sort_by { |p| archive_date(p) }.each do |path|
|
|
37
|
-
item = ArticleParser.parse path
|
|
37
|
+
item = ArticleParser.parse path, @data_fetcher.errors
|
|
38
38
|
file = "#{item.docidentifier.first.content.downcase.tr(' ', '-')}.#{@data_fetcher.ext}"
|
|
39
39
|
out_path = File.join(@data_fetcher.output, file)
|
|
40
40
|
key = Relaton::Bipm::Id.new.parse(item.docidentifier.first.content).to_hash
|
|
@@ -74,7 +74,7 @@ module Relaton::Bipm
|
|
|
74
74
|
def fetch_metrologia(*args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
75
75
|
id = identifier(*args)
|
|
76
76
|
item = ItemData.new(
|
|
77
|
-
type: "article", formattedref: id, docidentifier: docidentifier(id),
|
|
77
|
+
type: "article", formattedref: Relaton::Bib::Formattedref.new(content: id), docidentifier: docidentifier(id),
|
|
78
78
|
language: ["en"], script: ["Latn"], relation: relation(*args),
|
|
79
79
|
source: typed_uri(*args)
|
|
80
80
|
)
|
|
@@ -143,7 +143,7 @@ module Relaton::Bipm
|
|
|
143
143
|
# @return [Relaton::Bipm::Item] bibitem
|
|
144
144
|
#
|
|
145
145
|
def rel_bibitem(id)
|
|
146
|
-
Relaton::Bib::ItemData.new(formattedref: id, docidentifier: docidentifier(id))
|
|
146
|
+
Relaton::Bib::ItemData.new(formattedref: Relaton::Bib::Formattedref.new(content: id), docidentifier: docidentifier(id))
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
def typed_uri(*args)
|
|
@@ -35,8 +35,11 @@ module Relaton::Bipm
|
|
|
35
35
|
xml = File.read(f, encoding: "UTF-8")
|
|
36
36
|
xml = xml.force_encoding("UTF-8") if xml.encoding != Encoding::UTF_8
|
|
37
37
|
item1 = Bibdata.from_xml(xml)
|
|
38
|
+
@data_fetcher.errors[:si_brochure_title] &&= item1.title.empty?
|
|
39
|
+
@data_fetcher.errors[:si_brochure_docidentifier] &&= item1.docidentifier.empty?
|
|
38
40
|
unless has_committee_contributor?(item1)
|
|
39
|
-
extract_editorialgroup(xml)
|
|
41
|
+
contribs = extract_editorialgroup(xml)
|
|
42
|
+
contribs.each { |c| item1.contributor << c }
|
|
40
43
|
end
|
|
41
44
|
fix_si_brochure_id item1
|
|
42
45
|
basename = File.join @data_fetcher.output, File.basename(f).sub(/(?:-(?:en|fr))?\.rxl$/, "")
|
data/lib/relaton/bipm/version.rb
CHANGED
data/relaton_bipm.gemspec
CHANGED
|
@@ -35,8 +35,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
|
35
35
|
spec.add_dependency "faraday", "~> 2.7.0"
|
|
36
36
|
spec.add_dependency "mechanize", "~> 2.10"
|
|
37
37
|
spec.add_dependency "parslet", "~> 2.0.0"
|
|
38
|
-
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.
|
|
38
|
+
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.7"
|
|
39
39
|
spec.add_dependency "relaton-index", "~> 0.2.2"
|
|
40
|
-
spec.add_dependency "relaton-core", "~> 0.0.
|
|
40
|
+
spec.add_dependency "relaton-core", "~> 0.0.12"
|
|
41
41
|
spec.add_dependency "rubyzip", "~> 2.3.0"
|
|
42
42
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-bipm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.pre.alpha.
|
|
4
|
+
version: 2.0.0.pre.alpha.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 2.0.0.pre.alpha.
|
|
60
|
+
version: 2.0.0.pre.alpha.7
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 2.0.0.pre.alpha.
|
|
67
|
+
version: 2.0.0.pre.alpha.7
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: relaton-index
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.0.
|
|
88
|
+
version: 0.0.12
|
|
89
89
|
type: :runtime
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.0.
|
|
95
|
+
version: 0.0.12
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: rubyzip
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|