relaton-bipm 1.14.4 → 1.14.5
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/.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 +64 -49
- 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: e0d5eb5717b605c2d3eec083e4ca529ccafb140246b1b8a042137d1025b41abb
|
|
4
|
+
data.tar.gz: bdef48071e8e5ab07d643e54fed9f21c38d29119927620216a23d2d2d9c84a7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09e75649f7ca561179506cf24c0eb9c06b2c2e6241aac712e3aaa01e85985542d7086d907068acc365b0b93386e83160646e41d67585b1c9a8e98c8b5c281f55'
|
|
7
|
+
data.tar.gz: ca8540f40846fe5d92b0b2da284c72cb3a44a4dfd580ad4a51eb6c625cfd400aa59b7a435c46af45244540482d02aff1bd9aa70b3cc5359a41b873602b5d5ecd
|
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,19 @@ 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 = [item.docnumber]
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
end
|
|
240
|
-
key
|
|
233
|
+
# key = [item.docnumber]
|
|
234
|
+
# SHORTTYPE.each do |k, v|
|
|
235
|
+
# if item.docnumber.include? k
|
|
236
|
+
# key << item.docnumber.sub(k, v)
|
|
237
|
+
# key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, EN\\2")
|
|
238
|
+
# key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, FR\\2")
|
|
239
|
+
# break
|
|
240
|
+
# end
|
|
241
|
+
# end
|
|
242
|
+
key = item.docidentifier.select { |i| i.type == "BIPM" }.map &:id
|
|
241
243
|
@data_fetcher.index[key] = path
|
|
242
244
|
@data_fetcher.index_new.add_or_update key, path
|
|
243
|
-
key2 = Id.new(item.docnumber).
|
|
245
|
+
key2 = Id.new(item.docnumber).to_hash
|
|
244
246
|
@data_fetcher.index2.add_or_update key2, path
|
|
245
247
|
end
|
|
246
248
|
|
|
@@ -349,12 +351,12 @@ module RelatonBipm
|
|
|
349
351
|
# @param [String] session number of meeting
|
|
350
352
|
#
|
|
351
353
|
def add_part(hash, part)
|
|
352
|
-
regex = /(\p{L}+\s(
|
|
354
|
+
regex = /(\p{L}+\s(?:\w+\/)?\d+)(?![\d-])/
|
|
353
355
|
hash[:id] += "-#{part}"
|
|
354
356
|
hash[:docnumber].sub!(regex) { |m| "#{m}-#{part}" }
|
|
355
357
|
hash[:docid].select { |id| id.type == "BIPM" }.each do |did|
|
|
356
|
-
|
|
357
|
-
did.instance_variable_set(:@id, id)
|
|
358
|
+
did.instance_variable_get(:@id).sub!(regex) { "#{$1}-#{part}" }
|
|
359
|
+
# did.instance_variable_set(:@id, id)
|
|
358
360
|
end
|
|
359
361
|
hash[:structuredidentifier].instance_variable_set :@part, part
|
|
360
362
|
end
|
|
@@ -374,12 +376,12 @@ module RelatonBipm
|
|
|
374
376
|
# @return [Hash] Hash of BIPM meeting/resolution
|
|
375
377
|
#
|
|
376
378
|
def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
377
|
-
docnum =
|
|
379
|
+
docnum = create_meeting_docnum args[:body], args[:type], args[:num], args[:en]["date"]
|
|
378
380
|
hash = { title: [], type: "proceedings", doctype: args[:type],
|
|
379
381
|
place: [RelatonBib::Place.new(city: "Paris")] }
|
|
380
382
|
hash[:title] = create_titles args.slice(:en, :fr)
|
|
381
383
|
hash[:date] = [{ type: "published", on: args[:en]["date"] }]
|
|
382
|
-
hash[:docid] =
|
|
384
|
+
hash[:docid] = create_meeting_docids docnum
|
|
383
385
|
hash[:docnumber] = docnum # .sub(" --", "").sub(/\s\(\d{4}\)/, "")
|
|
384
386
|
hash[:id] = create_id(args[:body], args[:type], args[:num], args[:en]["date"])
|
|
385
387
|
hash[:link] = create_links(**args)
|
|
@@ -426,16 +428,21 @@ module RelatonBipm
|
|
|
426
428
|
#
|
|
427
429
|
def create_docnum(body, type, num, date)
|
|
428
430
|
year = Date.parse(date).year
|
|
429
|
-
if special_id_case? body, type, year
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
else
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
end
|
|
431
|
+
# if special_id_case? body, type, year
|
|
432
|
+
# id = "#{type.capitalize} #{body}"
|
|
433
|
+
# id += "/#{num}" if num.to_i.positive?
|
|
434
|
+
# else
|
|
435
|
+
id = "#{body} #{SHORTTYPE[type.capitalize]}"
|
|
436
|
+
id += " #{num}" if num.to_i.positive?
|
|
437
|
+
# end
|
|
436
438
|
"#{id} (#{year})"
|
|
437
439
|
end
|
|
438
440
|
|
|
441
|
+
def create_meeting_docnum(body, type, num, date)
|
|
442
|
+
year = Date.parse(date).year
|
|
443
|
+
"#{body} #{num}th #{type} (#{year})"
|
|
444
|
+
end
|
|
445
|
+
|
|
439
446
|
#
|
|
440
447
|
# Create ID
|
|
441
448
|
#
|
|
@@ -448,13 +455,11 @@ module RelatonBipm
|
|
|
448
455
|
#
|
|
449
456
|
def create_id(body, type, num, date)
|
|
450
457
|
year = Date.parse(date).year
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
id += "-#{num}" if num.to_i.positive?
|
|
457
|
-
id
|
|
458
|
+
# if special_id_case?(body, type, year)
|
|
459
|
+
# [type.capitalize, body, year]
|
|
460
|
+
# else
|
|
461
|
+
[body, SHORTTYPE[type.capitalize], year, num].compact.join("-")
|
|
462
|
+
# end
|
|
458
463
|
end
|
|
459
464
|
|
|
460
465
|
#
|
|
@@ -466,10 +471,10 @@ module RelatonBipm
|
|
|
466
471
|
#
|
|
467
472
|
# @return [Boolean] is special case
|
|
468
473
|
#
|
|
469
|
-
def special_id_case?(body, type, year)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
end
|
|
474
|
+
# def special_id_case?(body, type, year)
|
|
475
|
+
# (body == "CIPM" && type == "Decision" && year.to_i > 2011) ||
|
|
476
|
+
# (body == "JCRB" && %w[recomendation resolution descision].include?(type))
|
|
477
|
+
# end
|
|
473
478
|
|
|
474
479
|
#
|
|
475
480
|
# Create documetn IDs
|
|
@@ -478,12 +483,22 @@ module RelatonBipm
|
|
|
478
483
|
#
|
|
479
484
|
# @return [Array<RelatonBib::DocumentIdentifier>] document IDs
|
|
480
485
|
#
|
|
481
|
-
def create_docids(
|
|
482
|
-
|
|
486
|
+
def create_docids(id)
|
|
487
|
+
en_id = id.sub(/(\s\(\d{4})(\))$/, '\1, E\2')
|
|
488
|
+
fr_id = id.sub(/(\s\(\d{4})(\))$/, '\1, F\2')
|
|
483
489
|
[
|
|
484
490
|
make_docid(id: id, type: "BIPM", primary: true),
|
|
485
|
-
make_docid(id:
|
|
486
|
-
|
|
491
|
+
make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
|
|
492
|
+
make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
|
|
493
|
+
# create_docid_fr(en_id),
|
|
494
|
+
]
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
def create_meeting_docids(en_id)
|
|
498
|
+
fr_id = en_id.sub(/(\d+)th/, '\1e').sub("meeting", "réunion")
|
|
499
|
+
[
|
|
500
|
+
make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
|
|
501
|
+
make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
|
|
487
502
|
]
|
|
488
503
|
end
|
|
489
504
|
|
|
@@ -494,11 +509,11 @@ module RelatonBipm
|
|
|
494
509
|
#
|
|
495
510
|
# @return [RelatonBib::DocumentIdentifier] french document ID
|
|
496
511
|
#
|
|
497
|
-
def create_docid_fr(en_id)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
end
|
|
512
|
+
# def create_docid_fr(en_id)
|
|
513
|
+
# tr = TRANSLATIONS.detect { |_, v| en_id.include? v }
|
|
514
|
+
# id = tr ? en_id.sub(tr[1], tr[0]) : en_id
|
|
515
|
+
# make_docid(id: id, type: "BIPM", primary: true, language: "fr", script: "Latn")
|
|
516
|
+
# end
|
|
502
517
|
|
|
503
518
|
#
|
|
504
519
|
# 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.5
|
|
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-02 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'
|