pubid 2.0.0.pre.alpha.22 → 2.0.0.pre.alpha.24
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/ieee.json +1 -1
- data/lib/pubid/ieee/parser.rb +0 -128
- data/lib/pubid/version.rb +1 -1
- metadata +1 -1
data/lib/pubid/ieee/parser.rb
CHANGED
|
@@ -1374,108 +1374,6 @@ module Pubid
|
|
|
1374
1374
|
cleaned.sub(%r{(\d)[Rr][Ee][Vv][A-Za-z0-9]+\s*\z}, '\1')
|
|
1375
1375
|
end
|
|
1376
1376
|
|
|
1377
|
-
# Rewrite the mechanical spellings of the joint ISO-stage forms that no
|
|
1378
|
-
# grammar branch reaches (pubid#216 residuals). Two safety rules keep
|
|
1379
|
-
# this from stealing inputs other rules already parse:
|
|
1380
|
-
# 1. only BROKEN separators fire — underscore/space glue between
|
|
1381
|
-
# number, draft and stage, a slash-SPACE before the stage, a
|
|
1382
|
-
# dash/underscore month after it. A plain "/FDIS" tail is
|
|
1383
|
-
# natively accepted by ieee_p_identifier (fdraft) and the
|
|
1384
|
-
# stage-LAST embedded rule, so it is never rewritten.
|
|
1385
|
-
# 2. the number carries at most ONE part — joint_development_iso_format
|
|
1386
|
-
# reads a single optional part, while ieee_p_identifier takes
|
|
1387
|
-
# multi-part numbers ("P62271-37-013"); a rewrite that moved a
|
|
1388
|
-
# multi-part number onto the joint rule would break it.
|
|
1389
|
-
def self.normalize_joint_stage_spellings(cleaned)
|
|
1390
|
-
# The separator (slash-optional-space or a space) is INSIDE the
|
|
1391
|
-
# capture so a rewrite re-emits it — an uncaptured separator was
|
|
1392
|
-
# silently eaten, gluing the publisher to the stage.
|
|
1393
|
-
pubs = %r{((?:ISO/IEC/IEEE|IEEE/ISO/IEC|IEEE/IEC/ISO|ISO/IEEE|IEC/IEEE|IEEE/IEC|ISO/IEC|IEEE)(?:/ ?| ))}
|
|
1394
|
-
stage = /(FDIS|FCD|CDV|DIS\d?|CD\d?|WD|PWI|NP)/
|
|
1395
|
-
num = /(P?\d+(?:[.-]\d+)?)/
|
|
1396
|
-
# What the joint grammar can finish reading AFTER the stage: the end
|
|
1397
|
-
# of the string, a (comma-)month-year date, or a dash-year[-month].
|
|
1398
|
-
# Captured and re-emitted so a rewrite never drops the date.
|
|
1399
|
-
tail = /(,? (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)[a-z]* \d{4}|\z|-\d{4}(?:-\d\d)?)/
|
|
1400
|
-
|
|
1401
|
-
# Draft glued to the number with an underscore: "P15289_D3" →
|
|
1402
|
-
# "P15289/D3" (a digit must precede the underscore; "_FDIS" is the
|
|
1403
|
-
# stage, not a draft, and is already slash-rewritten earlier).
|
|
1404
|
-
cleaned = cleaned.gsub(%r{(\d)_D(\d)}, '\1/D\2')
|
|
1405
|
-
|
|
1406
|
-
# Crawl typo: a comma with no space before a month (",March 2021").
|
|
1407
|
-
# In these identifiers a comma is always a date separator, so
|
|
1408
|
-
# spacing it is safe.
|
|
1409
|
-
cleaned = cleaned.sub(/,(?=[A-Za-z])/, ", ")
|
|
1410
|
-
|
|
1411
|
-
# Stage AFTER the draft, both glued with underscores (the early
|
|
1412
|
-
# stage gsub already turned "_CD" into "/CD"):
|
|
1413
|
-
# "…P24748-3/D3/FDIS, April 2020 (E)" → "…FDIS P24748-3/D3, …"
|
|
1414
|
-
cleaned = cleaned.sub(
|
|
1415
|
-
%r{\A#{pubs}#{num}/(D[\d.]+)/ ?#{stage}\b},
|
|
1416
|
-
'\1\4 \2/\3',
|
|
1417
|
-
)
|
|
1418
|
-
|
|
1419
|
-
# Slash-SPACE before the stage ("…P16085/ FDIS, August 2020" —
|
|
1420
|
-
# ieee_p's fdraft has no inner space, so this spelling has no other
|
|
1421
|
-
# home): → "…FDIS P16085, August 2020"
|
|
1422
|
-
cleaned = cleaned.sub(
|
|
1423
|
-
%r{\A#{pubs}#{num}/ #{stage}#{tail}},
|
|
1424
|
-
'\1\3 \2\4',
|
|
1425
|
-
)
|
|
1426
|
-
|
|
1427
|
-
# A space-year after a slash-stage ("…P26511.2/FDIS 2018" — no rule
|
|
1428
|
-
# reads "/FDIS 2018"): → "…FDIS P26511.2-2018" (dash-year clause).
|
|
1429
|
-
cleaned = cleaned.sub(
|
|
1430
|
-
%r{\A#{pubs}#{num}/#{stage} (\d{4})\b},
|
|
1431
|
-
'\1\3 \2-\4',
|
|
1432
|
-
)
|
|
1433
|
-
|
|
1434
|
-
# Stage separated from the number by a SPACE ("IEC/IEEE P63113 CD4,
|
|
1435
|
-
# April 2019"): → "IEC/IEEE CD4 P63113, April 2019". The tail guard
|
|
1436
|
-
# keeps "…FDIS March 2019" (space-month-year, readable after the
|
|
1437
|
-
# swap) while leaving prose suffixes alone.
|
|
1438
|
-
cleaned = cleaned.sub(
|
|
1439
|
-
%r{\A#{pubs}#{num} #{stage}#{tail}},
|
|
1440
|
-
'\1\3 \2\4',
|
|
1441
|
-
)
|
|
1442
|
-
|
|
1443
|
-
# The same space-stage with a space-DRAFT chained after it
|
|
1444
|
-
# ("IEC/IEEE P60980-344 CDV D1, June 2019"): → stage-first with a
|
|
1445
|
-
# slash draft ("…CDV P60980-344/D1, June 2019").
|
|
1446
|
-
cleaned = cleaned.sub(
|
|
1447
|
-
%r{\A#{pubs}#{num} #{stage} (D\d+)\b},
|
|
1448
|
-
'\1\3 \2/\4',
|
|
1449
|
-
)
|
|
1450
|
-
|
|
1451
|
-
# Slash-stage carrying a dash-date ("…P15288/CD2-2013-09 …" — the
|
|
1452
|
-
# dash-year tail is what the joint grammar reads after the number, so
|
|
1453
|
-
# this cannot steal the plain "/FDIS, June 2021" spellings
|
|
1454
|
-
# ieee_p_identifier finishes): → "…CD2 P15288-2013-09 …". The date
|
|
1455
|
-
# must be a plausible year — a 4-digit monthcode (YYMM, e.g.
|
|
1456
|
-
# "…P24748-4/DIS-1404" = April 2014) is a DRAFT designator, not a
|
|
1457
|
-
# dash-date, and rewriting it onto the number breaks the parse.
|
|
1458
|
-
cleaned = cleaned.sub(
|
|
1459
|
-
%r{\A#{pubs}#{num}/ ?#{stage}(-(?:19|20)\d\d(?:-\d\d)?)},
|
|
1460
|
-
'\1\3 \2\4',
|
|
1461
|
-
)
|
|
1462
|
-
|
|
1463
|
-
# Draft separated from a stage-first number by a SPACE:
|
|
1464
|
-
# "…DIS P11073-10418 D13, January 2011" → "…DIS P11073-10418/D13, …"
|
|
1465
|
-
cleaned = cleaned.sub(
|
|
1466
|
-
%r{\A#{pubs}#{stage} #{num}/? ?(D\d+)\b},
|
|
1467
|
-
'\1\2 \3/\4',
|
|
1468
|
-
)
|
|
1469
|
-
|
|
1470
|
-
# NOT rewritten: a month glued to the stage with a dash/underscore
|
|
1471
|
-
# ("…/FDIS_Dec 2012", "…/FDIS-Dec 2015"). Even routed onto the joint
|
|
1472
|
-
# grammar, the joint render of a month+draft is itself not yet
|
|
1473
|
-
# idempotent, and the bare-IEEE fdraft path drops the stage and the
|
|
1474
|
-
# date from to_hash — rewriting would trade a visible parse failure
|
|
1475
|
-
# for silent garbage. Deferred with the pubid#216 semantic residue.
|
|
1476
|
-
cleaned
|
|
1477
|
-
end
|
|
1478
|
-
|
|
1479
1377
|
# Pre-parse ingestion normalizations (R2): every parse path —
|
|
1480
1378
|
# parslet and PG artifact alike — feeds the grammar the same
|
|
1481
1379
|
# normalized string.
|
|
@@ -1488,23 +1386,10 @@ module Pubid
|
|
|
1488
1386
|
# which standards are actually IEEE-related.
|
|
1489
1387
|
# ISO-only standards are still filtered as they have separate handling.
|
|
1490
1388
|
|
|
1491
|
-
# Pattern 3: Replace underscore before ISO stage codes with slash
|
|
1492
|
-
# These are joint development drafts that use underscore instead of slash
|
|
1493
|
-
cleaned = cleaned.gsub(/_(FDIS|CDV|CD|DIS|WD|PWI|NP)/, '/\1')
|
|
1494
|
-
|
|
1495
1389
|
# NEW: Normalize multiple spaces to single space
|
|
1496
1390
|
# No valid IEEE identifier pattern needs more than 1 space
|
|
1497
1391
|
cleaned = cleaned.gsub(/\s+/, " ")
|
|
1498
1392
|
|
|
1499
|
-
# A joint ISO-led publisher list is sometimes crawled with a stray slash
|
|
1500
|
-
# (or slash+space) before the ISO stage code — "ISO/IEC/IEEE/ FDIS …" or
|
|
1501
|
-
# "ISO/IEC/IEEE/FDIS …". Restore the space separator so the stage parses
|
|
1502
|
-
# (bucket 7).
|
|
1503
|
-
cleaned = cleaned.gsub(
|
|
1504
|
-
%r{\b(ISO/IEC/IEEE|IEEE/ISO/IEC|IEEE/IEC/ISO|ISO/IEEE|IEC/IEEE|IEEE/IEC|ISO/IEC)/ ?(FDIS|FCD|CDV|DIS\d?|CD\d?|WD|PWI|NP)\b},
|
|
1505
|
-
'\1 \2',
|
|
1506
|
-
)
|
|
1507
|
-
|
|
1508
1393
|
# Rewrite the rawbib revision-notation dialects (REVa/REVd/glued) into
|
|
1509
1394
|
# the canonical /R-<x> form before the suffix normalization below.
|
|
1510
1395
|
cleaned = normalize_revision_notation(cleaned)
|
|
@@ -1520,17 +1405,9 @@ module Pubid
|
|
|
1520
1405
|
cleaned = cleaned.gsub(/(\d)\s+-(\d{4})\b/, '\1-\2') # "C37.101 -2006" → "C37.101-2006"
|
|
1521
1406
|
cleaned = cleaned.gsub(/(\d)-\s+(\d{4})\b/, '\1-\2') # "C62.35- 2010" → "C62.35-2010"
|
|
1522
1407
|
|
|
1523
|
-
# NEW Session 171: HTML entity for en dash (–)
|
|
1524
|
-
# ONLY convert if not already followed by a dash (avoid creating --)
|
|
1525
|
-
cleaned = cleaned.gsub(/–(?!-)/, "-") # En dash → regular hyphen (if not followed by dash)
|
|
1526
|
-
cleaned = cleaned.gsub("–-", "-") # En-dash-dash → single dash
|
|
1527
|
-
|
|
1528
1408
|
# NEW Session 171: Remove wrong ! prefix
|
|
1529
1409
|
cleaned = cleaned.gsub(/^!IEEE /, "IEEE ")
|
|
1530
1410
|
|
|
1531
|
-
# NEW Session 171: Fix "IEEE/ ASTM" spacing (extra space after slash)
|
|
1532
|
-
cleaned = cleaned.gsub("IEEE/ ASTM", "IEEE/ASTM")
|
|
1533
|
-
|
|
1534
1411
|
# NEW Phase 1: Handle HTML entities comprehensively
|
|
1535
1412
|
cleaned = cleaned.gsub("™", "™") # Trademark symbol
|
|
1536
1413
|
cleaned = cleaned.gsub("’", "'") # Smart apostrophe
|
|
@@ -1559,11 +1436,6 @@ module Pubid
|
|
|
1559
1436
|
/\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)(\d{4})\b/, '\1 \2'
|
|
1560
1437
|
)
|
|
1561
1438
|
|
|
1562
|
-
# Rewrite the joint ISO-stage glued spellings (pubid#216) AFTER the
|
|
1563
|
-
# month unglue above, so "Dec2015" is already spaced when the
|
|
1564
|
-
# dash-month rewrite looks for it.
|
|
1565
|
-
cleaned = normalize_joint_stage_spellings(cleaned)
|
|
1566
|
-
|
|
1567
1439
|
# NEW: Convert IEC/IEEE space-separated to semicolon format
|
|
1568
1440
|
# Pattern: "IEC 61523-3 First edition 2004-09; IEEE 1497" → already semicolon
|
|
1569
1441
|
# Pattern: "IEC 62539 First Edition 2007-07 IEEE 930" → needs semicolon
|
data/lib/pubid/version.rb
CHANGED