relaton-ieee 1.13.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +26 -85
- data/grammars/basicdoc.rng +3 -27
- data/grammars/biblio-standoc.rng +164 -0
- data/grammars/biblio.rng +82 -19
- data/grammars/relaton-ieee-compile.rng +11 -0
- data/grammars/relaton-ieee.rng +151 -0
- data/lib/relaton_ieee/data_parser.rb +2 -1
- data/lib/relaton_ieee/ieee_bibliographic_item.rb +11 -1
- data/lib/relaton_ieee/ieee_bibliography.rb +4 -2
- data/lib/relaton_ieee/version.rb +1 -1
- data/lib/relaton_ieee.rb +0 -1
- data/relaton_ieee.gemspec +3 -1
- metadata +35 -8
- data/grammars/isodoc.rng +0 -2807
- data/grammars/reqt.rng +0 -223
- data/lib/relaton_ieee/hit.rb +0 -9
- data/lib/relaton_ieee/scrapper.rb +0 -154
data/grammars/reqt.rng
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
-
<!--
|
4
|
-
Presupposes isodoc.rnc, is included in it
|
5
|
-
include "isodoc.rnc" { }
|
6
|
-
-->
|
7
|
-
<define name="requirement">
|
8
|
-
<element name="requirement">
|
9
|
-
<ref name="RequirementType"/>
|
10
|
-
</element>
|
11
|
-
</define>
|
12
|
-
<define name="recommendation">
|
13
|
-
<element name="recommendation">
|
14
|
-
<ref name="RequirementType"/>
|
15
|
-
</element>
|
16
|
-
</define>
|
17
|
-
<define name="permission">
|
18
|
-
<element name="permission">
|
19
|
-
<ref name="RequirementType"/>
|
20
|
-
</element>
|
21
|
-
</define>
|
22
|
-
<define name="RequirementType">
|
23
|
-
<optional>
|
24
|
-
<attribute name="obligation">
|
25
|
-
<ref name="ObligationType"/>
|
26
|
-
</attribute>
|
27
|
-
</optional>
|
28
|
-
<optional>
|
29
|
-
<attribute name="unnumbered">
|
30
|
-
<data type="boolean"/>
|
31
|
-
</attribute>
|
32
|
-
</optional>
|
33
|
-
<optional>
|
34
|
-
<attribute name="number"/>
|
35
|
-
</optional>
|
36
|
-
<optional>
|
37
|
-
<attribute name="subsequence"/>
|
38
|
-
</optional>
|
39
|
-
<optional>
|
40
|
-
<attribute name="keep-with-next">
|
41
|
-
<data type="boolean"/>
|
42
|
-
</attribute>
|
43
|
-
</optional>
|
44
|
-
<optional>
|
45
|
-
<attribute name="keep-lines-together">
|
46
|
-
<data type="boolean"/>
|
47
|
-
</attribute>
|
48
|
-
</optional>
|
49
|
-
<attribute name="id">
|
50
|
-
<data type="ID"/>
|
51
|
-
</attribute>
|
52
|
-
<optional>
|
53
|
-
<attribute name="filename"/>
|
54
|
-
</optional>
|
55
|
-
<optional>
|
56
|
-
<attribute name="model"/>
|
57
|
-
</optional>
|
58
|
-
<optional>
|
59
|
-
<attribute name="type"/>
|
60
|
-
</optional>
|
61
|
-
<optional>
|
62
|
-
<attribute name="tag"/>
|
63
|
-
</optional>
|
64
|
-
<optional>
|
65
|
-
<attribute name="multilingual-rendering">
|
66
|
-
<ref name="MultilingualRenderingType"/>
|
67
|
-
</attribute>
|
68
|
-
</optional>
|
69
|
-
<optional>
|
70
|
-
<ref name="reqtitle"/>
|
71
|
-
</optional>
|
72
|
-
<optional>
|
73
|
-
<ref name="label"/>
|
74
|
-
</optional>
|
75
|
-
<zeroOrMore>
|
76
|
-
<ref name="subject"/>
|
77
|
-
</zeroOrMore>
|
78
|
-
<zeroOrMore>
|
79
|
-
<ref name="reqinherit"/>
|
80
|
-
</zeroOrMore>
|
81
|
-
<zeroOrMore>
|
82
|
-
<ref name="classification"/>
|
83
|
-
</zeroOrMore>
|
84
|
-
<zeroOrMore>
|
85
|
-
<choice>
|
86
|
-
<ref name="measurementtarget"/>
|
87
|
-
<ref name="specification"/>
|
88
|
-
<ref name="verification"/>
|
89
|
-
<ref name="import"/>
|
90
|
-
<ref name="description"/>
|
91
|
-
<ref name="component"/>
|
92
|
-
</choice>
|
93
|
-
</zeroOrMore>
|
94
|
-
<optional>
|
95
|
-
<ref name="reqt_references"/>
|
96
|
-
</optional>
|
97
|
-
<zeroOrMore>
|
98
|
-
<choice>
|
99
|
-
<ref name="requirement"/>
|
100
|
-
<ref name="recommendation"/>
|
101
|
-
<ref name="permission"/>
|
102
|
-
</choice>
|
103
|
-
</zeroOrMore>
|
104
|
-
</define>
|
105
|
-
<define name="reqtitle">
|
106
|
-
<element name="title">
|
107
|
-
<ref name="FormattedString"/>
|
108
|
-
</element>
|
109
|
-
</define>
|
110
|
-
<define name="label">
|
111
|
-
<element name="label">
|
112
|
-
<oneOrMore>
|
113
|
-
<ref name="TextElement"/>
|
114
|
-
</oneOrMore>
|
115
|
-
</element>
|
116
|
-
</define>
|
117
|
-
<define name="subject">
|
118
|
-
<element name="subject">
|
119
|
-
<oneOrMore>
|
120
|
-
<ref name="TextElement"/>
|
121
|
-
</oneOrMore>
|
122
|
-
</element>
|
123
|
-
</define>
|
124
|
-
<define name="reqinherit">
|
125
|
-
<element name="inherit">
|
126
|
-
<oneOrMore>
|
127
|
-
<ref name="TextElement"/>
|
128
|
-
</oneOrMore>
|
129
|
-
</element>
|
130
|
-
</define>
|
131
|
-
<define name="measurementtarget">
|
132
|
-
<element name="measurement-target">
|
133
|
-
<ref name="RequirementSubpart"/>
|
134
|
-
</element>
|
135
|
-
</define>
|
136
|
-
<define name="specification">
|
137
|
-
<element name="specification">
|
138
|
-
<ref name="RequirementSubpart"/>
|
139
|
-
</element>
|
140
|
-
</define>
|
141
|
-
<define name="verification">
|
142
|
-
<element name="verification">
|
143
|
-
<ref name="RequirementSubpart"/>
|
144
|
-
</element>
|
145
|
-
</define>
|
146
|
-
<define name="import">
|
147
|
-
<element name="import">
|
148
|
-
<ref name="RequirementSubpart"/>
|
149
|
-
</element>
|
150
|
-
</define>
|
151
|
-
<define name="description">
|
152
|
-
<element name="description">
|
153
|
-
<ref name="RequirementSubpart"/>
|
154
|
-
</element>
|
155
|
-
</define>
|
156
|
-
<define name="component">
|
157
|
-
<element name="component">
|
158
|
-
<attribute name="class"/>
|
159
|
-
<ref name="RequirementSubpart"/>
|
160
|
-
</element>
|
161
|
-
</define>
|
162
|
-
<define name="reqt_references">
|
163
|
-
<element name="references">
|
164
|
-
<oneOrMore>
|
165
|
-
<ref name="bibitem"/>
|
166
|
-
</oneOrMore>
|
167
|
-
</element>
|
168
|
-
</define>
|
169
|
-
<define name="RequirementSubpart">
|
170
|
-
<optional>
|
171
|
-
<attribute name="type"/>
|
172
|
-
</optional>
|
173
|
-
<optional>
|
174
|
-
<attribute name="exclude">
|
175
|
-
<data type="boolean"/>
|
176
|
-
</attribute>
|
177
|
-
</optional>
|
178
|
-
<optional>
|
179
|
-
<attribute name="keep-with-next">
|
180
|
-
<data type="boolean"/>
|
181
|
-
</attribute>
|
182
|
-
</optional>
|
183
|
-
<optional>
|
184
|
-
<attribute name="keep-lines-together">
|
185
|
-
<data type="boolean"/>
|
186
|
-
</attribute>
|
187
|
-
</optional>
|
188
|
-
<optional>
|
189
|
-
<attribute name="tag"/>
|
190
|
-
</optional>
|
191
|
-
<optional>
|
192
|
-
<attribute name="multilingual-rendering">
|
193
|
-
<ref name="MultilingualRenderingType"/>
|
194
|
-
</attribute>
|
195
|
-
</optional>
|
196
|
-
<oneOrMore>
|
197
|
-
<ref name="BasicBlock"/>
|
198
|
-
</oneOrMore>
|
199
|
-
</define>
|
200
|
-
<define name="ObligationType">
|
201
|
-
<choice>
|
202
|
-
<value>requirement</value>
|
203
|
-
<value>recommendation</value>
|
204
|
-
<value>permission</value>
|
205
|
-
</choice>
|
206
|
-
</define>
|
207
|
-
<define name="classification">
|
208
|
-
<element name="classification">
|
209
|
-
<ref name="classification_tag"/>
|
210
|
-
<ref name="classification_value"/>
|
211
|
-
</element>
|
212
|
-
</define>
|
213
|
-
<define name="classification_tag">
|
214
|
-
<element name="tag">
|
215
|
-
<text/>
|
216
|
-
</element>
|
217
|
-
</define>
|
218
|
-
<define name="classification_value">
|
219
|
-
<element name="value">
|
220
|
-
<text/>
|
221
|
-
</element>
|
222
|
-
</define>
|
223
|
-
</grammar>
|
data/lib/relaton_ieee/hit.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
module RelatonIeee
|
2
|
-
module Scrapper
|
3
|
-
class << self
|
4
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
5
|
-
|
6
|
-
# papam hit [Hash]
|
7
|
-
# @return [RelatonOgc::OrcBibliographicItem]
|
8
|
-
def parse_page(hit)
|
9
|
-
doc = Nokogiri::HTML Faraday.get(hit[:url]).body
|
10
|
-
IeeeBibliographicItem.new(
|
11
|
-
fetched: Date.today.to_s,
|
12
|
-
title: fetch_title(doc),
|
13
|
-
docid: fetch_docid(hit[:ref]),
|
14
|
-
link: fetch_link(hit[:url]),
|
15
|
-
docstatus: fetch_status(doc),
|
16
|
-
abstract: fetch_abstract(doc),
|
17
|
-
contributor: fetch_contributor(doc),
|
18
|
-
language: ["en"],
|
19
|
-
script: ["Latn"],
|
20
|
-
date: fetch_date(doc),
|
21
|
-
editorialgroup: fetch_editorialgroup(doc),
|
22
|
-
place: ["Piscataway, NJ, USA"],
|
23
|
-
)
|
24
|
-
end
|
25
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
# @param doc [String] Nokogiri::HTML4::Document
|
30
|
-
# @return [Array<RelatonBib::TypedTitleString>]
|
31
|
-
def fetch_title(doc)
|
32
|
-
doc.xpath("//h2[@id='stnd-title']").map do |t|
|
33
|
-
RelatonBib::TypedTitleString.new(
|
34
|
-
type: "main", content: t.text, language: "en", script: "Latn",
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# @param ref [String]
|
40
|
-
# @return [Array<RelatonBib::DocumentIdentifier>]
|
41
|
-
def fetch_docid(ref)
|
42
|
-
args = { id: ref, type: "IEEE", primary: true }
|
43
|
-
ids = [RelatonBib::DocumentIdentifier.new(**args)]
|
44
|
-
args[:scope] = "trademark"
|
45
|
-
tm = ref.match?(/^IEEE\s(Std\s)?(802|2030)/) ? "\u00AE" : "\u2122"
|
46
|
-
args[:id] = ref.sub(/^(IEEE\s(?:Std\s)?[.\w]+)/) { |s| "#{s}#{tm}" }
|
47
|
-
ids << RelatonBib::DocumentIdentifier.new(**args)
|
48
|
-
end
|
49
|
-
|
50
|
-
# @param url [String]
|
51
|
-
# @return [Array>RelatonBib::TypedUri>]
|
52
|
-
def fetch_link(url)
|
53
|
-
[RelatonBib::TypedUri.new(type: "src", content: url)]
|
54
|
-
end
|
55
|
-
|
56
|
-
# @param doc [Nokogiri::HTML::Document]
|
57
|
-
# @return [RelatonBib::DocumentStatus, NilClass]
|
58
|
-
def fetch_status(doc)
|
59
|
-
stage = doc.at("//dd[@id='stnd-status']")
|
60
|
-
return unless stage
|
61
|
-
|
62
|
-
DocumentStatus.new(stage: stage.text.split.first)
|
63
|
-
end
|
64
|
-
|
65
|
-
# @param identifier [String]
|
66
|
-
# @return [String]
|
67
|
-
# def fetch_edition(identifier)
|
68
|
-
# %r{(?<=r)(?<edition>\d+)$} =~ identifier
|
69
|
-
# edition
|
70
|
-
# end
|
71
|
-
|
72
|
-
# @param doc [Nokogiri::HTML::Document]
|
73
|
-
# @return [Array<RelatonBib::FormattedString>]
|
74
|
-
def fetch_abstract(doc)
|
75
|
-
doc.xpath("//div[@id='stnd-description']").map do |a|
|
76
|
-
RelatonBib::FormattedString.new(
|
77
|
-
content: a.text.strip, language: "en", script: "Latn",
|
78
|
-
)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# @param doc [Nokogiri::HTML::Document]
|
83
|
-
# @return [Array<RelatonBib::ContributionInfo>]
|
84
|
-
def fetch_contributor(doc) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
85
|
-
address = RelatonBib::Address.new(
|
86
|
-
street: ["445 Hoes Lane"], postcode: "08854-4141", city: "Piscataway",
|
87
|
-
state: "NJ", country: "USA"
|
88
|
-
)
|
89
|
-
org = RelatonBib::Organization.new(
|
90
|
-
name: "Institute of Electrical and Electronics Engineers",
|
91
|
-
abbreviation: "IEEE", contact: [address]
|
92
|
-
)
|
93
|
-
contrib = RelatonBib::ContributionInfo.new(entity: org, role: [type: "publisher"])
|
94
|
-
doc.xpath("//dd[@id='stnd-staff-liaison']/text()").map do |name|
|
95
|
-
person_contrib(name.text.strip)
|
96
|
-
end << contrib
|
97
|
-
end
|
98
|
-
|
99
|
-
# @param name [String]
|
100
|
-
# @return [RelatonBib::ContributionInfo]
|
101
|
-
def person_contrib(name)
|
102
|
-
fname = RelatonBib::FullName.new(
|
103
|
-
completename: RelatonBib::LocalizedString.new(name),
|
104
|
-
)
|
105
|
-
entity = RelatonBib::Person.new(name: fname)
|
106
|
-
RelatonBib::ContributionInfo.new(
|
107
|
-
entity: entity, role: [type: "author"],
|
108
|
-
)
|
109
|
-
end
|
110
|
-
|
111
|
-
# @param name [String]
|
112
|
-
# @return [RelatonBib::ContributionInfo]
|
113
|
-
# def org_contrib(name)
|
114
|
-
# entity = RelatonBib::Organization.new(name: name)
|
115
|
-
# RelatonBib::ContributionInfo.new(
|
116
|
-
# entity: entity, role: [type: "publisher"],
|
117
|
-
# )
|
118
|
-
# end
|
119
|
-
|
120
|
-
# @param date [Nokogiri::HTML::Document]
|
121
|
-
# @return [Array<RelatonBib::BibliographicDate>]
|
122
|
-
def fetch_date(doc)
|
123
|
-
dates = []
|
124
|
-
id = doc.at "//dd[@id='stnd-approval-date']"
|
125
|
-
if id
|
126
|
-
dates << RelatonBib::BibliographicDate.new(type: "issued", on: id.text)
|
127
|
-
end
|
128
|
-
pd = doc.at("//dd[@id='stnd-published-date']")
|
129
|
-
if pd
|
130
|
-
dates << RelatonBib::BibliographicDate.new(type: "published", on: pd.text)
|
131
|
-
end
|
132
|
-
dates
|
133
|
-
end
|
134
|
-
|
135
|
-
#
|
136
|
-
# @param doc [Nokogiri::HTML::Document]
|
137
|
-
#
|
138
|
-
# @return [RelatonIeee::EditorialGroup]
|
139
|
-
#
|
140
|
-
def fetch_editorialgroup(doc) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
141
|
-
committees = doc.xpath(
|
142
|
-
"//dd[@id='stnd-committee']/text()",
|
143
|
-
"//td[.='Standards Committee']/following-sibling::td/div/a",
|
144
|
-
).map { |c| c.text.strip }
|
145
|
-
wg = doc.at("//dd[@id='stnd-working-group']/text()")&.text&.strip
|
146
|
-
# chair = doc.at "//dd[@id='stnd-working-group-chair']"
|
147
|
-
society = doc.at("//dd[@id='stnd-society']/text()")&.text&.strip
|
148
|
-
return unless committees.any? || wg || society
|
149
|
-
|
150
|
-
EditorialGroup.new(society: society, working_group: wg, committee: committees)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|