pubid 2.0.61 → 2.0.62
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/data/parg/nist.json +1 -1
- data/lib/pubid/iso/CLAUDE.md +18 -4
- data/lib/pubid/iso/identifier.rb +1 -25
- data/lib/pubid/iso/normalizer.rb +0 -4
- data/lib/pubid/nist/CLAUDE.md +46 -0
- data/lib/pubid/nist/caster.rb +7 -1
- data/lib/pubid/nist/identifiers/base.rb +8 -1
- data/lib/pubid/nist/preprocessor.rb +12 -5
- data/lib/pubid/nist/router.rb +1 -1
- data/lib/pubid/version.rb +1 -1
- metadata +2 -2
data/lib/pubid/iso/CLAUDE.md
CHANGED
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
render byte-identically. No grammar or renderer change was needed.
|
|
80
80
|
|
|
81
81
|
- **Typed model bindings (Phase D): the builder consumes the grammar's bound
|
|
82
|
-
map, not a parse tree.** `
|
|
82
|
+
map, not a parse tree.** `Normalizer` (which `Identifier.parse` reaches
|
|
83
|
+
through `Pubid::Iso.parse`) parses through
|
|
83
84
|
`Pubid::Parg::Model.bound(:iso, …)`; `UrnParser#build_identifier` constructs
|
|
84
85
|
the same bound-map dialect. The grammar is edition 2 with every
|
|
85
86
|
builder-consumed capture bound (`grammars/iso.parg`, `bindings identifier`).
|
|
@@ -217,9 +218,22 @@
|
|
|
217
218
|
A `data/iso/update_codes.yaml` regex removes `-_` after a digit when a
|
|
218
219
|
separator (`:`, `/`, `(`, space) or the end follows, so the id parses as
|
|
219
220
|
`ISO/NP TS 6041` with a nil part. A nil part is the honest model (the part
|
|
220
|
-
is unknown), and
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
is unknown), and a parse of the `-_` form gives the same identifier as
|
|
222
|
+
the index row. The render is normalized, not byte-exact. No grammar or
|
|
223
|
+
artifact change.
|
|
224
|
+
**The first fix did not reach relaton (relaton/relaton-data-iso#49).**
|
|
225
|
+
relaton calls `Pubid::Iso::Identifier.parse` (`Relaton::Iso::DataParser#pubid`,
|
|
226
|
+
`Relaton::Iso::Docidentifier#content=`), not `Pubid::Iso.parse`. The class
|
|
227
|
+
method had its own body that went straight to the grammar and skipped
|
|
228
|
+
`Normalizer` — no update codes, no Cyrillic decode, no DAD rewrite — so the
|
|
229
|
+
stored docid stayed unparseable and every Deploy reported it again. Over
|
|
230
|
+
the 7,674 ISO `full/` inputs the two entry points differed on 44 (the
|
|
231
|
+
`-_` id was not in the corpus; the 44 were all Cyrillic, `ИСО 3858`), and
|
|
232
|
+
every time the class method raised. The class method now delegates to
|
|
233
|
+
`Pubid::Iso.parse`, the jcgm/nist shape, so one path holds every ISO
|
|
234
|
+
normalization. A 400-input sample of every other flavor showed no such
|
|
235
|
+
split. **Lesson**: a normalization belongs behind every public entry
|
|
236
|
+
point; test it through the one the consumer calls.
|
|
223
237
|
**Known gap:** the rule is ISO-only, and IEC's grammar accepts `_` as a
|
|
224
238
|
part, so `Pubid.parse("ISO 6041-_")` routes to IEC (an exact round trip
|
|
225
239
|
wins) with part `"_"`. The reported `ISO/NP TS 6041-_` still reaches ISO,
|
data/lib/pubid/iso/identifier.rb
CHANGED
|
@@ -300,31 +300,7 @@ module Pubid
|
|
|
300
300
|
end
|
|
301
301
|
|
|
302
302
|
def self.parse(string, format: :auto)
|
|
303
|
-
|
|
304
|
-
raise Pubid::Errors::InvalidInputError,
|
|
305
|
-
Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
if string.length > Pubid::MAX_INPUT_LENGTH
|
|
309
|
-
raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
string = ::Pubid.utf8_input(string)
|
|
313
|
-
|
|
314
|
-
format = Pubid::FormatDetector.detect(string) if format == :auto
|
|
315
|
-
|
|
316
|
-
case format
|
|
317
|
-
when :urn
|
|
318
|
-
Pubid::Iso::UrnParser.parse(string)
|
|
319
|
-
when :mr_string
|
|
320
|
-
Pubid::Parsers::MrString.parse(string)
|
|
321
|
-
else
|
|
322
|
-
# The baked PG artifact parses through the grammar's declared
|
|
323
|
-
# bindings: the Builder consumes the typed bound map (every
|
|
324
|
-
# capture bound by name, supplement layers position-scoped).
|
|
325
|
-
parsed = Pubid::Parg::Model.bound(:iso, string)
|
|
326
|
-
Pubid::Iso::Builder.new.build(parsed)
|
|
327
|
-
end
|
|
303
|
+
Pubid::Iso.parse(string, format: format)
|
|
328
304
|
end
|
|
329
305
|
|
|
330
306
|
# from_hash is the shared polymorphic dispatch on Pubid::Identifier, which
|
data/lib/pubid/iso/normalizer.rb
CHANGED
|
@@ -27,10 +27,6 @@ module Pubid
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
29
|
def parse_with_builder(string)
|
|
30
|
-
# R2 ingestion hook: normalized strings reach the model through
|
|
31
|
-
# the same parser of record as Identifier.parse (the baked PG
|
|
32
|
-
# artifact's bindings), so every Tier-3 normalization feeds one
|
|
33
|
-
# grammar.
|
|
34
30
|
parsed = Pubid::Parg::Model.bound(:iso, string)
|
|
35
31
|
Pubid::Iso.builder.build(parsed)
|
|
36
32
|
end
|
data/lib/pubid/nist/CLAUDE.md
CHANGED
|
@@ -220,3 +220,49 @@ Read this before you change `lib/pubid/nist/` or `spec/pubid/nist/`. The root
|
|
|
220
220
|
non-normalized aliases of the canonical cases, the two bare ones as
|
|
221
221
|
canonical `publisher_was_parsed: false` cases) with the gem twin in
|
|
222
222
|
lockstep.
|
|
223
|
+
|
|
224
|
+
- **A dotted tail after a bare number reads the same in every prefix form
|
|
225
|
+
(relaton-data-nist#37).** The relaton NIST crawler spaces only the DOI's
|
|
226
|
+
`PUB.SERIES.` prefix, so it parses a **mixed** spelling: `NIST SP 1271.ukr`.
|
|
227
|
+
`normalize_mr_translation_codes!` turned the final `.xxx` into ` xxx` only for
|
|
228
|
+
the all-dots form with a pure-digit number, so the mixed form (and
|
|
229
|
+
`NIST.IR.8259B.spa`, a letter-suffixed number) reached the grammar with the
|
|
230
|
+
dot, which reads `.u` as a part letter and `kr` as a two-letter translation:
|
|
231
|
+
`NIST SP 1271-u(kr)` — a face the gem then could not parse, so 14 published
|
|
232
|
+
ids were dropped from the index. A second rule now accepts a dot or a space
|
|
233
|
+
after the publisher and after the series, and an optional capital letter
|
|
234
|
+
after the number — but **only for a known language tail**
|
|
235
|
+
(`Preprocessor::TRANSLATION_TAIL_CODES`: the codes in relaton-data-nist plus
|
|
236
|
+
the `Caster::TRANSLATION_MAP` keys). **Do not widen it to any lowercase
|
|
237
|
+
tail.** A first version did, and review found that spacing a marker gives it
|
|
238
|
+
a wrong meaning: `NBS CIRC 154.sup` silently lost its supplement, and
|
|
239
|
+
`NIST SP 1262.rev` became revision `ev`. The all-dots MR rule keeps its old
|
|
240
|
+
any-tail behaviour unchanged. Marker tails in the mixed form are still
|
|
241
|
+
corrupted (`NIST FIPS 197.ipd` → `197-i(pd)`, `NBS TN 467.add` →
|
|
242
|
+
`467-a(dd)`); they are not in #37, and they need their own per-marker
|
|
243
|
+
ruling. A hyphenated number (`800-181.spa`) never needed it. Verified byte-identical
|
|
244
|
+
over the 21,382-id `full/` corpus. Two ids are a crawler bug (`…;https://…`,
|
|
245
|
+
hand-off `relaton__relaton__nist-doi-semicolon-split`). Locked by
|
|
246
|
+
`spec/pubid/nist/dotted_translation_spec.rb`, which also pins that rejection.
|
|
247
|
+
|
|
248
|
+
- **`NIST NWIRP GCR` and `NBS RPT SA150` (the grammar half of #37).** The
|
|
249
|
+
vendored `data/parg/nist.json` comes from pubid-grammar PR #170. It adds the
|
|
250
|
+
compound series `NIST NWIRP GCR` / `NIST.NWIRP.GCR` and a letter-prefixed
|
|
251
|
+
number on the `RPT` path only. The RPT forms needed no gem change. The GCR
|
|
252
|
+
sub-series needed two: the grammar captures the MR spelling as one token
|
|
253
|
+
`NIST.NWIRP.GCR`, so `Caster::DOTTED_COMPOUND_SERIES` folds it onto the
|
|
254
|
+
spaced token before the publisher split (else the publisher is nil and the
|
|
255
|
+
MR face is `NIST.NIST.NWIRP.GCR.1-2`); and the series value keeps its space
|
|
256
|
+
(`NWIRP GCR`), so `Identifiers::Base::MR_SERIES_FACES` prints it dotted in
|
|
257
|
+
the MR face. `to_mr_style` does **not** read the `mr` table of
|
|
258
|
+
`data/nist/series.yaml`; wiring that table in would move many MR faces
|
|
259
|
+
(`MONO` → `MN`), so the map stays narrow. Other spaced series (`CSRC Book`,
|
|
260
|
+
`ITL Bulletin`) still print a space in the MR face; that is older and not
|
|
261
|
+
in #37. The official `to_urn` prints the series raw
|
|
262
|
+
(`urn:nist:nwirp gcr:1-2.supp`); it parses back, and the pass corpus
|
|
263
|
+
already has 114 `Rev. N` URNs with a space, so it was left. The pubid-scheme
|
|
264
|
+
URN escapes the space (`series-NWIRP~20GCR`). Locked by
|
|
265
|
+
`spec/pubid/nist/nwirp_gcr_rpt_letter_number_spec.rb`.
|
|
266
|
+
The classification run for these fixtures dropped seven inputs that lived
|
|
267
|
+
only in `pass/` (the bare series references `NBS CS` … and
|
|
268
|
+
`NIST FIPS 199 Rev. 1`); they are now in `full/complete.txt`.
|
data/lib/pubid/nist/caster.rb
CHANGED
|
@@ -21,6 +21,12 @@ module Pubid
|
|
|
21
21
|
"esp" => "spa",
|
|
22
22
|
}.freeze
|
|
23
23
|
|
|
24
|
+
# The grammar captures the MR spelling of these compound series as one
|
|
25
|
+
# token. They fold onto the spaced spelling, so both are one identity.
|
|
26
|
+
DOTTED_COMPOUND_SERIES = {
|
|
27
|
+
"NIST.NWIRP.GCR" => "NIST NWIRP GCR",
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
24
30
|
# Cast parsed value to appropriate component type
|
|
25
31
|
# ALL conversions happen in this single method
|
|
26
32
|
# @param type [Symbol] the parameter type
|
|
@@ -56,7 +62,7 @@ module Pubid
|
|
|
56
62
|
when :series
|
|
57
63
|
return nil if value.nil? || value.to_s.strip.empty?
|
|
58
64
|
|
|
59
|
-
str_value = value.to_s
|
|
65
|
+
str_value = DOTTED_COMPOUND_SERIES.fetch(value.to_s, value.to_s)
|
|
60
66
|
publisher_extracted = nil
|
|
61
67
|
|
|
62
68
|
# Compound series carry the publisher inside the series token (e.g.
|
|
@@ -31,6 +31,10 @@ module Pubid
|
|
|
31
31
|
COMPACT_FLAT_VALUES = %w[volume].freeze
|
|
32
32
|
COMPACT_DROP_ATTRS = %w[first_number second_number].freeze
|
|
33
33
|
|
|
34
|
+
# A compound sub-series keeps its space in the series value and turns
|
|
35
|
+
# it into a dot in the MR face, the DOI suffix NIST publishes.
|
|
36
|
+
MR_SERIES_FACES = { "NWIRP GCR" => "NWIRP.GCR" }.freeze
|
|
37
|
+
|
|
34
38
|
# Deserialize a (possibly compact) hash: expand the flattened scalars
|
|
35
39
|
# back into Code sub-hashes, then let the shared polymorphic from_hash
|
|
36
40
|
# do the real work. Nested `base` documents are expanded recursively by
|
|
@@ -808,7 +812,10 @@ module Pubid
|
|
|
808
812
|
series.to_s
|
|
809
813
|
end
|
|
810
814
|
|
|
811
|
-
|
|
815
|
+
if effective_series
|
|
816
|
+
result += ".#{MR_SERIES_FACES.fetch(effective_series,
|
|
817
|
+
effective_series)}"
|
|
818
|
+
end
|
|
812
819
|
result += ".#{number}" if number
|
|
813
820
|
result += parts.map { |p| "-#{p}" }.join if parts&.any?
|
|
814
821
|
|
|
@@ -34,6 +34,15 @@ module Pubid
|
|
|
34
34
|
"X" => "10",
|
|
35
35
|
}.freeze
|
|
36
36
|
|
|
37
|
+
TRANSLATION_TAIL_CODES = (
|
|
38
|
+
%w[ara fra fre ind jpn kor por slo spa ukr vie zho] +
|
|
39
|
+
Caster::TRANSLATION_MAP.keys
|
|
40
|
+
).uniq.freeze
|
|
41
|
+
SPACED_OR_LETTERED_TRANSLATION_TAIL = /
|
|
42
|
+
\A([A-Z]+[. ][A-Z]+[. ]\d+[A-Z]?)
|
|
43
|
+
\.(#{Regexp.union(TRANSLATION_TAIL_CODES).source})\z
|
|
44
|
+
/x
|
|
45
|
+
|
|
37
46
|
def initialize(input)
|
|
38
47
|
@input = input.to_s.strip
|
|
39
48
|
@cleaned = Core::UpdateCodes.apply(@input, :nist)
|
|
@@ -365,12 +374,10 @@ module Pubid
|
|
|
365
374
|
# MR-format translation codes (".spa", ".por", ".ind") would be
|
|
366
375
|
# misparsed as letter suffixes — convert the trailing dot to a space.
|
|
367
376
|
def normalize_mr_translation_codes!
|
|
368
|
-
@cleaned = @cleaned.
|
|
369
|
-
|
|
370
|
-
)
|
|
371
|
-
@cleaned = @cleaned.gsub(
|
|
372
|
-
/^([A-Z]+)\.([A-Z]+)\.(\d+)\.([a-z]{2,4})$/, '\1.\2.\3 \4'
|
|
377
|
+
@cleaned = @cleaned.sub(
|
|
378
|
+
/\A([A-Z]+\.[A-Z]+\.\d+)\.([a-z]{2,4})\z/, '\1 \2'
|
|
373
379
|
)
|
|
380
|
+
@cleaned = @cleaned.sub(SPACED_OR_LETTERED_TRANSLATION_TAIL, '\1 \2')
|
|
374
381
|
end
|
|
375
382
|
|
|
376
383
|
# Trailing "-YYYY" → "eYYYY" edition marker, but only when the
|
data/lib/pubid/nist/router.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Pubid
|
|
|
25
25
|
"BRPD-CRPL-D", "CRPL-F-A", "CRPL-F-B", "CS-E",
|
|
26
26
|
"CSRC Building Block", "CSRC Use Case", "CSRC Book",
|
|
27
27
|
"ITL Bulletin", "NIST LC", "NIST PS", "NIST DCI",
|
|
28
|
-
"NIST Other", "NSRDS-NBS",
|
|
28
|
+
"NIST Other", "NSRDS-NBS", "NIST NWIRP GCR",
|
|
29
29
|
].freeze
|
|
30
30
|
|
|
31
31
|
# Check if series is valid
|
data/lib/pubid/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.62
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-12-
|
|
11
|
+
date: 2026-12-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|