relaton-gb 1.1.0 → 1.5.0
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/ubuntu.yml +1 -0
- data/.rubocop.yml +2 -2
- data/README.adoc +4 -22
- data/grammars/biblio.rng +1 -1
- data/grammars/gbstandard.rng +7 -0
- data/grammars/isodoc.rng +563 -21
- data/grammars/isostandard.rng +11 -1
- data/lib/relaton_gb.rb +1 -1
- data/lib/relaton_gb/ccs.rb +12 -0
- data/lib/relaton_gb/gb_bibliographic_item.rb +21 -39
- data/lib/relaton_gb/gb_scrapper.rb +1 -1
- data/lib/relaton_gb/hash_converter.rb +9 -0
- data/lib/relaton_gb/hit.rb +1 -1
- data/lib/relaton_gb/hit_collection.rb +3 -2
- data/lib/relaton_gb/scrapper.rb +7 -18
- data/lib/relaton_gb/sec_scrapper.rb +5 -3
- data/lib/relaton_gb/t_scrapper.rb +11 -16
- data/lib/relaton_gb/version.rb +1 -1
- data/lib/relaton_gb/xml_parser.rb +7 -15
- data/relaton_gb.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdcf6f4c449c467339bf697fcd6aa713605e7ff91ac5ba9879b7221a63b0aa84
|
4
|
+
data.tar.gz: b04b5b64cef0b79870c502d697bab4e78868b4e7730dae283aae4c10b1ec5b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c13f6d1a6667403fe2c49662d49455e4a29fe7e039f7abb8b3fc73ff7122bab44eb2b8185b4e8aaee19d9388556465896904651685158e74688a4645951f102
|
7
|
+
data.tar.gz: e2c1eb2ff01e25cc136df5ee920d5eaed3055eecdcc13ef2d24534aaad50c357ff220560ac591d944442f0f8d7abad0221ed404886922b6330939a2d9fbe2b67
|
data/.rubocop.yml
CHANGED
data/README.adoc
CHANGED
@@ -46,28 +46,10 @@ Or install it yourself as:
|
|
46
46
|
require 'relaton_gb'
|
47
47
|
|
48
48
|
hit_collection = RelatonGb::GbBibliography.search "GB/T 20223-2006"
|
49
|
-
=>
|
50
|
-
<RelatonGb::Hit:0x007f97572b7208 @fullIdentifier="" @title="20010320-T-424 棉短绒">,
|
51
|
-
<RelatonGb::Hit:0x007f97572b70c8 @fullIdentifier="" @title="GB/T 20223-2018 棉短绒">,
|
52
|
-
<RelatonGb::Hit:0x007f97572b6fb0 @fullIdentifier="" @title="NB/T 20223-2013 核电厂安全重要机械设备维修指南">,
|
53
|
-
<RelatonGb::Hit:0x007f97572b6e98 @fullIdentifier="" @title="20130458-T-424 棉短绒">,
|
54
|
-
<RelatonGb::Hit:0x007f97572b6d80 @fullIdentifier="" @title="GB 12995-2006 机动轮椅车">,
|
55
|
-
<RelatonGb::Hit:0x007f97572b6c68 @fullIdentifier="" @title="GB 14866-2006 个人用眼护具技术要求">,
|
56
|
-
<RelatonGb::Hit:0x007f97572b6b28 @fullIdentifier="" @title="GB/T 20788-2006 饲草揉碎机">,
|
57
|
-
<RelatonGb::Hit:0x007f97572b6a10 @fullIdentifier="" @title="GB/T 20707-2006 可可脂">,
|
58
|
-
<RelatonGb::Hit:0x007f97572b68f8 @fullIdentifier="" @title="GB/T 20706-2006 可可粉">]
|
59
|
-
|
60
|
-
hit_collection.size
|
61
|
-
=> 10
|
49
|
+
=> <RelatonGb::HitCollection:0x007fc8d8a26d10 @ref= @fetched=false>
|
62
50
|
|
63
51
|
hit_collection.first
|
64
|
-
=> <RelatonGb::Hit:
|
65
|
-
|
66
|
-
hit_collection[1]
|
67
|
-
=> <RelatonGb::Hit:0x007f97572b7208 @fullIdentifier="" @title="20010320-T-424 棉短绒">
|
68
|
-
|
69
|
-
hit_collection.first.title
|
70
|
-
=> "GB/T 20223-2006 棉短绒"
|
52
|
+
=> <RelatonGb::Hit:0x007fc8d8a27c88 @fullIdentifier="" @docref="GB/T 20223-2006">
|
71
53
|
----
|
72
54
|
|
73
55
|
=== Scrape document form collection
|
@@ -111,7 +93,7 @@ hit_collection.first.fetch.date
|
|
111
93
|
=> [#<RelatonBib::BibliographicDate:0x007f975a0207d0 @from=nil, @on=2006-03-10 00:00:00 +0100, @to=nil, @type="published">]
|
112
94
|
----
|
113
95
|
|
114
|
-
=== Create bibliographic item
|
96
|
+
=== Create bibliographic item from YAML
|
115
97
|
[source,ruby]
|
116
98
|
----
|
117
99
|
hash = YAML.load_file 'spec/examples/gb_bib_item.yml'
|
@@ -131,7 +113,7 @@ RelatonGb::GbBibliographicItem.new bib_hash
|
|
131
113
|
[source,ruby]
|
132
114
|
----
|
133
115
|
hit_collection.first.fetch.to_xml
|
134
|
-
=>"<bibitem id="GB/T20223-2006" type="
|
116
|
+
=>"<bibitem id="GB/T20223-2006" type="standard\">
|
135
117
|
<title type="title-main" format="text/plain" language="zh" script="Hans">棉短绒</title>
|
136
118
|
<title type="main" format="text/plain" language="zh" script="Hans">棉短绒</title>
|
137
119
|
<title type="title-main" format="text/plain" language="en" script="Latn">Cotton linter</title>
|
data/grammars/biblio.rng
CHANGED
@@ -532,7 +532,7 @@
|
|
532
532
|
</define>
|
533
533
|
<define name="LocalityType">
|
534
534
|
<data type="string">
|
535
|
-
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|locality:[a-zA-Z0-9_]+</param>
|
535
|
+
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
|
536
536
|
</data>
|
537
537
|
</define>
|
538
538
|
<define name="referenceFrom">
|
data/grammars/gbstandard.rng
CHANGED
@@ -183,6 +183,13 @@
|
|
183
183
|
<!-- identical structure to iso-standard -->
|
184
184
|
<define name="gb-standard">
|
185
185
|
<element name="gb-standard">
|
186
|
+
<attribute name="version"/>
|
187
|
+
<attribute name="type">
|
188
|
+
<choice>
|
189
|
+
<value>semantic</value>
|
190
|
+
<value>presentation</value>
|
191
|
+
</choice>
|
192
|
+
</attribute>
|
186
193
|
<ref name="bibdata"/>
|
187
194
|
<zeroOrMore>
|
188
195
|
<ref name="termdocsource"/>
|
data/grammars/isodoc.rng
CHANGED
@@ -43,7 +43,9 @@
|
|
43
43
|
<define name="xref">
|
44
44
|
<element name="xref">
|
45
45
|
<attribute name="target">
|
46
|
-
<data type="
|
46
|
+
<data type="string">
|
47
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
48
|
+
</data>
|
47
49
|
</attribute>
|
48
50
|
<optional>
|
49
51
|
<attribute name="type">
|
@@ -61,9 +63,93 @@
|
|
61
63
|
</choice>
|
62
64
|
</attribute>
|
63
65
|
</optional>
|
66
|
+
<optional>
|
67
|
+
<attribute name="droploc">
|
68
|
+
<data type="boolean"/>
|
69
|
+
</attribute>
|
70
|
+
</optional>
|
64
71
|
<text/>
|
65
72
|
</element>
|
66
73
|
</define>
|
74
|
+
<define name="ul">
|
75
|
+
<element name="ul">
|
76
|
+
<attribute name="id">
|
77
|
+
<data type="ID"/>
|
78
|
+
</attribute>
|
79
|
+
<optional>
|
80
|
+
<attribute name="keep-with-next">
|
81
|
+
<data type="boolean"/>
|
82
|
+
</attribute>
|
83
|
+
</optional>
|
84
|
+
<optional>
|
85
|
+
<attribute name="keep-lines-together">
|
86
|
+
<data type="boolean"/>
|
87
|
+
</attribute>
|
88
|
+
</optional>
|
89
|
+
<oneOrMore>
|
90
|
+
<ref name="li"/>
|
91
|
+
</oneOrMore>
|
92
|
+
<zeroOrMore>
|
93
|
+
<ref name="note"/>
|
94
|
+
</zeroOrMore>
|
95
|
+
</element>
|
96
|
+
</define>
|
97
|
+
<define name="ol">
|
98
|
+
<element name="ol">
|
99
|
+
<attribute name="id">
|
100
|
+
<data type="ID"/>
|
101
|
+
</attribute>
|
102
|
+
<optional>
|
103
|
+
<attribute name="keep-with-next">
|
104
|
+
<data type="boolean"/>
|
105
|
+
</attribute>
|
106
|
+
</optional>
|
107
|
+
<optional>
|
108
|
+
<attribute name="keep-lines-together">
|
109
|
+
<data type="boolean"/>
|
110
|
+
</attribute>
|
111
|
+
</optional>
|
112
|
+
<attribute name="type">
|
113
|
+
<choice>
|
114
|
+
<value>roman</value>
|
115
|
+
<value>alphabet</value>
|
116
|
+
<value>arabic</value>
|
117
|
+
<value>roman_upper</value>
|
118
|
+
<value>alphabet_upper</value>
|
119
|
+
</choice>
|
120
|
+
</attribute>
|
121
|
+
<oneOrMore>
|
122
|
+
<ref name="li"/>
|
123
|
+
</oneOrMore>
|
124
|
+
<zeroOrMore>
|
125
|
+
<ref name="note"/>
|
126
|
+
</zeroOrMore>
|
127
|
+
</element>
|
128
|
+
</define>
|
129
|
+
<define name="dl">
|
130
|
+
<element name="dl">
|
131
|
+
<attribute name="id">
|
132
|
+
<data type="ID"/>
|
133
|
+
</attribute>
|
134
|
+
<optional>
|
135
|
+
<attribute name="keep-with-next">
|
136
|
+
<data type="boolean"/>
|
137
|
+
</attribute>
|
138
|
+
</optional>
|
139
|
+
<optional>
|
140
|
+
<attribute name="keep-lines-together">
|
141
|
+
<data type="boolean"/>
|
142
|
+
</attribute>
|
143
|
+
</optional>
|
144
|
+
<oneOrMore>
|
145
|
+
<ref name="dt"/>
|
146
|
+
<ref name="dd"/>
|
147
|
+
</oneOrMore>
|
148
|
+
<zeroOrMore>
|
149
|
+
<ref name="note"/>
|
150
|
+
</zeroOrMore>
|
151
|
+
</element>
|
152
|
+
</define>
|
67
153
|
<define name="example">
|
68
154
|
<element name="example">
|
69
155
|
<attribute name="id">
|
@@ -77,6 +163,19 @@
|
|
77
163
|
<optional>
|
78
164
|
<attribute name="subsequence"/>
|
79
165
|
</optional>
|
166
|
+
<optional>
|
167
|
+
<attribute name="number"/>
|
168
|
+
</optional>
|
169
|
+
<optional>
|
170
|
+
<attribute name="keep-with-next">
|
171
|
+
<data type="boolean"/>
|
172
|
+
</attribute>
|
173
|
+
</optional>
|
174
|
+
<optional>
|
175
|
+
<attribute name="keep-lines-together">
|
176
|
+
<data type="boolean"/>
|
177
|
+
</attribute>
|
178
|
+
</optional>
|
80
179
|
<optional>
|
81
180
|
<ref name="tname"/>
|
82
181
|
</optional>
|
@@ -97,6 +196,296 @@
|
|
97
196
|
</zeroOrMore>
|
98
197
|
</element>
|
99
198
|
</define>
|
199
|
+
<define name="table">
|
200
|
+
<element name="table">
|
201
|
+
<attribute name="id">
|
202
|
+
<data type="ID"/>
|
203
|
+
</attribute>
|
204
|
+
<optional>
|
205
|
+
<attribute name="unnumbered">
|
206
|
+
<data type="boolean"/>
|
207
|
+
</attribute>
|
208
|
+
</optional>
|
209
|
+
<optional>
|
210
|
+
<attribute name="number"/>
|
211
|
+
</optional>
|
212
|
+
<optional>
|
213
|
+
<attribute name="subsequence"/>
|
214
|
+
</optional>
|
215
|
+
<optional>
|
216
|
+
<attribute name="alt"/>
|
217
|
+
</optional>
|
218
|
+
<optional>
|
219
|
+
<attribute name="summary"/>
|
220
|
+
</optional>
|
221
|
+
<optional>
|
222
|
+
<attribute name="uri">
|
223
|
+
<data type="anyURI"/>
|
224
|
+
</attribute>
|
225
|
+
</optional>
|
226
|
+
<optional>
|
227
|
+
<attribute name="keep-with-next">
|
228
|
+
<data type="boolean"/>
|
229
|
+
</attribute>
|
230
|
+
</optional>
|
231
|
+
<optional>
|
232
|
+
<attribute name="keep-lines-together">
|
233
|
+
<data type="boolean"/>
|
234
|
+
</attribute>
|
235
|
+
</optional>
|
236
|
+
<optional>
|
237
|
+
<ref name="tname"/>
|
238
|
+
</optional>
|
239
|
+
<optional>
|
240
|
+
<ref name="thead"/>
|
241
|
+
</optional>
|
242
|
+
<ref name="tbody"/>
|
243
|
+
<optional>
|
244
|
+
<ref name="tfoot"/>
|
245
|
+
</optional>
|
246
|
+
<zeroOrMore>
|
247
|
+
<ref name="table-note"/>
|
248
|
+
</zeroOrMore>
|
249
|
+
<optional>
|
250
|
+
<ref name="dl"/>
|
251
|
+
</optional>
|
252
|
+
</element>
|
253
|
+
</define>
|
254
|
+
<define name="figure">
|
255
|
+
<element name="figure">
|
256
|
+
<attribute name="id">
|
257
|
+
<data type="ID"/>
|
258
|
+
</attribute>
|
259
|
+
<optional>
|
260
|
+
<attribute name="unnumbered">
|
261
|
+
<data type="boolean"/>
|
262
|
+
</attribute>
|
263
|
+
</optional>
|
264
|
+
<optional>
|
265
|
+
<attribute name="number"/>
|
266
|
+
</optional>
|
267
|
+
<optional>
|
268
|
+
<attribute name="subsequence"/>
|
269
|
+
</optional>
|
270
|
+
<optional>
|
271
|
+
<attribute name="keep-with-next">
|
272
|
+
<data type="boolean"/>
|
273
|
+
</attribute>
|
274
|
+
</optional>
|
275
|
+
<optional>
|
276
|
+
<attribute name="keep-lines-together">
|
277
|
+
<data type="boolean"/>
|
278
|
+
</attribute>
|
279
|
+
</optional>
|
280
|
+
<optional>
|
281
|
+
<attribute name="class"/>
|
282
|
+
</optional>
|
283
|
+
<optional>
|
284
|
+
<ref name="source"/>
|
285
|
+
</optional>
|
286
|
+
<optional>
|
287
|
+
<ref name="tname"/>
|
288
|
+
</optional>
|
289
|
+
<choice>
|
290
|
+
<ref name="image"/>
|
291
|
+
<ref name="video"/>
|
292
|
+
<ref name="audio"/>
|
293
|
+
<ref name="pre"/>
|
294
|
+
<oneOrMore>
|
295
|
+
<ref name="paragraph-with-footnote"/>
|
296
|
+
</oneOrMore>
|
297
|
+
<zeroOrMore>
|
298
|
+
<ref name="figure"/>
|
299
|
+
</zeroOrMore>
|
300
|
+
</choice>
|
301
|
+
<zeroOrMore>
|
302
|
+
<ref name="fn"/>
|
303
|
+
</zeroOrMore>
|
304
|
+
<optional>
|
305
|
+
<ref name="dl"/>
|
306
|
+
</optional>
|
307
|
+
<zeroOrMore>
|
308
|
+
<ref name="note"/>
|
309
|
+
</zeroOrMore>
|
310
|
+
</element>
|
311
|
+
</define>
|
312
|
+
<define name="sourcecode">
|
313
|
+
<element name="sourcecode">
|
314
|
+
<attribute name="id">
|
315
|
+
<data type="ID"/>
|
316
|
+
</attribute>
|
317
|
+
<optional>
|
318
|
+
<attribute name="unnumbered">
|
319
|
+
<data type="boolean"/>
|
320
|
+
</attribute>
|
321
|
+
</optional>
|
322
|
+
<optional>
|
323
|
+
<attribute name="number"/>
|
324
|
+
</optional>
|
325
|
+
<optional>
|
326
|
+
<attribute name="subsequence"/>
|
327
|
+
</optional>
|
328
|
+
<optional>
|
329
|
+
<attribute name="keep-with-next">
|
330
|
+
<data type="boolean"/>
|
331
|
+
</attribute>
|
332
|
+
</optional>
|
333
|
+
<optional>
|
334
|
+
<attribute name="keep-lines-together">
|
335
|
+
<data type="boolean"/>
|
336
|
+
</attribute>
|
337
|
+
</optional>
|
338
|
+
<optional>
|
339
|
+
<attribute name="lang"/>
|
340
|
+
</optional>
|
341
|
+
<optional>
|
342
|
+
<ref name="tname"/>
|
343
|
+
</optional>
|
344
|
+
<oneOrMore>
|
345
|
+
<choice>
|
346
|
+
<text/>
|
347
|
+
<ref name="callout"/>
|
348
|
+
</choice>
|
349
|
+
</oneOrMore>
|
350
|
+
<zeroOrMore>
|
351
|
+
<ref name="annotation"/>
|
352
|
+
</zeroOrMore>
|
353
|
+
<zeroOrMore>
|
354
|
+
<ref name="note"/>
|
355
|
+
</zeroOrMore>
|
356
|
+
</element>
|
357
|
+
</define>
|
358
|
+
<define name="formula">
|
359
|
+
<element name="formula">
|
360
|
+
<attribute name="id">
|
361
|
+
<data type="ID"/>
|
362
|
+
</attribute>
|
363
|
+
<optional>
|
364
|
+
<attribute name="unnumbered">
|
365
|
+
<data type="boolean"/>
|
366
|
+
</attribute>
|
367
|
+
</optional>
|
368
|
+
<optional>
|
369
|
+
<attribute name="number"/>
|
370
|
+
</optional>
|
371
|
+
<optional>
|
372
|
+
<attribute name="subsequence"/>
|
373
|
+
</optional>
|
374
|
+
<optional>
|
375
|
+
<attribute name="keep-with-next">
|
376
|
+
<data type="boolean"/>
|
377
|
+
</attribute>
|
378
|
+
</optional>
|
379
|
+
<optional>
|
380
|
+
<attribute name="keep-lines-together">
|
381
|
+
<data type="boolean"/>
|
382
|
+
</attribute>
|
383
|
+
</optional>
|
384
|
+
<optional>
|
385
|
+
<attribute name="inequality">
|
386
|
+
<data type="boolean"/>
|
387
|
+
</attribute>
|
388
|
+
</optional>
|
389
|
+
<ref name="stem"/>
|
390
|
+
<optional>
|
391
|
+
<ref name="dl"/>
|
392
|
+
</optional>
|
393
|
+
<zeroOrMore>
|
394
|
+
<ref name="note"/>
|
395
|
+
</zeroOrMore>
|
396
|
+
</element>
|
397
|
+
</define>
|
398
|
+
<define name="ParagraphType">
|
399
|
+
<attribute name="id">
|
400
|
+
<data type="ID"/>
|
401
|
+
</attribute>
|
402
|
+
<optional>
|
403
|
+
<attribute name="align">
|
404
|
+
<ref name="Alignments"/>
|
405
|
+
</attribute>
|
406
|
+
</optional>
|
407
|
+
<optional>
|
408
|
+
<attribute name="keep-with-next">
|
409
|
+
<data type="boolean"/>
|
410
|
+
</attribute>
|
411
|
+
</optional>
|
412
|
+
<optional>
|
413
|
+
<attribute name="keep-lines-together">
|
414
|
+
<data type="boolean"/>
|
415
|
+
</attribute>
|
416
|
+
</optional>
|
417
|
+
<zeroOrMore>
|
418
|
+
<ref name="TextElement"/>
|
419
|
+
</zeroOrMore>
|
420
|
+
<zeroOrMore>
|
421
|
+
<ref name="note"/>
|
422
|
+
</zeroOrMore>
|
423
|
+
</define>
|
424
|
+
<define name="paragraph-with-footnote">
|
425
|
+
<element name="p">
|
426
|
+
<attribute name="id">
|
427
|
+
<data type="ID"/>
|
428
|
+
</attribute>
|
429
|
+
<optional>
|
430
|
+
<attribute name="align">
|
431
|
+
<ref name="Alignments"/>
|
432
|
+
</attribute>
|
433
|
+
</optional>
|
434
|
+
<optional>
|
435
|
+
<attribute name="keep-with-next">
|
436
|
+
<data type="boolean"/>
|
437
|
+
</attribute>
|
438
|
+
</optional>
|
439
|
+
<optional>
|
440
|
+
<attribute name="keep-lines-together">
|
441
|
+
<data type="boolean"/>
|
442
|
+
</attribute>
|
443
|
+
</optional>
|
444
|
+
<zeroOrMore>
|
445
|
+
<choice>
|
446
|
+
<ref name="TextElement"/>
|
447
|
+
<ref name="fn"/>
|
448
|
+
</choice>
|
449
|
+
</zeroOrMore>
|
450
|
+
<zeroOrMore>
|
451
|
+
<ref name="note"/>
|
452
|
+
</zeroOrMore>
|
453
|
+
</element>
|
454
|
+
</define>
|
455
|
+
<define name="quote">
|
456
|
+
<element name="quote">
|
457
|
+
<attribute name="id">
|
458
|
+
<data type="ID"/>
|
459
|
+
</attribute>
|
460
|
+
<optional>
|
461
|
+
<attribute name="alignment">
|
462
|
+
<ref name="Alignments"/>
|
463
|
+
</attribute>
|
464
|
+
</optional>
|
465
|
+
<optional>
|
466
|
+
<attribute name="keep-with-next">
|
467
|
+
<data type="boolean"/>
|
468
|
+
</attribute>
|
469
|
+
</optional>
|
470
|
+
<optional>
|
471
|
+
<attribute name="keep-lines-together">
|
472
|
+
<data type="boolean"/>
|
473
|
+
</attribute>
|
474
|
+
</optional>
|
475
|
+
<optional>
|
476
|
+
<ref name="quote-source"/>
|
477
|
+
</optional>
|
478
|
+
<optional>
|
479
|
+
<ref name="quote-author"/>
|
480
|
+
</optional>
|
481
|
+
<oneOrMore>
|
482
|
+
<ref name="paragraph-with-footnote"/>
|
483
|
+
</oneOrMore>
|
484
|
+
<zeroOrMore>
|
485
|
+
<ref name="note"/>
|
486
|
+
</zeroOrMore>
|
487
|
+
</element>
|
488
|
+
</define>
|
100
489
|
<define name="BibDataExtensionType">
|
101
490
|
<ref name="doctype"/>
|
102
491
|
<optional>
|
@@ -165,6 +554,30 @@
|
|
165
554
|
<attribute name="id">
|
166
555
|
<data type="ID"/>
|
167
556
|
</attribute>
|
557
|
+
<optional>
|
558
|
+
<attribute name="unnumbered">
|
559
|
+
<data type="boolean"/>
|
560
|
+
</attribute>
|
561
|
+
</optional>
|
562
|
+
<optional>
|
563
|
+
<attribute name="number"/>
|
564
|
+
</optional>
|
565
|
+
<optional>
|
566
|
+
<attribute name="subsequence"/>
|
567
|
+
</optional>
|
568
|
+
<optional>
|
569
|
+
<attribute name="keep-with-next">
|
570
|
+
<data type="boolean"/>
|
571
|
+
</attribute>
|
572
|
+
</optional>
|
573
|
+
<optional>
|
574
|
+
<attribute name="keep-lines-together">
|
575
|
+
<data type="boolean"/>
|
576
|
+
</attribute>
|
577
|
+
</optional>
|
578
|
+
<optional>
|
579
|
+
<attribute name="type"/>
|
580
|
+
</optional>
|
168
581
|
<oneOrMore>
|
169
582
|
<choice>
|
170
583
|
<ref name="paragraph"/>
|
@@ -172,6 +585,8 @@
|
|
172
585
|
<ref name="ol"/>
|
173
586
|
<ref name="dl"/>
|
174
587
|
<ref name="formula"/>
|
588
|
+
<ref name="quote"/>
|
589
|
+
<ref name="sourcecode"/>
|
175
590
|
</choice>
|
176
591
|
</oneOrMore>
|
177
592
|
</element>
|
@@ -255,6 +670,16 @@
|
|
255
670
|
</choice>
|
256
671
|
</attribute>
|
257
672
|
</optional>
|
673
|
+
<optional>
|
674
|
+
<attribute name="valign">
|
675
|
+
<choice>
|
676
|
+
<value>top</value>
|
677
|
+
<value>middle</value>
|
678
|
+
<value>bottom</value>
|
679
|
+
<value>baseline</value>
|
680
|
+
</choice>
|
681
|
+
</attribute>
|
682
|
+
</optional>
|
258
683
|
<choice>
|
259
684
|
<zeroOrMore>
|
260
685
|
<choice>
|
@@ -291,6 +716,16 @@
|
|
291
716
|
</choice>
|
292
717
|
</attribute>
|
293
718
|
</optional>
|
719
|
+
<optional>
|
720
|
+
<attribute name="valign">
|
721
|
+
<choice>
|
722
|
+
<value>top</value>
|
723
|
+
<value>middle</value>
|
724
|
+
<value>bottom</value>
|
725
|
+
<value>baseline</value>
|
726
|
+
</choice>
|
727
|
+
</attribute>
|
728
|
+
</optional>
|
294
729
|
<choice>
|
295
730
|
<zeroOrMore>
|
296
731
|
<choice>
|
@@ -428,6 +863,13 @@
|
|
428
863
|
</define>
|
429
864
|
<define name="standard-document">
|
430
865
|
<element name="standard-document">
|
866
|
+
<attribute name="version"/>
|
867
|
+
<attribute name="type">
|
868
|
+
<choice>
|
869
|
+
<value>semantic</value>
|
870
|
+
<value>presentation</value>
|
871
|
+
</choice>
|
872
|
+
</attribute>
|
431
873
|
<ref name="bibdata"/>
|
432
874
|
<optional>
|
433
875
|
<ref name="boilerplate"/>
|
@@ -449,7 +891,7 @@
|
|
449
891
|
<oneOrMore>
|
450
892
|
<choice>
|
451
893
|
<ref name="content"/>
|
452
|
-
<ref name="
|
894
|
+
<ref name="abstract"/>
|
453
895
|
<ref name="foreword"/>
|
454
896
|
<ref name="introduction"/>
|
455
897
|
<ref name="acknowledgements"/>
|
@@ -516,6 +958,9 @@
|
|
516
958
|
<optional>
|
517
959
|
<attribute name="script"/>
|
518
960
|
</optional>
|
961
|
+
<optional>
|
962
|
+
<attribute name="type"/>
|
963
|
+
</optional>
|
519
964
|
<optional>
|
520
965
|
<attribute name="obligation">
|
521
966
|
<choice>
|
@@ -555,9 +1000,6 @@
|
|
555
1000
|
</define>
|
556
1001
|
<define name="content-subsection">
|
557
1002
|
<element name="clause">
|
558
|
-
<optional>
|
559
|
-
<attribute name="type"/>
|
560
|
-
</optional>
|
561
1003
|
<ref name="Content-Section"/>
|
562
1004
|
</element>
|
563
1005
|
</define>
|
@@ -586,6 +1028,9 @@
|
|
586
1028
|
</choice>
|
587
1029
|
</attribute>
|
588
1030
|
</optional>
|
1031
|
+
<optional>
|
1032
|
+
<attribute name="type"/>
|
1033
|
+
</optional>
|
589
1034
|
<optional>
|
590
1035
|
<ref name="section-title"/>
|
591
1036
|
</optional>
|
@@ -605,9 +1050,6 @@
|
|
605
1050
|
</define>
|
606
1051
|
<define name="clause">
|
607
1052
|
<element name="clause">
|
608
|
-
<optional>
|
609
|
-
<attribute name="type"/>
|
610
|
-
</optional>
|
611
1053
|
<ref name="Clause-Section"/>
|
612
1054
|
</element>
|
613
1055
|
</define>
|
@@ -636,18 +1078,24 @@
|
|
636
1078
|
</choice>
|
637
1079
|
</attribute>
|
638
1080
|
</optional>
|
1081
|
+
<optional>
|
1082
|
+
<attribute name="type"/>
|
1083
|
+
</optional>
|
639
1084
|
<optional>
|
640
1085
|
<ref name="section-title"/>
|
641
1086
|
</optional>
|
642
1087
|
<group>
|
643
|
-
<
|
644
|
-
<
|
645
|
-
<
|
646
|
-
|
647
|
-
|
648
|
-
<
|
649
|
-
|
650
|
-
|
1088
|
+
<choice>
|
1089
|
+
<group>
|
1090
|
+
<zeroOrMore>
|
1091
|
+
<ref name="BasicBlock"/>
|
1092
|
+
</zeroOrMore>
|
1093
|
+
<zeroOrMore>
|
1094
|
+
<ref name="note"/>
|
1095
|
+
</zeroOrMore>
|
1096
|
+
</group>
|
1097
|
+
<ref name="amend"/>
|
1098
|
+
</choice>
|
651
1099
|
<zeroOrMore>
|
652
1100
|
<choice>
|
653
1101
|
<ref name="clause-subsection"/>
|
@@ -774,6 +1222,9 @@
|
|
774
1222
|
<optional>
|
775
1223
|
<attribute name="script"/>
|
776
1224
|
</optional>
|
1225
|
+
<optional>
|
1226
|
+
<attribute name="type"/>
|
1227
|
+
</optional>
|
777
1228
|
<optional>
|
778
1229
|
<attribute name="obligation">
|
779
1230
|
<choice>
|
@@ -910,6 +1361,27 @@
|
|
910
1361
|
<attribute name="id">
|
911
1362
|
<data type="ID"/>
|
912
1363
|
</attribute>
|
1364
|
+
<optional>
|
1365
|
+
<attribute name="unnumbered">
|
1366
|
+
<data type="boolean"/>
|
1367
|
+
</attribute>
|
1368
|
+
</optional>
|
1369
|
+
<optional>
|
1370
|
+
<attribute name="number"/>
|
1371
|
+
</optional>
|
1372
|
+
<optional>
|
1373
|
+
<attribute name="subsequence"/>
|
1374
|
+
</optional>
|
1375
|
+
<optional>
|
1376
|
+
<attribute name="keep-with-next">
|
1377
|
+
<data type="boolean"/>
|
1378
|
+
</attribute>
|
1379
|
+
</optional>
|
1380
|
+
<optional>
|
1381
|
+
<attribute name="keep-lines-together">
|
1382
|
+
<data type="boolean"/>
|
1383
|
+
</attribute>
|
1384
|
+
</optional>
|
913
1385
|
<oneOrMore>
|
914
1386
|
<choice>
|
915
1387
|
<ref name="paragraph"/>
|
@@ -1020,11 +1492,6 @@
|
|
1020
1492
|
</optional>
|
1021
1493
|
</element>
|
1022
1494
|
</define>
|
1023
|
-
<define name="preface_abstract">
|
1024
|
-
<element name="abstract">
|
1025
|
-
<ref name="Basic-Section"/>
|
1026
|
-
</element>
|
1027
|
-
</define>
|
1028
1495
|
<define name="term-clause">
|
1029
1496
|
<element name="clause">
|
1030
1497
|
<optional>
|
@@ -1074,4 +1541,79 @@
|
|
1074
1541
|
<ref name="CitationType"/>
|
1075
1542
|
</element>
|
1076
1543
|
</define>
|
1544
|
+
<define name="amend">
|
1545
|
+
<element name="amend">
|
1546
|
+
<optional>
|
1547
|
+
<attribute name="id">
|
1548
|
+
<data type="ID"/>
|
1549
|
+
</attribute>
|
1550
|
+
</optional>
|
1551
|
+
<attribute name="change">
|
1552
|
+
<choice>
|
1553
|
+
<value>add</value>
|
1554
|
+
<value>modify</value>
|
1555
|
+
<value>delete</value>
|
1556
|
+
</choice>
|
1557
|
+
</attribute>
|
1558
|
+
<optional>
|
1559
|
+
<attribute name="path"/>
|
1560
|
+
</optional>
|
1561
|
+
<optional>
|
1562
|
+
<attribute name="path_end"/>
|
1563
|
+
</optional>
|
1564
|
+
<optional>
|
1565
|
+
<attribute name="title"/>
|
1566
|
+
</optional>
|
1567
|
+
<optional>
|
1568
|
+
<element name="location">
|
1569
|
+
<zeroOrMore>
|
1570
|
+
<ref name="locality"/>
|
1571
|
+
</zeroOrMore>
|
1572
|
+
</element>
|
1573
|
+
</optional>
|
1574
|
+
<zeroOrMore>
|
1575
|
+
<ref name="autonumber"/>
|
1576
|
+
</zeroOrMore>
|
1577
|
+
<optional>
|
1578
|
+
<element name="description">
|
1579
|
+
<zeroOrMore>
|
1580
|
+
<ref name="BasicBlock"/>
|
1581
|
+
</zeroOrMore>
|
1582
|
+
</element>
|
1583
|
+
</optional>
|
1584
|
+
<optional>
|
1585
|
+
<element name="newcontent">
|
1586
|
+
<zeroOrMore>
|
1587
|
+
<ref name="BasicBlock"/>
|
1588
|
+
</zeroOrMore>
|
1589
|
+
</element>
|
1590
|
+
</optional>
|
1591
|
+
<optional>
|
1592
|
+
<element name="description">
|
1593
|
+
<zeroOrMore>
|
1594
|
+
<ref name="BasicBlock"/>
|
1595
|
+
</zeroOrMore>
|
1596
|
+
</element>
|
1597
|
+
</optional>
|
1598
|
+
</element>
|
1599
|
+
</define>
|
1600
|
+
<define name="autonumber">
|
1601
|
+
<element name="autonumber">
|
1602
|
+
<attribute name="type">
|
1603
|
+
<choice>
|
1604
|
+
<value>requirement</value>
|
1605
|
+
<value>recommendation</value>
|
1606
|
+
<value>permission</value>
|
1607
|
+
<value>table</value>
|
1608
|
+
<value>figure</value>
|
1609
|
+
<value>admonition</value>
|
1610
|
+
<value>formula</value>
|
1611
|
+
<value>sourcecode</value>
|
1612
|
+
<value>example</value>
|
1613
|
+
<value>note</value>
|
1614
|
+
</choice>
|
1615
|
+
</attribute>
|
1616
|
+
<text/>
|
1617
|
+
</element>
|
1618
|
+
</define>
|
1077
1619
|
</grammar>
|
data/grammars/isostandard.rng
CHANGED
@@ -253,7 +253,7 @@
|
|
253
253
|
<define name="preface">
|
254
254
|
<element name="preface">
|
255
255
|
<optional>
|
256
|
-
<ref name="
|
256
|
+
<ref name="abstract"/>
|
257
257
|
</optional>
|
258
258
|
<ref name="foreword"/>
|
259
259
|
<optional>
|
@@ -362,6 +362,9 @@
|
|
362
362
|
<data type="boolean"/>
|
363
363
|
</attribute>
|
364
364
|
</optional>
|
365
|
+
<optional>
|
366
|
+
<attribute name="number"/>
|
367
|
+
</optional>
|
365
368
|
<optional>
|
366
369
|
<attribute name="subsequence"/>
|
367
370
|
</optional>
|
@@ -402,6 +405,13 @@
|
|
402
405
|
-->
|
403
406
|
<define name="iso-standard">
|
404
407
|
<element name="iso-standard">
|
408
|
+
<attribute name="version"/>
|
409
|
+
<attribute name="type">
|
410
|
+
<choice>
|
411
|
+
<value>semantic</value>
|
412
|
+
<value>presentation</value>
|
413
|
+
</choice>
|
414
|
+
</attribute>
|
405
415
|
<ref name="bibdata"/>
|
406
416
|
<zeroOrMore>
|
407
417
|
<ref name="termdocsource"/>
|
data/lib/relaton_gb.rb
CHANGED
data/lib/relaton_gb/ccs.rb
CHANGED
@@ -4,5 +4,17 @@ module Cnccs
|
|
4
4
|
def to_hash
|
5
5
|
{ "code" => code }
|
6
6
|
end
|
7
|
+
|
8
|
+
# @param prefix [String]
|
9
|
+
# @param count [Integer]
|
10
|
+
# @return [String]
|
11
|
+
def to_aciibib(prefix = "", count = 1)
|
12
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
13
|
+
pref += "ccs"
|
14
|
+
out = count > 1 ? "#{pref}::\n" : ""
|
15
|
+
out += "#{pref}.code:: #{code}\n" if code
|
16
|
+
out += "#{pref}.description:: #{description}\n" if description
|
17
|
+
out
|
18
|
+
end
|
7
19
|
end
|
8
20
|
end
|
@@ -31,26 +31,25 @@ module RelatonGb
|
|
31
31
|
|
32
32
|
def initialize(**args)
|
33
33
|
super
|
34
|
-
|
34
|
+
@committee = GbTechnicalCommittee.new args[:committee] if args[:committee]
|
35
35
|
@ccs = args[:ccs].map { |c| c.is_a?(Cnccs::Ccs) ? c : Cnccs.fetch(c) }
|
36
36
|
@gbtype = GbStandardType.new args[:gbtype]
|
37
|
-
@gbplannumber = args[:gbplannumber] ||
|
37
|
+
@gbplannumber = args[:gbplannumber] ||
|
38
|
+
structuredidentifier&.project_number
|
38
39
|
end
|
39
40
|
|
40
|
-
# @param
|
41
|
-
# @
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end.doc.root.to_xml
|
49
|
-
end
|
41
|
+
# @param opts [Hash]
|
42
|
+
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
43
|
+
# @option opts [Boolean] :bibdata
|
44
|
+
# @option opts [Symbol, NilClass] :date_format (:short), :full
|
45
|
+
# @option opts [String, Symbol] :lang language
|
46
|
+
# @return [String] XML
|
47
|
+
def to_xml(**opts)
|
48
|
+
super(**opts) { |xml| render_gbxml(xml) }
|
50
49
|
end
|
51
50
|
|
52
51
|
# @return [Hash]
|
53
|
-
def to_hash
|
52
|
+
def to_hash # rubocop:disable Metrics/AbcSize
|
54
53
|
hash = super
|
55
54
|
hash["ccs"] = single_element_array(ccs) if ccs&.any?
|
56
55
|
hash["committee"] = committee.to_hash if committee
|
@@ -59,11 +58,17 @@ module RelatonGb
|
|
59
58
|
hash
|
60
59
|
end
|
61
60
|
|
61
|
+
# @param prefix [String]
|
62
|
+
# @return [String]
|
63
|
+
def to_asciibib(prefix = "")
|
64
|
+
out = super
|
65
|
+
ccs.each { |c| out += c.to_aciibib prefix, ccs.size }
|
66
|
+
out
|
67
|
+
end
|
68
|
+
|
62
69
|
# @return [String]
|
63
70
|
def inspect
|
64
|
-
"<#{self.class}:#{format('
|
65
|
-
# "@fullIdentifier=\"#{@fetch&.shortref}\" "\
|
66
|
-
# "@title=\"#{title}\">"
|
71
|
+
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)}>"
|
67
72
|
end
|
68
73
|
|
69
74
|
# @return [String]
|
@@ -76,34 +81,11 @@ module RelatonGb
|
|
76
81
|
|
77
82
|
id ||= @docidentifier.reject { |i| i.type == "DOI" }[0]
|
78
83
|
idstr = id.id
|
79
|
-
# if id.part_number&.size&.positive?
|
80
|
-
# idstr = idstr + "-#{id.part_number}"
|
81
|
-
# end
|
82
84
|
idstr.gsub(/\s/, "").strip
|
83
85
|
end
|
84
86
|
|
85
87
|
private
|
86
88
|
|
87
|
-
# Overraides IsoBibliographicItem method.
|
88
|
-
# @param language [Array<String>]
|
89
|
-
# @raise ArgumentError
|
90
|
-
def check_language(language)
|
91
|
-
language.each do |lang|
|
92
|
-
unless %w[en zh].include? lang
|
93
|
-
raise ArgumentError, "invalid language: #{lang}"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Overraides IsoBibliographicItem method.
|
99
|
-
# @param script [Array<String>]
|
100
|
-
# @raise ArgumentError
|
101
|
-
def check_script(script)
|
102
|
-
script.each do |scr|
|
103
|
-
raise ArgumentError, "invalid script: #{scr}" unless %w[Latn Hans].include? scr
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
89
|
# @param builder [Nokogiri::XML::Builder]
|
108
90
|
def render_gbxml(builder)
|
109
91
|
gbtype.to_xml builder
|
@@ -16,7 +16,7 @@ module RelatonGb
|
|
16
16
|
# @return [RelatonGb::HitCollection]
|
17
17
|
def scrape_page(text)
|
18
18
|
search_html = OpenURI.open_uri(
|
19
|
-
"http://openstd.samr.gov.cn/bzgk/gb/std_list?p.p2=" + text
|
19
|
+
"http://openstd.samr.gov.cn/bzgk/gb/std_list?p.p2=" + text,
|
20
20
|
)
|
21
21
|
result = Nokogiri::HTML search_html
|
22
22
|
hits = result.xpath(
|
@@ -17,6 +17,15 @@ module RelatonGb
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
#
|
21
|
+
# Ovverides superclass's method
|
22
|
+
#
|
23
|
+
# @param item [Hash]
|
24
|
+
# @retirn [RelatonGb::GbBibliographicItem]
|
25
|
+
def bib_item(item)
|
26
|
+
GbBibliographicItem.new(item)
|
27
|
+
end
|
28
|
+
|
20
29
|
def ccs_hash_to_bib(ret)
|
21
30
|
ret[:ccs] = array(ret[:ccs]).map do |ccs|
|
22
31
|
ccs[:code] ? Cnccs.fetch(ccs[:code]) : Cnccs.fetch(ccs)
|
data/lib/relaton_gb/hit.rb
CHANGED
@@ -38,7 +38,7 @@ module RelatonGb
|
|
38
38
|
|
39
39
|
# @return [String]
|
40
40
|
def inspect
|
41
|
-
"<#{self.class}:#{format('
|
41
|
+
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} "\
|
42
42
|
"@fullIdentifier=\"#{@fetch&.shortref}\" "\
|
43
43
|
"@docref=\"#{docref}\">"
|
44
44
|
end
|
@@ -5,10 +5,11 @@ module RelatonGb
|
|
5
5
|
class HitCollection < RelatonBib::HitCollection
|
6
6
|
# @param hits [Array<Hash>]
|
7
7
|
# @param hit_pages [Integer]
|
8
|
-
# @param scrapper [RelatonGb::GbScrapper, RelatonGb::SecScrapper,
|
8
|
+
# @param scrapper [RelatonGb::GbScrapper, RelatonGb::SecScrapper,
|
9
|
+
# RelatonGb::TScrapper]
|
9
10
|
def initialize(hits = [])
|
10
11
|
@array = hits
|
11
|
-
@fetched
|
12
|
+
@fetched = false
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/relaton_gb/scrapper.rb
CHANGED
@@ -78,19 +78,14 @@ module RelatonGb
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# @param doc [Nokogiri::HTML::Document]
|
81
|
-
# @return [Array<
|
82
|
-
# * :title_intro [String]
|
83
|
-
# * :title_main [String]
|
84
|
-
# * :language [String]
|
85
|
-
# * :script [String]
|
81
|
+
# @return [Array<RelatonBib::TypedTitleString>]
|
86
82
|
def get_titles(doc)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
titles
|
83
|
+
tzh = doc.at("//td[contains(text(), '中文标准名称')]/b").text
|
84
|
+
titles = RelatonBib::TypedTitleString.from_string tzh, "zh", "Hans"
|
85
|
+
ten = doc.at("//td[contains(text(), '英文标准名称')]").text.match(/[\w\s]+/).to_s
|
86
|
+
return titles if ten.empty?
|
87
|
+
|
88
|
+
titles + RelatonBib::TypedTitleString.from_string(ten, "en", "Latn")
|
94
89
|
end
|
95
90
|
|
96
91
|
def get_type
|
@@ -123,12 +118,6 @@ module RelatonGb
|
|
123
118
|
mandate: get_mandate(ref), topic: "other" }
|
124
119
|
end
|
125
120
|
|
126
|
-
# @param doc [Nokogiri::HTML::Document]
|
127
|
-
# @return [String]
|
128
|
-
# def get_ref(doc)
|
129
|
-
# doc.xpath('//dt[text()="标准号"]/following-sibling::dd[1]').text
|
130
|
-
# end
|
131
|
-
|
132
121
|
# @param doc [Nokogiri::HTML::Document]
|
133
122
|
# @return [Array<String>]
|
134
123
|
def get_ccs(doc)
|
@@ -58,13 +58,15 @@ module RelatonGb
|
|
58
58
|
# * :language [String]
|
59
59
|
# * :script [String]
|
60
60
|
def get_titles(doc)
|
61
|
-
titles = [{ title_main: doc.at("//h4").text.delete("\r\n\t"),
|
62
|
-
|
61
|
+
# titles = [{ title_main: doc.at("//h4").text.delete("\r\n\t"),
|
62
|
+
# title_intro: nil, language: "zh", script: "Hans" }]
|
63
|
+
tzh = doc.at("//h4").text.delete("\r\n\t")
|
64
|
+
RelatonBib::TypedTitleString.from_string tzh, "zh", "Hans"
|
63
65
|
# title_main = doc.at("//td[contains(text(), '英文标准名称')]").text.match(/[\w\s]+/).to_s
|
64
66
|
# unless title_main.empty?
|
65
67
|
# titles << { title_main: title_main, title_intro: nil, language: "en", script: "Latn" }
|
66
68
|
# end
|
67
|
-
titles
|
69
|
+
# titles
|
68
70
|
end
|
69
71
|
|
70
72
|
# @param _doc [Nokogiri::HTML::Document]
|
@@ -21,7 +21,7 @@ module RelatonGb
|
|
21
21
|
def scrape_page(text)
|
22
22
|
search_html = OpenURI.open_uri(
|
23
23
|
"http://www.ttbz.org.cn/Home/Standard?searchType=2&key=" +
|
24
|
-
CGI.escape(text.tr("-", [8212].pack("U")))
|
24
|
+
CGI.escape(text.tr("-", [8212].pack("U")))
|
25
25
|
).read
|
26
26
|
header = Nokogiri::HTML search_html
|
27
27
|
xpath = '//table[contains(@class, "standard_list_table")]/tr/td/a'
|
@@ -84,26 +84,21 @@ module RelatonGb
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def get_titles(doc)
|
87
|
-
|
88
|
-
titles =
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
titles
|
87
|
+
xpz = '//td[contains(.,"中文标题")]/following-sibling::td[1]'
|
88
|
+
titles = RelatonBib::TypedTitleString.from_string doc.at(xpz)
|
89
|
+
.text, "zh", "Hans"
|
90
|
+
xpe = '//td[contains(.,"英文标题")]/following-sibling::td[1]'
|
91
|
+
ten = doc.xpath(xpe).text
|
92
|
+
return titles if ten.empty?
|
93
|
+
|
94
|
+
titles + RelatonBib::TypedTitleString.from_string(ten, "en", "Latn")
|
97
95
|
end
|
98
96
|
|
99
97
|
def gbtype
|
100
|
-
{ scope: "social-group", prefix: "T", mandate: "mandatory",
|
98
|
+
{ scope: "social-group", prefix: "T", mandate: "mandatory",
|
99
|
+
topic: "other" }
|
101
100
|
end
|
102
101
|
|
103
|
-
# def get_group_code(ref)
|
104
|
-
# ref.match(%r{(?<=\/)[^\s]})
|
105
|
-
# end
|
106
|
-
|
107
102
|
def get_ccs(doc)
|
108
103
|
[doc.xpath('//td[contains(.,"中国标准分类号")]/following-sibling::td[1]')
|
109
104
|
.text.gsub(/[\r\n]/, "").strip.match(/^[^\s]+/).to_s]
|
data/lib/relaton_gb/version.rb
CHANGED
@@ -3,18 +3,15 @@ require "nokogiri"
|
|
3
3
|
module RelatonGb
|
4
4
|
class XMLParser < RelatonIsoBib::XMLParser
|
5
5
|
class << self
|
6
|
-
def from_xml(xml)
|
7
|
-
doc = Nokogiri::XML(xml)
|
8
|
-
gbitem = doc.at "/bibitem|/bibdata"
|
9
|
-
if gbitem
|
10
|
-
GbBibliographicItem.new item_data(gbitem)
|
11
|
-
else
|
12
|
-
warn "[relato-gb] can't find bibitem or bibdata element in the XML"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
6
|
private
|
17
7
|
|
8
|
+
# override RelatonBib::BibliographicItem.bib_item method
|
9
|
+
# @param item_hash [Hash]
|
10
|
+
# @return [RelatonGb::GbBibliographicItem]
|
11
|
+
def bib_item(item_hash)
|
12
|
+
GbBibliographicItem.new item_hash
|
13
|
+
end
|
14
|
+
|
18
15
|
def item_data(gbitem)
|
19
16
|
data = super
|
20
17
|
data[:committee] = fetch_committee gbitem
|
@@ -24,11 +21,6 @@ module RelatonGb
|
|
24
21
|
data
|
25
22
|
end
|
26
23
|
|
27
|
-
# Overrade get_id from RelatonIsoBib::XMLParser
|
28
|
-
# def get_id(did)
|
29
|
-
# did.text.match(/^(?<project>.*?\d+)(?<hyphen>-)?(?(<hyphen>)(?<year>\d*))/)
|
30
|
-
# end
|
31
|
-
|
32
24
|
def fetch_committee(doc)
|
33
25
|
committee = doc.at "./ext/gbcommittee"
|
34
26
|
return nil unless committee
|
data/relaton_gb.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-gb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
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: 2020-
|
11
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
187
|
+
version: 1.5.0
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 1.
|
194
|
+
version: 1.5.0
|
195
195
|
description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
|
196
196
|
the BibliographicItem model.'
|
197
197
|
email:
|
@@ -241,7 +241,7 @@ homepage: https://github.com/metanorma/relaton_gb
|
|
241
241
|
licenses:
|
242
242
|
- BSD-2-Clause
|
243
243
|
metadata: {}
|
244
|
-
post_install_message:
|
244
|
+
post_install_message:
|
245
245
|
rdoc_options: []
|
246
246
|
require_paths:
|
247
247
|
- lib
|
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
version: '0'
|
258
258
|
requirements: []
|
259
259
|
rubygems_version: 3.0.6
|
260
|
-
signing_key:
|
260
|
+
signing_key:
|
261
261
|
specification_version: 4
|
262
262
|
summary: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using the
|
263
263
|
BibliographicItem model.'
|