relaton-ieee 1.9.3 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/grammars/basicdoc.rng +26 -7
- data/grammars/biblio.rng +7 -5
- data/grammars/isodoc.rng +617 -89
- data/grammars/reqt.rng +34 -5
- data/lib/relaton_ieee/bibxml_parser.rb +11 -2
- data/lib/relaton_ieee/data_parser.rb +8 -4
- data/lib/relaton_ieee/hit_collection.rb +15 -14
- data/lib/relaton_ieee/ieee_bibliography.rb +3 -3
- data/lib/relaton_ieee/scrapper.rb +50 -47
- data/lib/relaton_ieee/version.rb +1 -1
- data/relaton_ieee.gemspec +1 -1
- metadata +6 -6
data/grammars/reqt.rng
CHANGED
@@ -58,15 +58,23 @@
|
|
58
58
|
<optional>
|
59
59
|
<attribute name="type"/>
|
60
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>
|
61
69
|
<optional>
|
62
70
|
<ref name="reqtitle"/>
|
63
71
|
</optional>
|
64
72
|
<optional>
|
65
73
|
<ref name="label"/>
|
66
74
|
</optional>
|
67
|
-
<
|
75
|
+
<zeroOrMore>
|
68
76
|
<ref name="subject"/>
|
69
|
-
</
|
77
|
+
</zeroOrMore>
|
70
78
|
<zeroOrMore>
|
71
79
|
<ref name="reqinherit"/>
|
72
80
|
</zeroOrMore>
|
@@ -80,6 +88,7 @@
|
|
80
88
|
<ref name="verification"/>
|
81
89
|
<ref name="import"/>
|
82
90
|
<ref name="description"/>
|
91
|
+
<ref name="component"/>
|
83
92
|
</choice>
|
84
93
|
</zeroOrMore>
|
85
94
|
<optional>
|
@@ -100,17 +109,23 @@
|
|
100
109
|
</define>
|
101
110
|
<define name="label">
|
102
111
|
<element name="label">
|
103
|
-
<
|
112
|
+
<oneOrMore>
|
113
|
+
<ref name="TextElement"/>
|
114
|
+
</oneOrMore>
|
104
115
|
</element>
|
105
116
|
</define>
|
106
117
|
<define name="subject">
|
107
118
|
<element name="subject">
|
108
|
-
<
|
119
|
+
<oneOrMore>
|
120
|
+
<ref name="TextElement"/>
|
121
|
+
</oneOrMore>
|
109
122
|
</element>
|
110
123
|
</define>
|
111
124
|
<define name="reqinherit">
|
112
125
|
<element name="inherit">
|
113
|
-
<
|
126
|
+
<oneOrMore>
|
127
|
+
<ref name="TextElement"/>
|
128
|
+
</oneOrMore>
|
114
129
|
</element>
|
115
130
|
</define>
|
116
131
|
<define name="measurementtarget">
|
@@ -138,6 +153,12 @@
|
|
138
153
|
<ref name="RequirementSubpart"/>
|
139
154
|
</element>
|
140
155
|
</define>
|
156
|
+
<define name="component">
|
157
|
+
<element name="component">
|
158
|
+
<attribute name="class"/>
|
159
|
+
<ref name="RequirementSubpart"/>
|
160
|
+
</element>
|
161
|
+
</define>
|
141
162
|
<define name="reqt_references">
|
142
163
|
<element name="references">
|
143
164
|
<oneOrMore>
|
@@ -164,6 +185,14 @@
|
|
164
185
|
<data type="boolean"/>
|
165
186
|
</attribute>
|
166
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>
|
167
196
|
<oneOrMore>
|
168
197
|
<ref name="BasicBlock"/>
|
169
198
|
</oneOrMore>
|
@@ -3,12 +3,21 @@ module RelatonIeee
|
|
3
3
|
extend RelatonBib::BibXMLParser
|
4
4
|
extend BibXMLParser
|
5
5
|
|
6
|
-
FLAVOR = "IEEE".freeze
|
7
|
-
|
8
6
|
# @param attrs [Hash]
|
9
7
|
# @return [RelatonBib::IetfBibliographicItem]
|
10
8
|
def bib_item(**attrs)
|
11
9
|
IeeeBibliographicItem.new(**attrs)
|
12
10
|
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Return PubID type
|
14
|
+
#
|
15
|
+
# @param [String] _ docidentifier
|
16
|
+
#
|
17
|
+
# @return [String] type
|
18
|
+
#
|
19
|
+
def pubid_type(_)
|
20
|
+
"IEEE"
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
@@ -57,11 +57,15 @@ module RelatonIeee
|
|
57
57
|
#
|
58
58
|
# Parse title
|
59
59
|
#
|
60
|
-
# @return [RelatonBib::
|
60
|
+
# @return [Array<RelatonBib::TypedTitleString>]
|
61
61
|
#
|
62
62
|
def parse_title
|
63
|
-
t =
|
64
|
-
|
63
|
+
t = []
|
64
|
+
content = doc.at("./volume/article/title").text
|
65
|
+
if content =~ /\A(.+)\s-\sredline\z/i
|
66
|
+
t << RelatonBib::TypedTitleString.new(content: $1, type: "title-main")
|
67
|
+
end
|
68
|
+
t << RelatonBib::TypedTitleString.new(content: content, type: "main")
|
65
69
|
end
|
66
70
|
|
67
71
|
#
|
@@ -110,7 +114,7 @@ module RelatonIeee
|
|
110
114
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
111
115
|
#
|
112
116
|
def parse_docid
|
113
|
-
ids = [{ id: pubid.to_s, type: "IEEE" }]
|
117
|
+
ids = [{ id: pubid.to_s, type: "IEEE", primary: true }]
|
114
118
|
isbn = doc.at("./publicationinfo/isbn")
|
115
119
|
ids << { id: isbn.text, type: "ISBN" } if isbn
|
116
120
|
doi = doc.at("./volume/article/articleinfo/articledoi")
|
@@ -11,23 +11,24 @@ module RelatonIeee
|
|
11
11
|
|
12
12
|
# rubocop:disable Metrics/AbcSize
|
13
13
|
|
14
|
-
# @param
|
14
|
+
# @param reference [Strig]
|
15
15
|
# @param opts [Hash]
|
16
|
-
def initialize(
|
16
|
+
def initialize(reference) # rubocop:disable Metrics/MethodLength
|
17
17
|
super
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
resp = Faraday.
|
22
|
-
|
23
|
-
|
24
|
-
@array =
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
code1 = reference.sub(/^IEEE\s(Std\s)?/, "")
|
19
|
+
url = "#{DOMAIN}/wp-admin/admin-ajax.php"
|
20
|
+
query = reference.gsub("/", " ")
|
21
|
+
resp = Faraday.post url, { action: "ieee_cloudsearch", q: query }
|
22
|
+
json = JSON.parse resp.body
|
23
|
+
html = Nokogiri::HTML json["html"]
|
24
|
+
@array = html.xpath("//h4/a").reduce([]) do |s, hit|
|
25
|
+
ref = hit.text.strip
|
26
|
+
/^(?:\w+\s)?(?<code2>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ ref
|
27
|
+
next s unless code2 && code1 =~ %r{^#{code2}}
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
hit_data = { ref: ref, year: year.to_i, url: hit[:href] }
|
30
|
+
s << Hit.new(hit_data, self)
|
31
|
+
end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
|
31
32
|
end
|
32
33
|
# rubocop:enable Metrics/AbcSize
|
33
34
|
end
|
@@ -15,7 +15,7 @@ module RelatonIeee
|
|
15
15
|
#
|
16
16
|
# @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
|
17
17
|
# if document is found else returns NilClass
|
18
|
-
def get(code, year = nil, _opts = {})
|
18
|
+
def get(code, year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
19
19
|
warn "[relaton-ieee] (\"#{code}\") fetching..."
|
20
20
|
result = search(code) || (return nil)
|
21
21
|
year ||= code.match(/(?<=-)\d{4}/)&.to_s
|
@@ -42,11 +42,11 @@ module RelatonIeee
|
|
42
42
|
# @param opts [Hash] options
|
43
43
|
#
|
44
44
|
# @return [Hash]
|
45
|
-
def bib_results_filter(result, ref, year)
|
45
|
+
def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
|
46
46
|
rp1 = ref_parts ref
|
47
47
|
missed_years = []
|
48
48
|
result.each do |hit|
|
49
|
-
rp2 = ref_parts hit.hit[
|
49
|
+
rp2 = ref_parts hit.hit[:ref]
|
50
50
|
next if rp1[:code] != rp2[:code] || rp1[:corr] != rp2[:corr]
|
51
51
|
|
52
52
|
return { ret: hit } if !year
|
@@ -6,40 +6,40 @@ module RelatonIeee
|
|
6
6
|
# papam hit [Hash]
|
7
7
|
# @return [RelatonOgc::OrcBibliographicItem]
|
8
8
|
def parse_page(hit)
|
9
|
-
doc = Nokogiri::HTML Faraday.get(hit[
|
9
|
+
doc = Nokogiri::HTML Faraday.get(hit[:url]).body
|
10
10
|
IeeeBibliographicItem.new(
|
11
11
|
fetched: Date.today.to_s,
|
12
|
-
title: fetch_title(
|
13
|
-
docid: fetch_docid(hit[
|
14
|
-
link: fetch_link(hit[
|
12
|
+
title: fetch_title(doc),
|
13
|
+
docid: fetch_docid(hit[:ref]),
|
14
|
+
link: fetch_link(hit[:url]),
|
15
15
|
docstatus: fetch_status(doc),
|
16
16
|
abstract: fetch_abstract(doc),
|
17
17
|
contributor: fetch_contributor(doc),
|
18
18
|
language: ["en"],
|
19
19
|
script: ["Latn"],
|
20
20
|
date: fetch_date(doc),
|
21
|
-
committee: fetch_committee(doc)
|
21
|
+
committee: fetch_committee(doc),
|
22
|
+
place: ["Piscataway, NJ, USA"],
|
22
23
|
)
|
23
24
|
end
|
24
25
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
|
-
# @param
|
29
|
+
# @param doc [String] Nokogiri::HTML4::Document
|
29
30
|
# @return [Array<RelatonBib::TypedTitleString>]
|
30
|
-
def fetch_title(
|
31
|
-
[
|
31
|
+
def fetch_title(doc)
|
32
|
+
doc.xpath("//h2[@id='stnd-title']").map do |t|
|
32
33
|
RelatonBib::TypedTitleString.new(
|
33
|
-
type: "main", content:
|
34
|
-
)
|
35
|
-
|
34
|
+
type: "main", content: t.text, language: "en", script: "Latn",
|
35
|
+
)
|
36
|
+
end
|
36
37
|
end
|
37
38
|
|
38
|
-
# @param
|
39
|
+
# @param ref [String]
|
39
40
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
40
|
-
def fetch_docid(
|
41
|
-
|
42
|
-
[RelatonBib::DocumentIdentifier.new(id: identifier, type: "IEEE")]
|
41
|
+
def fetch_docid(ref)
|
42
|
+
[RelatonBib::DocumentIdentifier.new(id: ref, type: "IEEE", primary: true)]
|
43
43
|
end
|
44
44
|
|
45
45
|
# @param url [String]
|
@@ -51,10 +51,10 @@ module RelatonIeee
|
|
51
51
|
# @param doc [Nokogiri::HTML::Document]
|
52
52
|
# @return [RelatonBib::DocumentStatus, NilClass]
|
53
53
|
def fetch_status(doc)
|
54
|
-
stage = doc.at("//
|
54
|
+
stage = doc.at("//dd[@id='stnd-status']")
|
55
55
|
return unless stage
|
56
56
|
|
57
|
-
RelatonBib::DocumentStatus.new(stage: stage.text)
|
57
|
+
RelatonBib::DocumentStatus.new(stage: stage.text.split.first)
|
58
58
|
end
|
59
59
|
|
60
60
|
# @param identifier [String]
|
@@ -67,33 +67,39 @@ module RelatonIeee
|
|
67
67
|
# @param doc [Nokogiri::HTML::Document]
|
68
68
|
# @return [Array<RelatonBib::FormattedString>]
|
69
69
|
def fetch_abstract(doc)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
doc.xpath("//div[@id='stnd-description']").map do |a|
|
71
|
+
RelatonBib::FormattedString.new(
|
72
|
+
content: a.text.strip, language: "en", script: "Latn",
|
73
|
+
)
|
74
|
+
end
|
75
75
|
end
|
76
76
|
|
77
77
|
# @param doc [Nokogiri::HTML::Document]
|
78
78
|
# @return [Array<RelatonBib::ContributionInfo>]
|
79
|
-
def fetch_contributor(doc)
|
80
|
-
|
81
|
-
"
|
79
|
+
def fetch_contributor(doc) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
80
|
+
address = RelatonBib::Address.new(
|
81
|
+
street: ["445 Hoes Lane"], postcode: "08854-4141", city: "Piscataway",
|
82
|
+
state: "NJ", country: "USA"
|
82
83
|
)
|
83
|
-
|
84
|
-
|
85
|
-
|
84
|
+
org = RelatonBib::Organization.new(
|
85
|
+
name: "Institute of Electrical and Electronics Engineers",
|
86
|
+
abbreviation: "IEEE", contact: [address]
|
87
|
+
)
|
88
|
+
contrib = RelatonBib::ContributionInfo.new(entity: org, role: [type: "publisher"])
|
89
|
+
doc.xpath("//dd[@id='stnd-staff-liaison']/text()").map do |name|
|
90
|
+
person_contrib(name.text.strip)
|
91
|
+
end << contrib
|
86
92
|
end
|
87
93
|
|
88
94
|
# @param name [String]
|
89
95
|
# @return [RelatonBib::ContributionInfo]
|
90
|
-
def
|
96
|
+
def person_contrib(name)
|
91
97
|
fname = RelatonBib::FullName.new(
|
92
|
-
completename: RelatonBib::LocalizedString.new(name)
|
98
|
+
completename: RelatonBib::LocalizedString.new(name),
|
93
99
|
)
|
94
100
|
entity = RelatonBib::Person.new(name: fname)
|
95
101
|
RelatonBib::ContributionInfo.new(
|
96
|
-
entity: entity, role: [type: "author"]
|
102
|
+
entity: entity, role: [type: "author"],
|
97
103
|
)
|
98
104
|
end
|
99
105
|
|
@@ -112,16 +118,13 @@ module RelatonIeee
|
|
112
118
|
# @return [Array<RelatonBib::BibliographicDate>]
|
113
119
|
def fetch_date(doc)
|
114
120
|
dates = []
|
115
|
-
|
116
|
-
if
|
117
|
-
dates << RelatonBib::BibliographicDate.new(type: "issued",
|
118
|
-
on: issued.text)
|
121
|
+
id = doc.at "//dd[@id='stnd-approval-date']"
|
122
|
+
if id
|
123
|
+
dates << RelatonBib::BibliographicDate.new(type: "issued", on: id.text)
|
119
124
|
end
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
dates << RelatonBib::BibliographicDate.new(type: "published",
|
124
|
-
on: published)
|
125
|
+
pd = doc.at("//dd[@id='stnd-published-date']")
|
126
|
+
if pd
|
127
|
+
dates << RelatonBib::BibliographicDate.new(type: "published", on: pd.text)
|
125
128
|
end
|
126
129
|
dates
|
127
130
|
end
|
@@ -132,23 +135,23 @@ module RelatonIeee
|
|
132
135
|
# @return [Array<RelatonIeee::Committee>]
|
133
136
|
def fetch_committee(doc)
|
134
137
|
committees = []
|
135
|
-
sponsor = doc.at "//
|
138
|
+
sponsor = doc.at "//dd[@id='stnd-committee']/text()"
|
136
139
|
if sponsor
|
137
|
-
committees << Committee.new(type: "sponsor", name: sponsor.text)
|
140
|
+
committees << Committee.new(type: "sponsor", name: sponsor.text.strip)
|
138
141
|
end
|
139
142
|
sponsor = doc.at "//td[.='Standards Committee']/following-sibling::td/div/a"
|
140
143
|
if sponsor
|
141
144
|
committees << Committee.new(type: "standard", name: sponsor.text)
|
142
145
|
end
|
143
|
-
working = doc.at "//
|
144
|
-
chair = doc.at "//td[.='Working Group Chair']/following-sibling::td/div"
|
146
|
+
working = doc.at "//dd[@id='stnd-working-group']/text()"
|
145
147
|
if working
|
146
|
-
|
148
|
+
chair = doc.at "//dd[@id='stnd-working-group-chair']"
|
149
|
+
committees << Committee.new(type: "working", name: working.text.strip,
|
147
150
|
chair: chair.text)
|
148
151
|
end
|
149
|
-
society = doc.at "//
|
152
|
+
society = doc.at "//dd[@id='stnd-society']/text()"
|
150
153
|
if society
|
151
|
-
committees << Committee.new(type: "society", name: society.text)
|
154
|
+
committees << Committee.new(type: "society", name: society.text.strip)
|
152
155
|
end
|
153
156
|
committees
|
154
157
|
end
|
data/lib/relaton_ieee/version.rb
CHANGED
data/relaton_ieee.gemspec
CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "webmock"
|
39
39
|
|
40
40
|
spec.add_dependency "faraday", "~> 1.1"
|
41
|
-
spec.add_dependency "relaton-bib", "
|
41
|
+
spec.add_dependency "relaton-bib", "~> 1.10.1"
|
42
42
|
spec.add_dependency "rubyzip", "~> 2.3.0"
|
43
43
|
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.
|
4
|
+
version: 1.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: relaton-bib
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.10.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.10.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubyzip
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|