relaton-ieee 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b87fe1e68a822c6589d00479407ad483f13bcffd1d652885839e0e15c0f0b8c
4
- data.tar.gz: 8592b17b9d14faaa3b4a117c1f453af5591884230b6f92f68a4caf4a7dc89bed
3
+ metadata.gz: f5ea9caf8eaf59f616cad6b137ff46fbfd0f28d38ad92c457467a3d19032d2a7
4
+ data.tar.gz: 88b376e90082b8a6bb730e5a07b96930b292c092ece0ce82850a50a9d9cdeb0e
5
5
  SHA512:
6
- metadata.gz: 0463f9179cd438c1c9bcd146b586aa82143ddf119b00b36b24a33bead1f9cfc597553cc277c3ff24e5c2f58b4c7ded9bd553bdfec3e2a327d14377f000a94346
7
- data.tar.gz: 3777fa1634406a12a0734a6efab5d0ac9df0aa540f4f7fb7e26118657809a3120bc796b257e02b2a460cf79757cdfbeb38e224ec1be30798ee9aa23649a0ee63
6
+ metadata.gz: c5eeb5339a3d598da5509de3ffc2bb9231694f9a9edc6603b40cb2634ded16f6ebee01c0ffb222b624426075c7dfd28382bdfac428077097821215a017680f7f
7
+ data.tar.gz: 9d8ee0f3c616d91d53ce9bfd54ceaf4a5cd458ac78471e69f7179daf6f5cf225681dadfe409011012f8c4e987e11f87e27a7e82b777aff2138873be5761aa617
@@ -3,7 +3,7 @@ module RelatonIeee
3
3
  extend RelatonBib::BibXMLParser
4
4
  extend BibXMLParser
5
5
 
6
- FLAVOR = "IEEE"
6
+ FLAVOR = "IEEE".freeze
7
7
 
8
8
  # @param attrs [Hash]
9
9
  # @return [RelatonBib::IetfBibliographicItem]
@@ -1,5 +1,6 @@
1
1
  require "zip"
2
2
  require "relaton_ieee/data_parser"
3
+ require "relaton_ieee/rawbib_id_parser"
3
4
 
4
5
  module RelatonIeee
5
6
  class DataFetcher
@@ -30,6 +31,7 @@ module RelatonIeee
30
31
  @ext = format.sub(/^bib/, "")
31
32
  @crossrefs = {}
32
33
  @backrefs = {}
34
+ # @normtitles = []
33
35
  end
34
36
 
35
37
  #
@@ -64,6 +66,7 @@ module RelatonIeee
64
66
  warn e.message
65
67
  warn e.backtrace
66
68
  end
69
+ # File.write "normtitles.txt", @normtitles.join("\n")
67
70
  update_relations
68
71
  end
69
72
 
@@ -87,20 +90,33 @@ module RelatonIeee
87
90
  # @param [String] xml content
88
91
  # @param [String] filename source file
89
92
  #
90
- def fetch_doc(xml, filename) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
93
+ def fetch_doc(xml, filename) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
91
94
  doc = Nokogiri::XML(xml).at("/publication")
92
95
  unless doc
93
96
  warn "Empty file: #{filename}"
94
97
  return
95
98
  end
99
+ stdid = doc.at("./publicationinfo/standard_id").text
100
+ if stdid == "0"
101
+ # nt = doc&.at("./normtitle")&.text
102
+ # ntid = @normtitles.index nt
103
+ # @normtitles << nt if nt && !ntid
104
+ warn "Zero standard_id in #{filename}"
105
+ return
106
+ end
96
107
  bib = DataParser.parse doc, self
108
+ if bib.docnumber.nil?
109
+ nt = doc&.at("./normtitle")&.text
110
+ warn "PubID parse error. Normtitle: #{nt}, file: #{filename}"
111
+ return
112
+ end
97
113
  amsid = doc.at("./publicationinfo/amsid").text
98
114
  if backrefs.value?(bib.docidentifier[0].id) && /updates\.\d+/ !~ filename
99
115
  oamsid = backrefs.key bib.docidentifier[0].id
100
116
  warn "Document exists ID: \"#{bib.docidentifier[0].id}\" AMSID: "\
101
117
  "\"#{amsid}\" source: \"#{filename}\". Other AMSID: \"#{oamsid}\""
102
- if bib.docidentifier[0].id.include?(bib.docnumber)
103
- save_doc bib # rewrite file if the PubID mathces to the docnumber
118
+ if bib.docidentifier[0].id.include?(doc.at("./publicationinfo/stdnumber").text)
119
+ save_doc bib # rewrite file if the PubID matches to the stdnumber
104
120
  backrefs[amsid] = bib.docidentifier[0].id
105
121
  end
106
122
  else
@@ -147,7 +163,7 @@ module RelatonIeee
147
163
  # @return [String] filename
148
164
  #
149
165
  def file_name(docnumber)
150
- name = docnumber.gsub(/\s-/, "-").gsub(/[.\s,:\/]/, "_").squeeze("_").upcase
166
+ name = docnumber.gsub(/\s-/, "-").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
151
167
  File.join @output, "#{name}.#{@ext}"
152
168
  end
153
169
 
@@ -110,7 +110,7 @@ module RelatonIeee
110
110
  # @return [Array<RelatonBib::DocumentIdentifier>]
111
111
  #
112
112
  def parse_docid
113
- ids = [{ id: doc.at("./title").text, type: "IEEE" }]
113
+ ids = [{ id: pubid.to_s, type: "IEEE" }]
114
114
  isbn = doc.at("./publicationinfo/isbn")
115
115
  ids << { id: isbn.text, type: "ISBN" } if isbn
116
116
  doi = doc.at("./volume/article/articleinfo/articledoi")
@@ -120,13 +120,20 @@ module RelatonIeee
120
120
  end
121
121
  end
122
122
 
123
+ def pubid
124
+ @pubid ||= begin
125
+ nt = doc.at("./normtitle").text
126
+ RawbibIdParser.parse(nt)
127
+ end
128
+ end
129
+
123
130
  #
124
131
  # Parse docnumber
125
132
  #
126
133
  # @return [String] PubID
127
134
  #
128
135
  def docnumber
129
- @docnumber ||= doc.at("./publicationinfo/stdnumber").text
136
+ @docnumber ||= pubid&.to_id # doc.at("./publicationinfo/stdnumber").text
130
137
  end
131
138
 
132
139
  #
@@ -223,7 +230,8 @@ module RelatonIeee
223
230
  if (ref = fetcher.backrefs[r.text])
224
231
  rel = fetcher.create_relation(r[:type], ref)
225
232
  rels << rel if rel
226
- elsif !/Inactive Date/.match?(r) then fetcher.add_crossref(docnumber, r)
233
+ elsif !/Inactive Date/.match?(r) && docnumber
234
+ fetcher.add_crossref(docnumber, r)
227
235
  end
228
236
  end
229
237
  RelatonBib::DocRelationCollection.new rels
@@ -0,0 +1,149 @@
1
+ module RelatonIeee
2
+ class PubId
3
+ class Id
4
+ # @return [String]
5
+ attr_reader :number
6
+
7
+ # @return [String, nil]
8
+ attr_reader :publisher, :stage, :part, :status, :approval, :edition,
9
+ :draft, :rev, :corr, :amd, :redline, :year, :month
10
+
11
+ #
12
+ # PubId constructor
13
+ #
14
+ # @param [String] number
15
+ # @param [<Hash>] **args
16
+ # @option args [String] :number
17
+ # @option args [String] :publisher
18
+ # @option args [String] :stage
19
+ # @option args [String] :part
20
+ # @option args [String] :status
21
+ # @option args [String] :approval
22
+ # @option args [String] :edition
23
+ # @option args [String] :draft
24
+ # @option args [String] :rev
25
+ # @option args [String] :corr
26
+ # @option args [String] :amd
27
+ # @option args [Boolean] :redline
28
+ # @option args [String] :year
29
+ # @option args [String] :month
30
+ #
31
+ def initialize(number:, **args) # rubocop:disable Metrics/MethodLength
32
+ @publisher = args[:publisher]
33
+ @stage = args[:stage]
34
+ @number = number
35
+ @part = args[:part]
36
+ @status = args[:status]
37
+ @approval = args[:approval]
38
+ @edition = args[:edition]
39
+ @draft = args[:draft]
40
+ @rev = args[:rev]
41
+ @corr = args[:corr]
42
+ @amd = args[:amd]
43
+ @year = args[:year]
44
+ @month = args[:month]
45
+ @redline = args[:redline]
46
+ end
47
+
48
+ #
49
+ # PubId string representation
50
+ #
51
+ # @return [String]
52
+ #
53
+ def to_s # rubocop:disable Metrics/AbcSize
54
+ out = number
55
+ out = "#{stage} #{out}" if stage
56
+ out = "#{approval} #{out}" if approval
57
+ out = "#{status} #{out}" if status
58
+ out = "#{publisher} #{out}" if publisher
59
+ out += "-#{part}" if part
60
+ out += edition_to_s + draft_to_s + rev_to_s + corr_to_s + amd_to_s
61
+ out + year_to_s + month_to_s + redline_to_s
62
+ end
63
+
64
+ def edition_to_s
65
+ edition ? "/E-#{edition}" : ""
66
+ end
67
+
68
+ def draft_to_s
69
+ draft ? "/D-#{draft}" : ""
70
+ end
71
+
72
+ def rev_to_s
73
+ rev ? "/R-#{rev}" : ""
74
+ end
75
+
76
+ def corr_to_s
77
+ corr ? "/Cor#{corr}" : ""
78
+ end
79
+
80
+ def amd_to_s
81
+ amd ? "/Amd#{amd}" : ""
82
+ end
83
+
84
+ def year_to_s
85
+ year ? ".#{year}" : ""
86
+ end
87
+
88
+ def month_to_s
89
+ month ? "-#{month}" : ""
90
+ end
91
+
92
+ def redline_to_s
93
+ redline ? " Redline" : ""
94
+ end
95
+ end
96
+
97
+ # @return [Array<RelatonIeee::PubId::Id>]
98
+ attr_reader :pubid
99
+
100
+ #
101
+ # IEEE publication id
102
+ #
103
+ # @param [Array<Hash>, Hash] pubid
104
+ #
105
+ def initialize(pubid)
106
+ @pubid = array(pubid).map { |id| Id.new(**id) }
107
+ end
108
+
109
+ #
110
+ # Convert to array
111
+ #
112
+ # @param [Array<Hash>, Hash] pid
113
+ #
114
+ # @return [Array<Hash>]
115
+ #
116
+ def array(pid)
117
+ pid.is_a?(Array) ? pid : [pid]
118
+ end
119
+
120
+ #
121
+ # PubId string representation
122
+ #
123
+ # @return [String]
124
+ #
125
+ def to_s
126
+ pubid.map(&:to_s).join("/")
127
+ end
128
+
129
+ #
130
+ # Generate ID without publisher and second number
131
+ #
132
+ # @return [String]
133
+ #
134
+ def to_id # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
135
+ out = pubid[0].to_s
136
+ if pubid.size > 1
137
+ out += pubid[1].edition_to_s if pubid[0].edition.nil?
138
+ out += pubid[1].draft_to_s if pubid[0].draft.nil?
139
+ out += pubid[1].rev_to_s if pubid[0].rev.nil?
140
+ out += pubid[1].corr_to_s if pubid[0].corr.nil?
141
+ out += pubid[1].amd_to_s if pubid[0].amd.nil?
142
+ out += pubid[1].year_to_s if pubid[0].year.nil?
143
+ out += pubid[1].month_to_s if pubid[0].month.nil?
144
+ out += pubid[1].redline_to_s unless pubid[0].redline
145
+ end
146
+ out
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,515 @@
1
+ require "relaton_ieee/pub_id"
2
+
3
+ module RelatonIeee
4
+ module RawbibIdParser
5
+ STAGES = 'DIS\d?|PSI|FCD|FDIS|CD\d?|Pub2|CDV|TS|SI'.freeze
6
+ APPROVAL = '(?:\s(Unapproved|Approved))'.freeze
7
+ APPROV = '(?:\s(?:Unapproved|Approved))?'.freeze
8
+ STD = "(?:\s(?i)Std\.?(?-i))?".freeze
9
+
10
+ #
11
+ # Parse normtitle
12
+ #
13
+ # @param [String] normtitle <description>
14
+ #
15
+ # @return [RelatonIeee::PubId, nil]
16
+ #
17
+ def parse(normtitle) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
18
+ case normtitle
19
+ # when "2012 NESC Handbook, Seventh Edition" then "NESC HBK ED7.2012"
20
+ # when "2017 NESC(R) Handbook, Premier Edition" then "NESC HBK ED1.2017"
21
+ # when "2017 National Electrical Safety Code(R) (NESC(R)) - Redline" then "NESC C2R.2017"
22
+ # when "2017 National Electrical Safety Code(R) (NESC(R))" then "NESC C2.2017"
23
+ # when /^(\d+HistoricalData)-(\d{4})/ then "IEEE #{$1}.#{$2}"
24
+ # when /^(\d+)\.(\w+)\sBattery\sLife\sImprovement/ then "IEEE #{$1}-#{$2}"
25
+ # when /^(\d+)\.(\w+)-(\d{4})\s\(Amendment/ then "IEEE #{$1}-#{$2}.#{$3}"
26
+ when "A.I.E.E. No. 15 May-1928" then PubId.new(publisher: "AIEE", number: "15", year: "1928", month: "05")
27
+ # when "AIEE Nos 72 and 73 - 1932" then "AIEE 72_73.1932"
28
+ when "IEEE Std P1073.1.3.4/D3.0" then PubId.new(publisher: "IEEE", number: "P11073", part: "00101") # "IEEE P11073-00101"
29
+ # when "P1073.1.3.4/D3.0" then PubId.new(publisher: "IEEE", number: "P1073", part: "1-3-4", draft: "3.0") # "IEEE P1073-1-3-4/D3.0"
30
+ when "IEEE P1073.2.1.1/D08" then PubId.new(publisher: "ISO/IEEE", number: "P1073", part: "2-1-1", draft: "08") # "ISO/IEEE P1073-2-1-1/D08"
31
+ when "IEEE P802.1Qbu/03.0, July 2015" # "IEEE P802.1Qbu/D3.0.2015"
32
+ PubId.new(publisher: "IEEE", number: "P802", part: "1Qbu", draft: "3.0", year: "2015")
33
+ when "IEEE P11073-10422/04, November 2015" # "IEEE P11073-10422/D04.2015"
34
+ PubId.new(publiisher: "IEEE", number: "P11073", part: "10422", draft: "04", year: "2015")
35
+ when "IEEE P802.11aqTM/013.0 October 2017" # "IEEE P802-11aqTM/D13.0.2017"
36
+ PubId.new(publisher: "IEEE", number: "P802", part: "11aqTM", draft: "13.0", year: "2017")
37
+ when "IEEE P844.3/C22.2 293.3/D0, August 2018" # "IEEE P844-3/C22.2-293.3/D0.2018"
38
+ PubId.new([{ publisher: "IEEE", number: "P844", part: "3" },
39
+ { number: "C22.2", part: "293.3", dtaft: "0", year: "2018" }])
40
+ when "IEEE P844.3/C22.2 293.3/D1, November 2018" # "IEEE P844.3/C22.2 293.3/D1.2018"
41
+ PubId.new([{ publisher: "IEEE", number: "P844", part: "3" },
42
+ { number: "C22.2", part: "293.3", draft: "1", year: "2018" }])
43
+ when "AIEE No 431 (105) -1958" then PubId.new(publisher: "AIEE", number: "431", year: "1958") # "AIEE 431.1958"
44
+ when "IEEE 1076-CONC-I99O" then PubId.new(publisher: "IEEE", number: "1076", year: "199O") # "IEEE 1076.199O"
45
+ when "IEEE Std 960-1993, IEEE Std 1177-1993" # "IEEE 960/1177.1993"
46
+ PubId.new([{ publisher: "IEEE", number: "960" }, { number: "1177", year: "1993" }])
47
+ when "IEEE P802.11ajD8.0, August 2017" # "IEEE P802-11aj/D8.0.2017"
48
+ PubId.new(publisher: "IEEE", number: "P802", part: "11aj", draft: "8.0", year: "2017")
49
+ when "IEEE P802.11ajD9.0, November 2017" # "IEEE P802-11aj/D9.0.2017"
50
+ PubId.new(publisher: "IEEE", number: "P802", part: "11aj", draft: "9.0", year: "2017")
51
+ when "ISO/IEC/IEEE P29119-4-DISMay2013" # "ISO/IEC/IEEE DIS P29119-4.2013"
52
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P29119", part: "4", year: "2013")
53
+ when "IEEE-P15026-3-DIS-January 2015" # "IEEE DIS P15026-3.2015"
54
+ PubId.new(publisher: "IEEE", stage: "DIS", number: "P15026", year: "2015")
55
+ when "ANSI/IEEE PC63.7/D rev17, December 2014" # "ANSI/IEEE PC63-7/D/REV-17.2014"
56
+ PubId.new(publusher: "ANSI/IEEE", number: "PC63", part: "7", draft: "", rev: "17", year: "2014")
57
+ when "IEC/IEEE P62271-37-013:2015 D13.4" # "IEC/IEEE P62271-37-013/D13.4.2015"
58
+ PubId.new(publisher: "IEC/IEEE", number: "P62271", part: "37-013", draft: "13.4", year: "2015")
59
+ when "PC37.30.2/D043 Rev 18, May 2015" # "IEEE PC37-30-2/D043/REV-18.2015"
60
+ PubId.new(publisher: "IEEE", number: "PC37", part: "30-2", draft: "043", rev: "18", year: "2015")
61
+ when "IEC/IEEE FDIS 62582-5 IEC/IEEE 2015" # "IEC/IEEE FDIS 62582-5.2015"
62
+ PubId.new(publisher: "IEC/IEEE", stage: "FDIS", number: "62582", part: "5", year: "2015")
63
+ when "ISO/IEC/IEEE P15289:2016, 3rd Ed FDIS/D2" # "ISO/IEC/IEEE FDIS P15289/E3/D2.2016"
64
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "FDIS", number: "P15289", part: "", edition: "3", draft: "2", year: "2016")
65
+ when "IEEE P802.15.4REVi/D09, April 2011 (Revision of IEEE Std 802.15.4-2006)"
66
+ PubId.new(publisher: "IEEE", number: "P802", part: "15.4", rev: "i", draft: "09", year: "2013", month: "04", approval: true)
67
+ when "Draft IEEE P802.15.4REVi/D09, April 2011 (Revision of IEEE Std 802.15.4-2006)"
68
+ PubId.new(publisher: "IEEE", number: "P802", part: "15.4", rev: "i", draft: "09", year: "2011", month: "04")
69
+ when "ISO/IEC/IEEE DIS P42020:201x(E), June 2017"
70
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P42020", year: "2017", month: "06")
71
+ when "IEEE/IEC P62582 CD2 proposal, May 2017"
72
+ PubId.new(publisher: "IEEE/IEC", number: "P62582", stage: "CD2", year: "2017", month: "05")
73
+ when "ISO/IEC/IEEE P16326:201x WD.4a, July 2017"
74
+ PubId.new(publisher: "ISO/IEC/IEEE", number: "P16326", draft: "4a", year: "2017", month: "07")
75
+ when "ISO/IEC/IEEE CD.1 P21839, October 2017"
76
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "CD1", number: "P21839", year: "2017", month: "10")
77
+ when "IEEE P3001.2/D5, August 2017"
78
+ PubId.new(publisher: "IEEE", number: "P3001", part: "2", draft: "5", year: "2017", month: "01")
79
+ when "P3001.2/D5, August 2017"
80
+ PubId.new(publisher: "IEEE", number: "P3001", part: "2", draft: "5", year: "2017", month: "12")
81
+ when "ISO/IEC/IEEE P16326:201x WD5, December 2017"
82
+ PubId.new(publisher: "ISO/IEC/IEEE", number: "P16326", draft: "5", year: "2017", month: "12")
83
+ when "ISO/IEC/IEEE DIS P16326/201x, December 2018"
84
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P16326", year: "2018", month: "12")
85
+ when "ISO/IEC/IEEE/P21839, 2019(E)"
86
+ PubId.new(publisher: "ISO/IEC/IEEE", number: "P21839", year: "2019")
87
+ when "ISO/IEC/IEEE P42020/V1.9, August 2018"
88
+ PubId.new(publisher: "ISO/IEC/IEEE", number: "P42020", year: "2018", month: "08")
89
+ when "ISO/IEC/IEEE CD2 P12207-2: 201x(E), February 2019"
90
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "CD2", number: "P12207", part: "2", year: "2019", month: "02")
91
+ when "ISO/IEC/IEEE P42010.WD4:2019(E)"
92
+ PubId.new(publisher: "ISO/IEC/IEEE", number: "P42010", draft: "4", year: "2019")
93
+ when "IEC/IEEE P63195_CDV/V3, February 2020"
94
+ PubId.new(publisher: "IEC/IEEE", number: "P63195", stage: "CDV", year: "2020", month: "02")
95
+ when "ISO /IEC/IEEE P24774_D1, February 2020"
96
+ PubId.new(publisher: "ISO/IEC/IEEE", number: "P24774", draft: "1", year: "2020", month: "02")
97
+ when "IEEE/ISO/IEC P42010.CD1-V1.0, April 2020"
98
+ PubId.new(publisher: "IEEE/ISO/IEC", number: "P42010", stage: "CD1", year: "2020", month: "04")
99
+ when "ISO/IEC/IEEE/P16085_DIS, March 2020"
100
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P16085", year: "2020", month: "03")
101
+ when "ISO /IEC/IEEE P24774/DIS, July 2020"
102
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P24774", year: "2020", month: "07")
103
+ when "ANSI/ IEEE C37.23-1969" then PubId.new(publisher: "ANSI/IEEE", number: "C37", part:"23", year: "1969")
104
+ when "ANSI/IEEE Std: Outdoor Apparatus Bushings"
105
+ PubId.new(publisher: "ANSI/IEEE", number: "21", year: "1976", month: "11")
106
+ when "ANSI/ IEEE C37.5-1979" then PubId.new(publisher: "ANSI/IEEE", number: "C37", part:"5", year: "1979")
107
+ when "Unapproved Draft Std ISO/IEC FDIS 15288:2007(E) IEEE P15288/D3,"
108
+ PubId.new(publisher: "ISO/IEC/IEEE", stage: "FDIS", number: "P15288", draft: "3", year: "2007")
109
+ when "Draft National Electrical Safety Code, January 2016"
110
+ PubId.new(publisher: "IEEE", number: "PC2", year: "2016", month: "01")
111
+ when "ANSI/ IEEE C62.1-1981 (Revision of IEEE Std 28-1974 and ANSI C62.1-1975)"
112
+ PubId.new(publisher: "ANSI/IEEE", number: "C62", part: "1", year: "1981")
113
+ when "ANSI/IEEE-ANS-7-4.3.2-1982" then PubId.new(publisher: "ANSI/IEEE/ANS", number: "7", part: "4-3-2", year: "1982")
114
+ when "IEEE Unapproved Draft Std P802.1AB/REVD2.2, Dec 2007" # "IEEE P802.1AB/REV/D2.2.2007"
115
+ PubId.new(publisher: "IEEE", number: "P802", part: "1AB", rev: "", draft: "2.2", year: "2007", month: "12")
116
+
117
+ # drop all with <standard_id>0</standard_id>
118
+ # when "IEEE Std P1671/D5, June 2006", "IEEE Std PC37.100.1/D8, Dec 2006",
119
+ # "IEEE Unapproved Draft Std P1578/D17, Mar 2007", "IEEE Approved Draft Std P1115a/D4, Feb 2007",
120
+ # "IEEE Std P802.16g/D6, Nov 06", "IEEE Unapproved Draft Std P1588_D2.2, Jan 2008",
121
+ # "IEEE Unapproved Std P90003/D1, Feb 2007.pdf", "IEEE Unapproved Draft Std PC37.06/D10 Dec 2008",
122
+ # "IEEE P1451.2/D20, February 2011", "IEEE Std P1641.1/D3, July 2006",
123
+ # "IEEE P802.1AR-Rev/D2.2, September 2017 (Draft Revision of IEEE Std 802.1AR\u20132009)",
124
+ # "IEEE Std 108-1955; AIEE No.450-April 1955", "IEEE Std 85-1973 (Revision of IEEE Std 85-1965)",
125
+ # "IEEE Std 1003.1/2003.l/lNT, March 1994 Edition" then nil
126
+
127
+ # publisher1, number1, part1, publisher2, number2, part2, draft, year
128
+ when /^([A-Z\/]+)\s(\w+)[-.](\d+)\/(\w+)\s(\w+)[-.](\d+)_D([\d.]+),\s\w+\s(\d{4})/
129
+ PubId.new([{ publisher: $1, number: $2, part: $3 },
130
+ { publisher: $4, number: $5, part: $6, draft: dn($7), year: $8 }])
131
+
132
+ # publisher1, number1, part1, number2, part2, draft, year, month
133
+ when /^([A-Z\/]+)\s(\w+)[.-]([\w.-]+)\/(\w+)[.-]([[:alnum:].-]+)[\/_]D([\w.]+),\s(\w+)\s(\d{4})/
134
+ PubId.new([{ publisher: $1, number: $2, part: sp($3) }, { number: $4, part: sp($5), draft: dn($6), year: $8, month: mn($7) }])
135
+
136
+ # publisher, approval, number, part, corrigendum, draft, year
137
+ when /^([A-Z\/]+)#{APPROVAL}(?:\sDraft)?\sStd\s(\w+)\.(\d+)-\d{4}[^\/]*\/Cor\s?(\d)\/(D[\d\.]+),\s(?:\w+\s)?(\d{4})/o
138
+ PubId.new(publisher: $1, approval: $2, number: $3, part: sp($4), corr: $5, draft: dn($6), year: $7)
139
+
140
+ # publisher, number, part, corrigendum, draft, year, month
141
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.(\w+)-\d{4}\/Cor\s?(\d(?:-\d+x)?)[\/_]D([\d\.]+),\s?(\w+)\s(\d{4})/o
142
+ PubId.new(publisher: $1, number: $2, part: $3, corr: $4, draft: dn($5), month: mn($6), year: $7)
143
+
144
+ # publidsher1, number1, year1 publisher2, number2, draft, year2
145
+ when /^([A-Z\/]+)\s(\w+)-(\d{4})\/([A-Z]+)\s([[:alnum:]]+)_D([\w.]+),\s(\d{4})/
146
+ PubId.new([{ publisher: $1, number: $2, year: $3 }, { publisher: $4, number: $5, draft: dn($6), year: $7 }])
147
+
148
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)[.-]([[:alnum:].-]+)[\s\/_]ED([\w.]+),\s(\w+)\s(\d{4})/o
149
+ PubId.new(publisher: $1, stage: $2, number: $3, part: sp($4), edition: $5, month: mn($6), year: $7)
150
+
151
+ # publidsher1, number1, publisher2, number2, draft, year
152
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\/([A-Z]+)\s([[:alnum:]]+)_D([\d\.]+),\s\w+\s(\d{4})/o,
153
+ /^([A-Z\/]+)\s(\w+)\sand\s([A-Z]+)(?:\sGuideline)?\s([[:alnum:]]+)\/D([\d\.]+),\s\w+\s(\d{4})/o
154
+ PubId.new([{ publisher: $1, number: $2 }, { publisher: $3, number: $4, draft: dn($5), year: $6 }])
155
+
156
+ # publidsher1, number1, part, publisher2, number2, year
157
+ when /^([A-Z\/]+)\s(\w+)\.(\d+)_(\w+)\s(\w+),\s(\d{4})/ # "#{$1} #{$2}-#{$3}/#{$4} #{$5}.#{$6}"
158
+ PubId.new([{ publisher: $1, number: $2, part: $3 }, { publisher: $4, number: $5, year: $6 }])
159
+
160
+ # publisher, number1, part1, number2, part2, draft
161
+ when /^([A-Z\/]+)\s(\w+)[.-](\d+)\/(\w+)\.(\d+)[\/_]D([\d.]+)/ # "#{$1} #{$2}-#{$3}/#{$4}-#{$5}/D#{$6}"
162
+ PubId.new([{ publisher: $1, number: $2, part: $3 }, { number: $4, part: $5, draft: dn($6) }])
163
+
164
+ # publidsher, number1, part1, number2, part2, year
165
+ when /^([A-Z\/]+)\sStd\s(\w+)\.(\w+)\/(\w+)\.(\w+)\/INT\s\w+\s(\d{4})/
166
+ PubId.new([{ publisher: $1, number: $2, part: $3 }, { number: $4, part: $5, year: $6 }])
167
+
168
+ # publisher, number, part, corrigendum, draft, year
169
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-]([\d-]+)\/Cor\s?(\d)[\/_]D([\d\.]+),\s(?:\w+\s)?(\d{4})/o,
170
+ /^([A-Z\/]+)\s(\w+)[.-](\d+)-\d{4}\/Cor\s?(\d)(?:-|,\s|\/)D([\d.]+),?\s\w+\s(\d{4})/,
171
+ /^([A-Z\/]+)\s(\w+)\.([[:alnum:].]+)[-_]Cor[\s-]?(\d)\/D([\d.]+),?\s\w+\s(\d{4})/
172
+ PubId.new(publisher: $1, number: $2, part: sp($3), corr: $4, draft: dn($5), year: $6)
173
+ when /^([A-Z\/]+)\s(\w+)\.(\d+)-\d{4}\/Cor(\d)-(\d{4})\/D([\d.]+)/ # "#{$1} #{$2}-#{$3}/Cor#{$4}/D#{$6}.#{$5}"
174
+ PubId.new(publisher: $1, number: $2, part: $3, corr: $4, draft: dn($6), year: $5)
175
+
176
+ # publisher, status, number, part, draft, year, month
177
+ when /^([A-Z\/]+)(\sActive)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-]([[:alnum:]\.]+)\s?[\/_]D([\w\.]+),?\s(\w+)(?:\s\d{1,2},)?\s?(\d{2,4})/o
178
+ PubId.new(publisher: $1, status: $2, number: $3, part: sp($4), draft: dn($5), year: $7, month: mn($6))
179
+
180
+ # publisher, approval, number, part, draft, year, month
181
+ when /^([A-Z\/]+)(?:\sActive)?#{APPROVAL}(?:\sDraft)?#{STD}\s(\w+)[.-]([[:alnum:]\.]+)\s?[\/_]D([\w\.-]+),?\s(\w+)(?:\s\d{1,2},)?\s?(\d{2,4})/o
182
+ PubId.new(publisher: $1, approval: $2, number: $3, part: sp($4), draft: dn($5), year: $7, month: mn($6))
183
+ when /^([A-Z\/]+)\s(\w+)\.([\w.]+)\/D([\w.]+),?\s(\w+)[\s_](\d{4})(?:\s-\s\(|\s\(|_)(Unapproved|Approved)/
184
+ PubId.new(publisher: $1, number: $2, part: sp($3), draft: dn($4), year: $6, month: mn($5), approval: $7)
185
+
186
+ # publisher, approval, number, draft, year, month
187
+ when /^([A-Z\/]+)\s(\w+)\/D([\w.]+),\s(\w+)\s(\d{4})\s-\s\(?(Approved|Unapproved)/
188
+ PubId.new(publisher: $1, number: $2, draft: dn($3), year: $5, month: mn($4), approval: $6)
189
+
190
+ # publisher, approval, number, part, draft, year
191
+ when /^([A-Z\/]+)#{APPROVAL}(?:\sDraft)?#{STD}\s(\w+)[.-]([\w.]+)\s?[\/_\s]D([\w\.]+),?\s\w+\s?(\d{4})/o
192
+ PubId.new(publisher: $1, approval: $2, number: $3, part: sp($4), draft: dn($5), year: $6)
193
+ when /^([A-Z\/]+)\s(\w+)\.([\w.]+)\/D([\d.]+),?\s\w+[\s_](\d{4})(?:\s-\s\(|_|\s\()?#{APPROVAL}/o
194
+ PubId.new(publisher: $1, number: $2, part: sp($3), draft: dn($4), year: $5, approval: $6)
195
+
196
+ # publisher, stage, number, part, edition, year, month
197
+ when /^([A-Z\/]+)\s(\w+)[.-]([[:alnum:].-]+)[\/_](#{STAGES})\s(\w+)\sedition,\s(\w+)\s(\d{4})/o
198
+ PubId.new(publisher: $1, number: $2, part: sp($3), stage: $4, edition: en($5), month: mn($6), year: $7)
199
+
200
+ # number, part, corrigendum, draft, year
201
+ when /^(\w+)\.([\w.]+)-\d{4}[_\/]Cor\s?(\d)\/D([\w.]+),?\s\w+\s(?:\d{2},\s)?(\d{4})/
202
+ PubId.new(number: $1, part: sp($2), corr: $3, draft: dn($4), year: $5)
203
+
204
+ # publisher, approval, number, part, draft
205
+ when /^([A-Z\/]+)\s(\w+)\.(\d+)\/D([\d.]+)\s\([^)]+\)\s-#{APPROVAL}/o
206
+ PubId.new(publisher: $1, approval: $5, number: $2, part: $3, draft: dn($4))
207
+
208
+ # publisher, number, part1, rev, draft, part2
209
+ when /^([A-Z\/]+)#{STD}\s(\w+)\.([\d.]+)REV([a-z]+)_D([\w.]+)\sPart\s(\d)/o
210
+ PubId.new(publisher: $1, number: $2, part: "#{sp($3)}-#{$6}", rev: $4, draft: dn($5))
211
+
212
+ # publisher, number, part, draft, year, month
213
+ when /^([A-Z\/]+)#{STD}\s(\w+)[.-]([[:alnum:].]+)[\/\s_]D([\d.]+)(?:,?\s|_)([[:alpha:]]+)[\s_]?(\d{4})/o
214
+ PubId.new(publisher: $1, number: $2, part: sp($3), draft: dn($4), year: $6, month: mn($5))
215
+
216
+ # publisher, stage, number, part, draft, year
217
+ when /^([\w\/]+)\s(#{STAGES})\s(\w+)-([[:alnum:]]+)[\/_\s]D([\d.]+),\s\w+\s(\d{4})/o
218
+ PubId.new(publisher: $1, stage: $2, number: $3, part: sp($4), draft: dn($5), year: $6)
219
+
220
+ # publisher, number, part, rev, draft, year, month
221
+ when /^([A-Z\/]+)\s(\w+)\.([\w.]+)-Rev\/D([\w.]+),\s(\w+)\s(\d{4})/
222
+ PubId.new(publisher: $1, number: $2, part: sp($3), rev: "", draft: dn($4), year: $6, month: mn($5))
223
+
224
+ # publisher, number, part, rev, draft, year
225
+ when /^([A-Z\/]+)\s(\w+)\.([\d.]+)Rev(\w+)-D([\w.]+),\s\w+\s(\d{4})/
226
+ PubId.new(publisher: $1, number: $2, part: sp($3), rev: $4, draft: dn($5), year: $6)
227
+
228
+ # publisher, stage, number, part, edition, year
229
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)[.-]([[:alnum:].-]+)[\/\s_]ED([\d.]+),\s(\d{4})/o
230
+ PubId.new(publisher: $1, stage: $2, number: $3, part: sp($4), edition: $5, year: $6)
231
+
232
+ # publisher, stage, number, draft, year, month
233
+ when /^([A-Z\/]+)\s(\w+)\/(#{STAGES})[\/_]D([\w.]+),\s(\w+)\s(\d{4})/o
234
+ PubId.new(publisher: $1, number: $2, stage: $3, draft: dn($4), year: $6, month: mn($5))
235
+
236
+ # number, part, draft, year, month
237
+ when /(\w+)[.-]([[:alnum:].]+)[\/\s_]D([\d.]+)(?:,?\s|_)([[:alpha:]]+)[\s_]?(\d{4})/
238
+ PubId.new(publisher: "IEEE", number: $1, part: sp($2), draft: dn($3), year: $5, month: mn($4))
239
+
240
+ # number, corrigendum, draft, year, month
241
+ when /^(\w+)-\d{4}[\/_]Cor\s?(\d)[\/_]D([\w.]+),\s(\w+)\s(\d{4})/
242
+ PubId.new(publisher: "IEEE", number: $1, corr: $2, draft: dn($3), month: mn($4), year: $5)
243
+
244
+ # publisher, number, corrigendum, draft, year
245
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?\sStd\s(\w+)(?:-\d{4})?[\/_]Cor\s?(\d)\/D([\d\.]+),\s\w+\s(\d{4})/o
246
+ PubId.new(publisher: $1, number: $2, corr: $3, draft: dn($4), year: $5)
247
+
248
+ # publisher, number, part, rev, corrigendum, draft
249
+ when /^([A-Z\/]+)\s(\w+)\.(\w+)-\d{4}-Rev\/Cor(\d)\/D([\d.]+)/
250
+ PubId.new(publisher: $1, number: $2, part: $3, rev: "", corr: $4, draft: dn($5))
251
+
252
+ # publisher, number, part, corrigendum, draft
253
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.([\w.]+)\/[Cc]or\s?(\d)\/D([\w\.]+)/o,
254
+ /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.(\w+)-\d{4}\/Cor\s?(\d)[\/_]D([\d\.]+)/o
255
+ PubId.new(publisher: $1, number: $2, part: sp($3), corr: $4, draft: dn($5))
256
+
257
+ # publisher, number, part, corrigendum, year
258
+ when /^([A-Z\/]+)#{STD}\s(\w+)[.-]([\w.]+)[:-]\d{4}[\/-]Cor[\s.]?(\d)[:-](\d{4})/o
259
+ PubId.new(publisher: $1, number: $2, part: sp($3), corr: $4, year: $5)
260
+
261
+ # publisher, number, part, draft, year
262
+ when /^([\w\/]+)(?:\sActive)?#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-]([[:alnum:]\.]+)(?:\s?\/\s?|_|,\s|-)D([\w\.]+)\s?,?\s\w+(?:\s\d{1,2},)?\s?(\d{2,4})/o,
263
+ /^([A-Z\/]+)#{STD}\s(\w+)[.-]([\w.-]+)[\/\s]D([\w.]*)(?:-|,\s?\w+\s|\s\w+:|,\s)(\d{4})/o,
264
+ /^([\w\/]+)(?:\sActive)?#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-]([[:alnum:]\.]+)\sDraft\s([\w\.]+),\s\w+\s(\d{4})/o
265
+ PubId.new(publisher: $1, number: $2, part: sp($3), draft: dn($4), year: $5)
266
+
267
+ # publisher, approval, number, draft, year
268
+ when /^([A-Z\/]+)#{APPROVAL}(?:\sDraft)?#{STD}\s([[:alnum:]]+)\s?[\/_]\s?D([\w\.]+),?\s\w+\s(\d{2,4})/o
269
+ PubId.new(publisher: $1, approval: $2, number: $3, draft: dn($4), year: $5)
270
+ when /^([A-Z\/]+)\s(\w+)\/D([\d.]+),\s\w+[\s_](\d{4})(?:\s-\s\(?|_)?#{APPROVAL}/o
271
+ PubId.new(publisher: $1, number: $2, draft: dn($3), year: $4, approval: $5)
272
+
273
+ # publisher, number, part, rev, draft
274
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.([\w.]+)[-\s\/]?REV-?(\w+)\/D([\d.]+)/o
275
+ PubId.new(publisher: $1, number: $2, part: sp($3), rev: $4, draft: dn($5))
276
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.([\w.]+)-REV\/D([\d.]+)/o
277
+ PubId.new(publisher: $1, number: $2, part: sp($3), rev: "", draft: dn($4))
278
+
279
+ # publisher, number, part, rev, year
280
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?\sStd\s(\w+)\.(\d+)\/rev(\d+),\s\w+\s(\d+)/o
281
+ PubId.new(publisher: $1, number: $2, part: sp($3), rev: $4, year: $5)
282
+
283
+ # publisher, stage, number, draft, year
284
+ when /^([\w\/]+)\s(#{STAGES})\s([[:alnum:]]+)[\/_]D([\w.]+),(?:\s\w+)?\s(\d{4})/o
285
+ PubId.new(publisher: $1, stage: $2, number: $3, draft: dn($4), year: $5)
286
+
287
+ # publisher, stage, number, part, year, month
288
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-]([[:alnum:].-]+)(?:[\/_-]|,\s)(#{STAGES}),?\s(\w+)\s(\d{4})/o
289
+ PubId.new(publisher: $1, number: $2, part: sp($3), stage: $4, year: $6, month: mn($5))
290
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)[.-](\w+),\s(\w+)\s(\d{4})/o
291
+ PubId.new(publisher: $1, number: $3, part: sp($4), stage: $2, year: $6, month: mn($5))
292
+
293
+ # publisher, number, part, edition, year, month
294
+ when /^([A-Z\/]+)\s(\w+)[.-]([\w.-]+)[\/\s]ED([\d+]),\s(\w+)\s(\d{4})/
295
+ PubId.new(publisher: $1, number: $2, part: sp($3), edition: $4, month: mn($5), year: $6)
296
+
297
+ # publisher, stage, number, part, year
298
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-](\d+)[\/_-](#{STAGES}),?\s\w+\s(\d{4})/o,
299
+ /^([A-Z\/]+)\s(\w+)-(\d+)[\/-](#{STAGES})(?:_|,\s|-)\w+\s?(\d{4})/o,
300
+ /^([A-Z\/]+)\s(\w+)[.-](\d+)[\/-_](#{STAGES})[\s-](\d{4})/o
301
+ PubId.new(publisher: $1, number: $2, part: sp($3), stage: $4, year: $5)
302
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)-([\w-]+),\s(\d{4})/o
303
+ PubId.new(publisher: $1, number: $3, part: sp($4), stage: $2, year: $5)
304
+
305
+ # publisher, stage, number, year, month
306
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)(?:\s\g<2>)?,\s(\w+)\s(\d{4})/o
307
+ PubId.new(publisher: $1, number: $3, stage: $2, year: $5, month: mn($4))
308
+ when /^([A-Z\/]+)\s([[:alnum:]]+)(?:\s|_|\/\s?)?(#{STAGES}),?\s(\w+)\s(\d{4})/o
309
+ PubId.new(publisher: $1, number: $2, stage: $3, year: $5, month: mn($4))
310
+
311
+ # publisher, stage, number, part, draft
312
+ when /^([A-Z\/]+)[.-]([[:alnum:].-]+)[\/_]D([[:alnum:].]+)[\/_](#{STAGES})/o
313
+ PubId.new(publisher: "IEEE", number: $1, part: sp($2), draft: dn($3), stage: $4)
314
+
315
+ # publisher, stage, number, year
316
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)(?:,\s\w+\s|:)(\d{4})/o
317
+ PubId.new(publisher: $1, number: $3, stage: $2, year: $4)
318
+ when /^([A-Z\/]+)\s(\w+)(?:\/|,\s)(#{STAGES})-(\d{4})/o
319
+ PubId.new(publisher: $1, number: $2, stage: $3, year: $4)
320
+
321
+ # publisher, stage, number, part
322
+ when /^([A-Z\/]+)\s(\w+)-([\w-]+)[\s-](#{STAGES})/o
323
+ PubId.new(publisher: $1, number: $2, part: $3, stage: $4)
324
+ when /^([A-Z\/]+)\s(\w+)-(#{STAGES})-(\w+)/o
325
+ PubId.new(publisher: $1, number: $2, part: $4, stage: $3)
326
+ when /^([A-Z\/]+)\s(#{STAGES})\s(\w+)[.-]([[:alnum:].-]+)/o
327
+ PubId.new(publisher: $1, number: $3, part: sp($4), stage: $2)
328
+
329
+ # publisher, number, corrigendum, year
330
+ when /^([A-Z\/]+)#{STD}\s(\w+)-\d{4}\/Cor\s?(\d)-(\d{4})/o
331
+ PubId.new(publisher: $1, number: $2, corrigendum: $3, year: $4)
332
+
333
+ # publisher, number, rev, draft
334
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)-REV\/D([\d.]+)/o
335
+ PubId.new(publisher: $1, number: $2, rev: "", draft: dn($3))
336
+
337
+ # publisher, number, part, year, month
338
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)-([\w-]+),\s(\w+)\s?(\d{4})/o,
339
+ /^([A-Z\/]+)\sStd\s(\w+)\.(\w+)-\d{4}\/INT,?\s(\w+)\.?\s(\d{4})/
340
+ PubId.new(publisher: $1, number: $2, part: sp($3), year: $5, month: mn($4))
341
+
342
+ # publisher, number, part, amendment, year
343
+ when /^([A-Z\/]+)#{STD}\s(\w+)-(\w+)[:-](\d{4})\/Amd(?:\s|.\s?)?(\d)/o
344
+ PubId.new(publisher: $1, number: $2, part: sp($3), amd: $5, year: $4)
345
+
346
+ # publisher, number, part, year, redline
347
+ when /^([A-Z\/]+)#{STD}\s(\w+)[.-]([\w.]+)[:-](\d{4}).*?\s-\s(Redline)/o,
348
+ /^([A-Z\/]+)#{STD}\s(\w+)[.-]([\w.-]+):(\d{4}).*?\s-\s(Redline)/o
349
+ PubId.new(publisher: $1, number: $2, part: $3, year: $4, redline: true)
350
+
351
+ # publisher, number, part, year
352
+ when /^([A-Z\/]+)\s(\w+)-(\d{1,3}),\s\w+\s(\d{4})/,
353
+ /^([A-Z\/]+)#{STD}\s(\w+)[.-](?!(?:19|20)\d{2}\D)([\w.]+)(?:,\s\w+\s|-|:|,\s|\.|:)(\d{4})/o,
354
+ /^([A-Z\/]+)#{STD}\s(\w+)[.-](?!(?:19|20)\d{2}\D)([\w.-]+)(?:,\s\w+\s|:|,\s|\.|:)(\d{4})/o,
355
+ /^([A-Z\/]+)#{STD}\sNo(?:\.?\s|\.)(\w+)\.(\d+)\s?-(?:\w+\s)?(\d{4})/o
356
+ PubId.new(publisher: $1, number: $2, part: sp($3), year: $4)
357
+
358
+ # publisher, number, edition, year
359
+ when /^([A-Z\/]+)\s(\w+)\s(\w+)\sEdition,\s\w+\s(\d+)/,
360
+ /^([A-Z\/]+)\s(\w+)[\/_]ED([\d.]+),\s(\d{4})/
361
+ PubId.new(publisher: $1, number: $2, edition: en($3), year: $4)
362
+
363
+ # publisher, number, part, conformance, draft
364
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.([[:alnum:].]+)[\/-]Conformance(\d+)[\/_]D([\w\.]+)/o
365
+ PubId.new(publisher: $1, number: $2, part: "#{sp($3)}-#{$4}", draft: dn($5))
366
+
367
+ # publisher, number, part, conformance, year
368
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.([[:alnum:].]+)\s?\/\s?Conformance(\d+)-(\d{4})/o
369
+ PubId.new(publisher: $1, number: $2, part: "#{sp($3)}-#{$4}", year: $5)
370
+
371
+ # publisher, number, part, draft
372
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\.([[:alnum:].]+)[^\/]*\/D([[:alnum:]\.]+)/o,
373
+ /^([A-Z\/]+)\s(\w+)[.-]([[:alnum:]-]+)[\s_]D([\d.]+)/,
374
+ /^([A-Z\/]+)\s(\w+)-(\w+)\/D([\w.]+)/
375
+ PubId.new(publisher: $1, number: $2, part: sp($3), draft: dn($4))
376
+
377
+ # number, part, draft, year
378
+ when /^(\w+)[.-]([[:alnum:].-]+)(?:\/|,\s|_)D([\d.]+),?\s(?:\w+,?\s)?(\d{4})/
379
+ PubId.new(publisher: "IEEE", number: $1, part: sp($2), draft: dn($3), year: $4)
380
+
381
+ # publisher, number, draft, year, month
382
+ when /^([A-Z\/]+)\s(\w+)\/D([\d.]+),\s(\w+)\s(\d{4})/
383
+ PubId.new(publisher: $1, number: $2, draft: dn($3), year: $5, month: mn($4))
384
+
385
+ # publisher, number, draft, year
386
+ when /^([\w\/]+)(?:\sActive)?#{APPROV}(?:\sDraft)?#{STD}\s([[:alnum:]]+)\s?[\/_]\s?D([\w\.-]+),?\s(?:\w+\s)?(\d{2,4})/o,
387
+ /^([\w\/]+)(?:\sActive)?#{APPROV}(?:\sDraft)?#{STD}\s([[:alnum:]]+)\/?D?([\d\.]+),?\s\w+\s(\d{4})/o,
388
+ /^([A-Z\/]+)\s(\w+)\/Draft\s([\d.]+),\s\w+\s(\d{4})/
389
+ PubId.new(publisher: $1, number: $2, draft: dn($3), year: yn($4))
390
+ when /^([A-Z\/]+)\sStd\s(\w+)-(\d{4})\sDraft\s([\d.]+)/
391
+ PubId.new(publisher: $1, number: $2, draft: dn($4), year: $3)
392
+
393
+ # publisher, approval, number, draft
394
+ when /^([A-Z\/]+)#{APPROVAL}(?:\sDraft)?#{STD}\s([[:alnum:]]+)[\/_]D([\w.]+)/o
395
+ PubId.new(publisher: $1, approval: $2, number: $3, draft: dn($4))
396
+
397
+ # number, draft, year
398
+ when /^(\w+)\/D([\w.+]+),?\s\w+,?\s(\d{4})/
399
+ PubId.new(publisher: "IEEE", number: $1, draft: dn($2), year: $3)
400
+
401
+ # number, rev, draft
402
+ when /^(\w+)-REV\/D([\d.]+)/o
403
+ PubId.new(publisher: "IEEE", number: $1, rev: "", draft: dn($2))
404
+
405
+ # publisher, number, draft
406
+ when /^([\w\/]+)#{APPROV}(?:\sDraft)?#{STD}\s([[:alnum:]]+)[\/_]D([\w.]+)/o
407
+ PubId.new(publisher: $1, number: $2, draft: dn($3))
408
+
409
+ # publisher, number, year, month
410
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)(?:-\d{4})?,\s(\w+)\s(\d{4})/o
411
+ PubId.new(publisher: $1, number: $2, year: $4, month: mn($3))
412
+
413
+ # publisher, number, year, redline
414
+ when /^([A-Z\/]+)#{STD}\s(\w+)[:-](\d{4}).*?\s-\s(Redline)/o
415
+ PubId.new(publisher: $1, number: $2, year: $3, redline: true)
416
+
417
+ # publisher, number, year
418
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)(?:-|:|,\s(?:\w+\s)?)(\d{2,4})/o,
419
+ /^(\w+)#{APPROV}(?:\sDraft)?\sStd\s(\w+)\/\w+\s(\d{4})/o,
420
+ /^([\w\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)\/FCD-\w+(\d{4})/o,
421
+ /^(\w+)#{STD}\sNo(?:\.?\s|\.)(\w+)\s?(?:-|,\s)(?:\w+\s)?(\d{4})/o,
422
+ /^([A-Z\/]+)\sStd\s(\w+)\/INT-(\d{4})/
423
+ PubId.new(publisher: $1, number: $2, year: yn($3))
424
+ when /^ANSI\/\sIEEE#{STD}\s(\w+)-(\d{4})/o
425
+ PubId.new(publisher: "ANSI/IEEE", number: $1, year: $2)
426
+
427
+ # publisher, number, part
428
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}\s(\w+)[.-]([\d.]+)/o
429
+ PubId.new(publisher: $1, number: $2, part: sp($3))
430
+
431
+ # number, part, draft
432
+ when /^(\w+)\.([\w.]+)\/D([\w.]+)/
433
+ PubId.new(publisher: "IEEE", number: $1, part: sp($2), draft: dn($3))
434
+
435
+ # number, part, year
436
+ when /^(\d{2})\sIRE\s(\w+)[\s.](\w+)/ # "IRE #{$2}-#{$3}.#{yn $1}"
437
+ PubId.new(publisher: "IRE", number: $2, part: $3, year: yn($1))
438
+ when /^(\w+)\.(\w+)-(|d{4})/ then PubId.new(publisher: "IEEE", number: $1, part: $2, year: $3)
439
+
440
+ # number, year
441
+ when /^(\w+)-(\d{4})\D/ then PubId.new(publisher: "IEEE", number: $1, year: $2)
442
+
443
+ # publisher, number
444
+ when /^([A-Z\/]+)#{APPROV}(?:\sDraft)?#{STD}(?:\sNo\.?)?\s(\w+)/o
445
+ PubId.new(publisher: $1, number: $2)
446
+
447
+ # else
448
+ # warn "Failed to parse normtitle #{normtitle}"
449
+ # nil # normtitle
450
+ end
451
+ rescue ArgumentError => e
452
+ e
453
+ end
454
+
455
+ # replace subpart's delimiter
456
+ #
457
+ # @param parts [Strong]
458
+ #
459
+ # @return [String]
460
+ def sp(parts)
461
+ parts.gsub ".", "-"
462
+ end
463
+
464
+ #
465
+ # Convert 2 digits year to 4 digits
466
+ #
467
+ # @param [String] year
468
+ #
469
+ # @return [String, nil] nil if string's length isn't 2 or 4
470
+ #
471
+ def yn(year)
472
+ return year if year.size == 4
473
+
474
+ case year.to_i
475
+ when 0..25 then "20#{year}"
476
+ when 26..99 then "19#{year}"
477
+ end
478
+ end
479
+
480
+ #
481
+ # Return number of month
482
+ #
483
+ # @param [String] month monthname
484
+ #
485
+ # @return [String] 2 digits month number
486
+ #
487
+ def mn(month)
488
+ n = Date::ABBR_MONTHNAMES.index(month) || Date::MONTHNAMES.index(month)
489
+ return month unless n
490
+
491
+ n.to_s.rjust 2, "0"
492
+ end
493
+
494
+ #
495
+ # Convert edition name to number
496
+ #
497
+ # @param [Strin] edition
498
+ #
499
+ # @return [String]
500
+ #
501
+ def en(edition)
502
+ case edition
503
+ when "First" then 1
504
+ when "Second" then 2
505
+ else edition
506
+ end
507
+ end
508
+
509
+ def dn(draftnum)
510
+ draftnum.sub(/^\./, "").gsub "-", "."
511
+ end
512
+
513
+ extend RawbibIdParser
514
+ end
515
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonIeee
2
- VERSION = "1.9.2".freeze
2
+ VERSION = "1.9.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2021-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -156,6 +156,8 @@ files:
156
156
  - lib/relaton_ieee/ieee_bibliographic_item.rb
157
157
  - lib/relaton_ieee/ieee_bibliography.rb
158
158
  - lib/relaton_ieee/processor.rb
159
+ - lib/relaton_ieee/pub_id.rb
160
+ - lib/relaton_ieee/rawbib_id_parser.rb
159
161
  - lib/relaton_ieee/scrapper.rb
160
162
  - lib/relaton_ieee/version.rb
161
163
  - lib/relaton_ieee/xml_parser.rb