relaton-bipm 1.14.4 → 1.14.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -0
- data/.github/workflows/release.yml +3 -2
- data/README.adoc +29 -29
- data/lib/relaton_bipm/bipm_bibliographic_item.rb +3 -3
- data/lib/relaton_bipm/bipm_si_brochure_parser.rb +1 -1
- data/lib/relaton_bipm/data_outcomes_parser.rb +89 -63
- data/lib/relaton_bipm/id_parser.rb +35 -20
- data/lib/relaton_bipm/processor.rb +1 -1
- data/lib/relaton_bipm/rawdata_bipm_metrologia/article_parser.rb +4 -1
- data/lib/relaton_bipm/rawdata_bipm_metrologia/fetcher.rb +6 -5
- data/lib/relaton_bipm/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f72520efca5d2a8525b052758d95563c5ca6d57d22b85b146e4ff77e02ee2594
|
4
|
+
data.tar.gz: 57803ee16e558e356c0529599ffa8ba881ef85dba99d8b28a1f936a577f711f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e44f8da41d1c91944196344e85921988c14e5771f976af31471b14bfa216084717942b43b5e3ddc0053891c23e5bb4b7c9d4d9f07ad1abd9b825028fb2b49cd1
|
7
|
+
data.tar.gz: 1b6de32f1454222514c9867d86a1bf970d0b42fce78b8f927459e8907a9715ebaf45c17366acfbe2112599fd3c07fc5a93d9729fd43e7565e67dee6acbeb52c3
|
data/.github/workflows/rake.yml
CHANGED
data/README.adoc
CHANGED
@@ -91,13 +91,13 @@ Short:
|
|
91
91
|
{group name} {type-abbrev} {number} ({year}, {lang})
|
92
92
|
----
|
93
93
|
|
94
|
-
`group name` - a name of the group, required. A full list of group names is available https://github.com/metanorma/bipm-editor-guides/blob/main/sources/bipm-outcomes-en.adoc#appendix-a-bipm-groups-and-codes[here].
|
95
|
-
`type` - a type of document, required. A list of types is: Resolution (Résolution), Recommendation (Recommandation), Decision (Décision), Meeting (Réunion), Declaration (Déclaration).
|
96
|
-
`type-abbrev` - an abbreviation of the type, required. A list of abbreviations: RES (Resolution), REC (Recommendation), DECN (Decision).
|
97
|
-
`number` - a number of the document, optional. Can be with part, e.g. `1-2`.
|
98
|
-
`zero_leading_number` - a number of the document with a leading zero, required. Can be used when a document has a 1 or 2 digits number. It's `00` for documents without a number.
|
99
|
-
`year` - a year of the document, optional.
|
100
|
-
`lang` - a language of the document, optional. Can be `EN` or `FR`.
|
94
|
+
- `group name` - a name of the group, required. A full list of group names is available https://github.com/metanorma/bipm-editor-guides/blob/main/sources/bipm-outcomes-en.adoc#appendix-a-bipm-groups-and-codes[here].
|
95
|
+
- `type` - a type of document, required. A list of types is: Resolution (Résolution), Recommendation (Recommandation), Decision (Décision), Meeting (Réunion), Declaration (Déclaration).
|
96
|
+
- `type-abbrev` - an abbreviation of the type, required. A list of abbreviations: RES (Resolution), REC (Recommendation), DECN (Decision).
|
97
|
+
- `number` - a number of the document, optional. Can be with part, e.g. `1-2`.
|
98
|
+
- `zero_leading_number` - a number of the document with a leading zero, required. Can be used when a document has a 1 or 2 digits number. It's `00` for documents without a number.
|
99
|
+
- `year` - a year of the document, optional.
|
100
|
+
- `lang` - a language of the document, optional. Can be `EN` or `FR`.
|
101
101
|
|
102
102
|
===== Special case pattern
|
103
103
|
|
@@ -209,54 +209,54 @@ bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 001"
|
|
209
209
|
...
|
210
210
|
|
211
211
|
# get CGPM meetings
|
212
|
-
RelatonBipm::BipmBibliography.get "CGPM
|
213
|
-
[relaton-bipm] ("CGPM
|
214
|
-
[relaton-bipm] ("CGPM
|
212
|
+
RelatonBipm::BipmBibliography.get "CGPM 1st Meeting (1889)"
|
213
|
+
[relaton-bipm] ("CGPM 1st Meeting (1889)") fetching...
|
214
|
+
[relaton-bipm] ("CGPM 1st Meeting (1889)") found CGPM 1th meeting (1889)
|
215
215
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f7fd02aba28
|
216
216
|
...
|
217
217
|
|
218
218
|
# get CGPM resolutions
|
219
|
-
|
220
|
-
[relaton-bipm] ("CGPM
|
221
|
-
[relaton-bipm] ("CGPM
|
219
|
+
RelatonBipm::BipmBibliography.get "CGPM RES (1889, E)"
|
220
|
+
[relaton-bipm] ("CGPM RES (1889, E)") fetching...
|
221
|
+
[relaton-bipm] ("CGPM RES (1889, E)") found CGPM RES (1889)
|
222
222
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f80421f93d8
|
223
223
|
...
|
224
224
|
|
225
|
-
RelatonBipm::BipmBibliography.get "CGPM
|
226
|
-
[relaton-bipm] ("CGPM
|
227
|
-
[relaton-bipm] ("CGPM
|
225
|
+
RelatonBipm::BipmBibliography.get "CGPM Resolution (1889)"
|
226
|
+
[relaton-bipm] ("CGPM Resolution (1889)") fetching...
|
227
|
+
[relaton-bipm] ("CGPM Resolution (1889)") found CGPM RES (1889)
|
228
228
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f60c18
|
229
229
|
...
|
230
230
|
|
231
|
-
RelatonBipm::BipmBibliography.get "CGPM
|
232
|
-
[relaton-bipm] ("CGPM
|
233
|
-
[relaton-bipm] ("CGPM
|
231
|
+
RelatonBipm::BipmBibliography.get "CGPM Résolution (1889)"
|
232
|
+
[relaton-bipm] ("CGPM Résolution (1889)") fetching...
|
233
|
+
[relaton-bipm] ("CGPM Résolution (1889)") found CGPM RES (1889)
|
234
234
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f492e8
|
235
235
|
...
|
236
236
|
|
237
237
|
# get CIPM decision by year and decision number
|
238
238
|
RelatonBipm::BipmBibliography.get "BIPM Decision CIPM/101-1 (2012)"
|
239
239
|
[relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") fetching...
|
240
|
-
[relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") found
|
240
|
+
[relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") found CIPM DECN 101-1 (2012)
|
241
241
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f2bd88
|
242
242
|
...
|
243
243
|
|
244
|
-
RelatonBipm::BipmBibliography.get "BIPM DECN CIPM/101-1 (2012,
|
245
|
-
[relaton-bipm] ("BIPM DECN CIPM/101-1 (2012,
|
246
|
-
[relaton-bipm] ("BIPM DECN CIPM/101-1 (2012,
|
244
|
+
RelatonBipm::BipmBibliography.get "BIPM DECN CIPM/101-1 (2012, E)"
|
245
|
+
[relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, E)") fetching...
|
246
|
+
[relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, E)") found CIPM DECN 101-1 (2012)
|
247
247
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f39438
|
248
248
|
...
|
249
249
|
|
250
250
|
# get CIPM recommendation
|
251
|
-
RelatonBipm::BipmBibliography.get "CIPM
|
252
|
-
[relaton-bipm] ("CIPM
|
253
|
-
[relaton-bipm] ("CIPM
|
251
|
+
RelatonBipm::BipmBibliography.get "CIPM Recommendation 1 (2005)"
|
252
|
+
[relaton-bipm] ("CIPM Recommendation 1 (2005)") fetching...
|
253
|
+
[relaton-bipm] ("CIPM Recommendation 1 (2005)") found CIPM REC 1 (2005)
|
254
254
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f31da0
|
255
255
|
...
|
256
256
|
|
257
|
-
RelatonBipm::BipmBibliography.get "CIPM
|
258
|
-
[relaton-bipm] ("CIPM
|
259
|
-
[relaton-bipm] ("CIPM
|
257
|
+
RelatonBipm::BipmBibliography.get "CIPM REC 1 (2005, FR)"
|
258
|
+
[relaton-bipm] ("CIPM REC 1 (2005, FR)") fetching...
|
259
|
+
[relaton-bipm] ("CIPM REC 1 (2005, FR)") found CIPM REC 1 (2005)
|
260
260
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f80422100d8
|
261
261
|
...
|
262
262
|
----
|
@@ -2,9 +2,9 @@ module RelatonBipm
|
|
2
2
|
class BipmBibliographicItem < RelatonBib::BibliographicItem
|
3
3
|
include RelatonBib
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
DOCTYPES = %w[brochure mise-en-pratique rapport monographie guide
|
6
|
+
meeting-report technical-report working-party-note strategy
|
7
|
+
cipm-mra resolutions].freeze
|
8
8
|
|
9
9
|
STATUSES = %w[draft-proposal draft-development in-force retired].freeze
|
10
10
|
|
@@ -38,7 +38,7 @@ module RelatonBipm
|
|
38
38
|
key = hash1["docnumber"] || basename
|
39
39
|
@data_fetcher.index[[key]] = outfile
|
40
40
|
@data_fetcher.index_new.add_or_update [key], outfile
|
41
|
-
@data_fetcher.index2.add_or_update Id.new(key).
|
41
|
+
@data_fetcher.index2.add_or_update Id.new(key).to_hash, outfile
|
42
42
|
hash = if File.exist? outfile
|
43
43
|
warn_duplicate = false
|
44
44
|
hash2 = YAML.load_file outfile
|
@@ -1,18 +1,20 @@
|
|
1
1
|
module RelatonBipm
|
2
2
|
class DataOutcomesParser
|
3
|
-
|
3
|
+
SHORTTYPE = {
|
4
4
|
"Resolution" => "RES",
|
5
5
|
"Recommendation" => "REC",
|
6
6
|
"Decision" => "DECN",
|
7
7
|
"Statement" => "DECL",
|
8
|
+
"Declaration" => "DECL",
|
9
|
+
"Action" => "ACT",
|
8
10
|
}.freeze
|
9
11
|
|
10
12
|
TRANSLATIONS = {
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
13
|
+
"Declaration" => "Déclaration",
|
14
|
+
"Meeting" => "Réunion",
|
15
|
+
"Recommendation" => "Recommandation",
|
16
|
+
"Resolution" => "Résolution",
|
17
|
+
"Decision" => "Décision",
|
16
18
|
}.freeze
|
17
19
|
|
18
20
|
#
|
@@ -228,19 +230,10 @@ module RelatonBipm
|
|
228
230
|
# @param [String] path path to YAML file
|
229
231
|
#
|
230
232
|
def add_to_index(item, path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
231
|
-
key =
|
232
|
-
TYPEABBREV.each do |k, v|
|
233
|
-
if item.docnumber.include? k
|
234
|
-
key << item.docnumber.sub(k, v)
|
235
|
-
key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, EN\\2")
|
236
|
-
key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, FR\\2")
|
237
|
-
break
|
238
|
-
end
|
239
|
-
end
|
240
|
-
key << item.docidentifier.detect { |i| i.language == "fr" }.id
|
233
|
+
key = item.docidentifier.select { |i| i.type == "BIPM" }.map &:id
|
241
234
|
@data_fetcher.index[key] = path
|
242
235
|
@data_fetcher.index_new.add_or_update key, path
|
243
|
-
key2 = Id.new(item.docnumber).
|
236
|
+
key2 = Id.new(item.docnumber).to_hash
|
244
237
|
@data_fetcher.index2.add_or_update key2, path
|
245
238
|
end
|
246
239
|
|
@@ -252,20 +245,40 @@ module RelatonBipm
|
|
252
245
|
#
|
253
246
|
# @return [Array<Hash>] contributors
|
254
247
|
#
|
255
|
-
def contributors(date, body)
|
248
|
+
def contributors(date, body)
|
249
|
+
contribs = [{ entity: bipm_org, role: [{ type: "publisher" }] }]
|
250
|
+
author = author_org date, body
|
251
|
+
contribs << { entity: author, role: [{ type: "author" }] } if author
|
252
|
+
contribs
|
253
|
+
end
|
254
|
+
|
255
|
+
#
|
256
|
+
# Create author organization
|
257
|
+
#
|
258
|
+
# @param [String] date date of publication
|
259
|
+
# @param [String] body organization abbreviation (CCTF, CIPM, CGPM)
|
260
|
+
#
|
261
|
+
# @return [Hash, nil] author organization
|
262
|
+
#
|
263
|
+
def author_org(date, body)
|
256
264
|
case body
|
257
265
|
when "CCTF" then cctf_org date
|
258
266
|
when "CGPM" then cgpm_org
|
259
267
|
when "CIPM" then cipm_org
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
#
|
272
|
+
# Create BIPM organization
|
273
|
+
#
|
274
|
+
# @return [Hash] BIPM organization
|
275
|
+
#
|
276
|
+
def bipm_org
|
277
|
+
nms = [
|
278
|
+
{ content: "International Bureau of Weights and Measures", language: "en" },
|
279
|
+
{ content: "Bureau international des poids et mesures", language: "fr" },
|
280
|
+
]
|
281
|
+
organization(nms, "BIPM").tap { |org| org[:url] = "www.bipm.org" }
|
269
282
|
end
|
270
283
|
|
271
284
|
#
|
@@ -273,7 +286,7 @@ module RelatonBipm
|
|
273
286
|
#
|
274
287
|
# @param [String] date date of meeting
|
275
288
|
#
|
276
|
-
# @return [
|
289
|
+
# @return [Hash] CCTF organization
|
277
290
|
#
|
278
291
|
def cctf_org(date) # rubocop:disable Metrics/MethodLength
|
279
292
|
if Date.parse(date).year < 1999
|
@@ -297,17 +310,17 @@ module RelatonBipm
|
|
297
310
|
# @param [Array<Hash>] names organization names in different languages
|
298
311
|
# @param [String] abbr abbreviation
|
299
312
|
#
|
300
|
-
# @return [
|
313
|
+
# @return [Hash] organization
|
301
314
|
#
|
302
315
|
def organization(names, abbr)
|
303
316
|
names.each { |ctrb| ctrb[:script] = "Latn" }
|
304
|
-
|
317
|
+
{ name: names, abbreviation: { content: abbr, language: ["en", "fr"], script: "Latn" } }
|
305
318
|
end
|
306
319
|
|
307
320
|
#
|
308
321
|
# Create CGPM organization
|
309
322
|
#
|
310
|
-
# @return [
|
323
|
+
# @return [Hash] CGPM organization
|
311
324
|
#
|
312
325
|
def cgpm_org
|
313
326
|
nms = [
|
@@ -349,12 +362,12 @@ module RelatonBipm
|
|
349
362
|
# @param [String] session number of meeting
|
350
363
|
#
|
351
364
|
def add_part(hash, part)
|
352
|
-
regex = /(\p{L}+\s(
|
365
|
+
regex = /(\p{L}+\s(?:\w+\/)?\d+)(?![\d-])/
|
353
366
|
hash[:id] += "-#{part}"
|
354
367
|
hash[:docnumber].sub!(regex) { |m| "#{m}-#{part}" }
|
355
368
|
hash[:docid].select { |id| id.type == "BIPM" }.each do |did|
|
356
|
-
|
357
|
-
did.instance_variable_set(:@id, id)
|
369
|
+
did.instance_variable_get(:@id).sub!(regex) { "#{$1}-#{part}" }
|
370
|
+
# did.instance_variable_set(:@id, id)
|
358
371
|
end
|
359
372
|
hash[:structuredidentifier].instance_variable_set :@part, part
|
360
373
|
end
|
@@ -374,12 +387,12 @@ module RelatonBipm
|
|
374
387
|
# @return [Hash] Hash of BIPM meeting/resolution
|
375
388
|
#
|
376
389
|
def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
|
377
|
-
docnum =
|
390
|
+
docnum = create_meeting_docnum args[:body], args[:type], args[:num], args[:en]["date"]
|
378
391
|
hash = { title: [], type: "proceedings", doctype: args[:type],
|
379
392
|
place: [RelatonBib::Place.new(city: "Paris")] }
|
380
393
|
hash[:title] = create_titles args.slice(:en, :fr)
|
381
394
|
hash[:date] = [{ type: "published", on: args[:en]["date"] }]
|
382
|
-
hash[:docid] =
|
395
|
+
hash[:docid] = create_meeting_docids docnum
|
383
396
|
hash[:docnumber] = docnum # .sub(" --", "").sub(/\s\(\d{4}\)/, "")
|
384
397
|
hash[:id] = create_id(args[:body], args[:type], args[:num], args[:en]["date"])
|
385
398
|
hash[:link] = create_links(**args)
|
@@ -426,16 +439,21 @@ module RelatonBipm
|
|
426
439
|
#
|
427
440
|
def create_docnum(body, type, num, date)
|
428
441
|
year = Date.parse(date).year
|
429
|
-
if special_id_case? body, type, year
|
430
|
-
|
431
|
-
|
432
|
-
else
|
433
|
-
|
434
|
-
|
435
|
-
end
|
442
|
+
# if special_id_case? body, type, year
|
443
|
+
# id = "#{type.capitalize} #{body}"
|
444
|
+
# id += "/#{num}" if num.to_i.positive?
|
445
|
+
# else
|
446
|
+
id = "#{body} #{SHORTTYPE[type.capitalize]}"
|
447
|
+
id += " #{num}" if num.to_i.positive?
|
448
|
+
# end
|
436
449
|
"#{id} (#{year})"
|
437
450
|
end
|
438
451
|
|
452
|
+
def create_meeting_docnum(body, type, num, date)
|
453
|
+
year = Date.parse(date).year
|
454
|
+
"#{body} #{num}th #{type} (#{year})"
|
455
|
+
end
|
456
|
+
|
439
457
|
#
|
440
458
|
# Create ID
|
441
459
|
#
|
@@ -448,13 +466,11 @@ module RelatonBipm
|
|
448
466
|
#
|
449
467
|
def create_id(body, type, num, date)
|
450
468
|
year = Date.parse(date).year
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
id += "-#{num}" if num.to_i.positive?
|
457
|
-
id
|
469
|
+
# if special_id_case?(body, type, year)
|
470
|
+
# [type.capitalize, body, year]
|
471
|
+
# else
|
472
|
+
[body, SHORTTYPE[type.capitalize], year, num].compact.join("-")
|
473
|
+
# end
|
458
474
|
end
|
459
475
|
|
460
476
|
#
|
@@ -466,10 +482,10 @@ module RelatonBipm
|
|
466
482
|
#
|
467
483
|
# @return [Boolean] is special case
|
468
484
|
#
|
469
|
-
def special_id_case?(body, type, year)
|
470
|
-
|
471
|
-
|
472
|
-
end
|
485
|
+
# def special_id_case?(body, type, year)
|
486
|
+
# (body == "CIPM" && type == "Decision" && year.to_i > 2011) ||
|
487
|
+
# (body == "JCRB" && %w[recomendation resolution descision].include?(type))
|
488
|
+
# end
|
473
489
|
|
474
490
|
#
|
475
491
|
# Create documetn IDs
|
@@ -478,12 +494,22 @@ module RelatonBipm
|
|
478
494
|
#
|
479
495
|
# @return [Array<RelatonBib::DocumentIdentifier>] document IDs
|
480
496
|
#
|
481
|
-
def create_docids(
|
482
|
-
|
497
|
+
def create_docids(id)
|
498
|
+
en_id = id.sub(/(\s\(\d{4})(\))$/, '\1, E\2')
|
499
|
+
fr_id = id.sub(/(\s\(\d{4})(\))$/, '\1, F\2')
|
483
500
|
[
|
484
501
|
make_docid(id: id, type: "BIPM", primary: true),
|
485
|
-
make_docid(id:
|
486
|
-
|
502
|
+
make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
|
503
|
+
make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
|
504
|
+
# create_docid_fr(en_id),
|
505
|
+
]
|
506
|
+
end
|
507
|
+
|
508
|
+
def create_meeting_docids(en_id)
|
509
|
+
fr_id = en_id.sub(/(\d+)th/, '\1e').sub("meeting", "réunion")
|
510
|
+
[
|
511
|
+
make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
|
512
|
+
make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
|
487
513
|
]
|
488
514
|
end
|
489
515
|
|
@@ -494,11 +520,11 @@ module RelatonBipm
|
|
494
520
|
#
|
495
521
|
# @return [RelatonBib::DocumentIdentifier] french document ID
|
496
522
|
#
|
497
|
-
def create_docid_fr(en_id)
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
end
|
523
|
+
# def create_docid_fr(en_id)
|
524
|
+
# tr = TRANSLATIONS.detect { |_, v| en_id.include? v }
|
525
|
+
# id = tr ? en_id.sub(tr[1], tr[0]) : en_id
|
526
|
+
# make_docid(id: id, type: "BIPM", primary: true, language: "fr", script: "Latn")
|
527
|
+
# end
|
502
528
|
|
503
529
|
#
|
504
530
|
# Create doucment ID
|
@@ -11,11 +11,13 @@ module RelatonBipm
|
|
11
11
|
rule(:delimeter) { str("--") >> space }
|
12
12
|
rule(:delimeter?) { delimeter.maybe }
|
13
13
|
|
14
|
-
rule(:lang) { comma >> match["A-Z"].repeat(
|
14
|
+
rule(:lang) { comma >> space? >> match["A-Z"].repeat(1, 2).as(:lang) }
|
15
15
|
rule(:lang?) { lang.maybe }
|
16
16
|
|
17
|
-
rule(:
|
17
|
+
rule(:numdash) { match["0-9-"].repeat(1).as(:number) }
|
18
|
+
rule(:number) { numdash >> space? }
|
18
19
|
rule(:number?) { number.maybe }
|
20
|
+
rule(:num_suff) { numdash >> match["a-z"].repeat(1, 2) >> space }
|
19
21
|
|
20
22
|
rule(:year) { match["0-9"].repeat(4, 4).as(:year) }
|
21
23
|
rule(:year_paren) { lparen >> year >> lang? >> rparen }
|
@@ -37,7 +39,8 @@ module RelatonBipm
|
|
37
39
|
|
38
40
|
rule(:type_group) { type >> group >> slash >> num_and_year }
|
39
41
|
rule(:group_type) { group >> space >> delimeter? >> type >> num_and_year }
|
40
|
-
rule(:
|
42
|
+
rule(:group_num) { group >> space >> num_suff >> type >> year_paren }
|
43
|
+
rule(:outcome) { group_num | group_type | type_group }
|
41
44
|
|
42
45
|
rule(:append) { comma >> str("Appendix") >> space >> number }
|
43
46
|
rule(:brochure) { str("SI").as(:group) >> space >> str("Brochure").as(:type) >> append.maybe }
|
@@ -58,6 +61,7 @@ module RelatonBipm
|
|
58
61
|
"Décision" => "DECN",
|
59
62
|
"Declaration" => "Déclaration",
|
60
63
|
"Réunion" => "Meeting",
|
64
|
+
"Action" => "ACT",
|
61
65
|
}.freeze
|
62
66
|
|
63
67
|
# @return [Hash] the parsed id components
|
@@ -84,8 +88,8 @@ module RelatonBipm
|
|
84
88
|
# @return [Boolean] true if the two Id objects are equal
|
85
89
|
#
|
86
90
|
def ==(other)
|
87
|
-
other_hash = other.is_a?(Id) ? other.
|
88
|
-
hash =
|
91
|
+
other_hash = other.is_a?(Id) ? other.to_hash : normalize_hash(other)
|
92
|
+
hash = to_hash
|
89
93
|
hash.delete(:year) unless other_hash[:year]
|
90
94
|
other_hash.delete(:year) unless hash[:year]
|
91
95
|
hash.delete(:lang) unless other_hash[:lang]
|
@@ -99,16 +103,26 @@ module RelatonBipm
|
|
99
103
|
#
|
100
104
|
# @return [Hash] the normalized ID parts
|
101
105
|
#
|
102
|
-
def
|
103
|
-
@
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
def to_hash
|
107
|
+
@to_hash ||= normalize_hash id
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Normalize ID parts
|
112
|
+
# Traslate type into abbreviation, remove leading zeros from number
|
113
|
+
#
|
114
|
+
# @param [RelatonBipm::Id, Hash] src the ID parts
|
115
|
+
#
|
116
|
+
# @return [Hash] the normalized ID parts
|
117
|
+
#
|
118
|
+
def normalize_hash(src) # rubocop:disable Metrics/AbcSize
|
119
|
+
hash = { group: src[:group].to_s.sub("CCDS", "CCTF") }
|
120
|
+
hash[:type] = normalized_type(src) if src[:type]
|
121
|
+
norm_num = normalized_number(src)
|
122
|
+
hash[:number] = norm_num unless norm_num.nil? || norm_num.empty?
|
123
|
+
hash[:year] = src[:year].to_s if src[:year]
|
124
|
+
hash[:lang] = src[:lang].to_s if src[:lang]
|
125
|
+
hash
|
112
126
|
end
|
113
127
|
|
114
128
|
#
|
@@ -116,8 +130,9 @@ module RelatonBipm
|
|
116
130
|
#
|
117
131
|
# @return [String] the normalized type
|
118
132
|
#
|
119
|
-
def normalized_type
|
120
|
-
TYPES[
|
133
|
+
def normalized_type(src)
|
134
|
+
type = TYPES[src[:type].to_s.capitalize] || src[:type].to_s
|
135
|
+
type == type.upcase ? type : type.capitalize
|
121
136
|
end
|
122
137
|
|
123
138
|
#
|
@@ -125,10 +140,10 @@ module RelatonBipm
|
|
125
140
|
#
|
126
141
|
# @return [String, nil] the normalized number
|
127
142
|
#
|
128
|
-
def normalized_number
|
129
|
-
return unless
|
143
|
+
def normalized_number(src)
|
144
|
+
return unless src[:number]
|
130
145
|
|
131
|
-
|
146
|
+
src[:number].to_s.sub(/^0+/, "")
|
132
147
|
end
|
133
148
|
end
|
134
149
|
end
|
@@ -7,7 +7,7 @@ module RelatonBipm
|
|
7
7
|
def initialize
|
8
8
|
@short = :relaton_bipm
|
9
9
|
@prefix = "BIPM"
|
10
|
-
@defaultprefix = %r{^(?:BIPM|CCTF|CCDS|CGPM|CIPM)(?!\w)}
|
10
|
+
@defaultprefix = %r{^(?:BIPM|CCTF|CCDS|CGPM|CIPM|JCRB)(?!\w)}
|
11
11
|
@idtype = "BIPM"
|
12
12
|
@datasets = %w[bipm-data-outcomes bipm-si-brochure rawdata-bipm-metrologia]
|
13
13
|
end
|
@@ -103,7 +103,10 @@ module RelatonBipm
|
|
103
103
|
@meta.xpath("./title-group/article-title").map do |t|
|
104
104
|
next if t.text.empty?
|
105
105
|
|
106
|
-
|
106
|
+
format = CGI.escapeHTML(t.inner_html) == t.inner_html ? "text/plain" : "text/html"
|
107
|
+
RelatonBib::TypedTitleString.new(
|
108
|
+
content: t.inner_html, language: t[:"xml:lang"], script: "Latn", format: format,
|
109
|
+
)
|
107
110
|
end.compact
|
108
111
|
end
|
109
112
|
|
@@ -35,7 +35,7 @@ module RelatonBipm
|
|
35
35
|
out_path = File.join(@data_fetcher.output, file)
|
36
36
|
@data_fetcher.index[[item.docidentifier.first.id]] = out_path
|
37
37
|
@data_fetcher.index_new.add_or_update [item.docidentifier.first.id], out_path
|
38
|
-
key = Id.new(item.docidentifier.first.id).
|
38
|
+
key = Id.new(item.docidentifier.first.id).to_hash
|
39
39
|
@data_fetcher.index2.add_or_update key, out_path
|
40
40
|
@data_fetcher.write_file out_path, item
|
41
41
|
end
|
@@ -80,7 +80,7 @@ module RelatonBipm
|
|
80
80
|
path = File.join(@data_fetcher.output, file)
|
81
81
|
@data_fetcher.index[[id]] = path
|
82
82
|
@data_fetcher.index_new.add_or_update [id], path
|
83
|
-
@data_fetcher.index2.add_or_update Id.new(id).
|
83
|
+
@data_fetcher.index2.add_or_update Id.new(id).to_hash, path
|
84
84
|
@data_fetcher.write_file path, item
|
85
85
|
end
|
86
86
|
|
@@ -138,11 +138,12 @@ module RelatonBipm
|
|
138
138
|
#
|
139
139
|
def relation(*args)
|
140
140
|
dir = [DIR, *args].join("/")
|
141
|
-
|
141
|
+
ids = Set.new
|
142
|
+
Dir["#{dir}/*"].each do |path|
|
142
143
|
part = path.split("/").last
|
143
|
-
|
144
|
-
RelatonBib::DocumentRelation.new(type: "partOf", bibitem: rel_bibitem(id))
|
144
|
+
ids << identifier(*args, part)
|
145
145
|
end
|
146
|
+
ids.map { |id| RelatonBib::DocumentRelation.new(type: "partOf", bibitem: rel_bibitem(id)) }
|
146
147
|
end
|
147
148
|
|
148
149
|
#
|
data/lib/relaton_bipm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bipm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -175,7 +175,7 @@ licenses:
|
|
175
175
|
metadata:
|
176
176
|
homepage_uri: https://github.com/relaton/relaton-bipm
|
177
177
|
source_code_uri: https://github.com/relaton/relaton-bipm
|
178
|
-
post_install_message:
|
178
|
+
post_install_message:
|
179
179
|
rdoc_options: []
|
180
180
|
require_paths:
|
181
181
|
- lib
|
@@ -190,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
194
|
-
signing_key:
|
193
|
+
rubygems_version: 3.4.9
|
194
|
+
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: 'RelatonBipm: retrieve BIPM Standards for bibliographic use using the BibliographicItem
|
197
197
|
model'
|