stepmod-utils 0.2.7 → 0.3.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/exe/stepmod-extract-terms +140 -13
- data/lib/stepmod/utils/bibdata.rb +2 -0
- data/lib/stepmod/utils/concept.rb +12 -2
- data/lib/stepmod/utils/converters/arm.rb +22 -0
- data/lib/stepmod/utils/converters/def.rb +1 -0
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +17 -0
- data/lib/stepmod/utils/converters/uof.rb +21 -0
- data/lib/stepmod/utils/stepmod_definition_converter.rb +3 -0
- data/lib/stepmod/utils/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1006db3b3828bc38932f36a4f410cf6f8a0d5669bf0c3357c7a204c84e587a44
|
|
4
|
+
data.tar.gz: 7fa819c6ee34eef23ad8ab20fd3a833296a36bf99ca48cb624a81a04049871ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40f09784e7aeac5e8e35c24079e84c5119dc9cd00f9555a4c24c1ce389e4b28bb32e0f6ec8c4408b3a1fea0445cfa16ca3700a263517b28c935c9ddca7de8cbb
|
|
7
|
+
data.tar.gz: dd35cce57f836527e31a6bd36576f6966494f558d1a0cc87486632c3149b1eecf66f37493f188f0a1ff685b804ddedb33bc13c1c6d45e5142335710ea7dea88c
|
data/exe/stepmod-extract-terms
CHANGED
|
@@ -24,7 +24,12 @@ require 'ptools'
|
|
|
24
24
|
|
|
25
25
|
ReverseAdoc.config.unknown_tags = :bypass
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
# TODO: we may want a command line option to override this in the future
|
|
28
|
+
ACCEPTED_STAGES = %w(IS DIS FDIS TS)
|
|
29
|
+
|
|
30
|
+
general_concepts = []
|
|
31
|
+
resource_concepts = []
|
|
32
|
+
module_concepts = []
|
|
28
33
|
parsed_bibliography = []
|
|
29
34
|
encountered_terms = {}
|
|
30
35
|
|
|
@@ -34,6 +39,40 @@ def log message
|
|
|
34
39
|
puts "[stepmod-utils] #{message}"
|
|
35
40
|
end
|
|
36
41
|
|
|
42
|
+
def term_special_category(bibdata)
|
|
43
|
+
case bibdata.part.to_i
|
|
44
|
+
when 41,42,43,44,45,46,47,51
|
|
45
|
+
true
|
|
46
|
+
when [56..112]
|
|
47
|
+
true
|
|
48
|
+
else
|
|
49
|
+
false
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def part_to_title(bibdata)
|
|
54
|
+
case bibdata.part.to_i
|
|
55
|
+
when 41
|
|
56
|
+
"Part 41"
|
|
57
|
+
when 42
|
|
58
|
+
"Geometric and topological representation"
|
|
59
|
+
when 43
|
|
60
|
+
"Foundation representation"
|
|
61
|
+
when 44
|
|
62
|
+
"Product structure, concept and configuration"
|
|
63
|
+
when 45
|
|
64
|
+
"Part 45"
|
|
65
|
+
when 46
|
|
66
|
+
"Visual presentation"
|
|
67
|
+
when 47
|
|
68
|
+
"Shape tolerance"
|
|
69
|
+
when 51
|
|
70
|
+
"Mathematical representation"
|
|
71
|
+
else
|
|
72
|
+
bibdata.title_en
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
37
76
|
stepmod_path = Pathname.new(stepmod_dir).realpath
|
|
38
77
|
|
|
39
78
|
# If we are using the stepmod CVS repository, provide the revision number per file
|
|
@@ -57,9 +96,14 @@ files = %w(
|
|
|
57
96
|
business_object_model.xml
|
|
58
97
|
module.xml
|
|
59
98
|
).inject([]) do |acc, t|
|
|
60
|
-
|
|
99
|
+
|
|
100
|
+
candidate_paths = Dir["#{stepmod_dir}/**/#{t}"]
|
|
101
|
+
acc << candidate_paths
|
|
102
|
+
|
|
61
103
|
end.flatten.sort.uniq
|
|
62
104
|
|
|
105
|
+
max_encountered_refs_indexes = {}
|
|
106
|
+
|
|
63
107
|
files.each do |file_path|
|
|
64
108
|
file_path = Pathname.new(file_path).realpath
|
|
65
109
|
fpath = file_path.relative_path_from(stepmod_path)
|
|
@@ -75,9 +119,8 @@ files.each do |file_path|
|
|
|
75
119
|
next
|
|
76
120
|
end
|
|
77
121
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
log "INFO: skipped #{bibdata.docid} as it is not IS, DIS or TS"
|
|
122
|
+
unless ACCEPTED_STAGES.include? bibdata.doctype
|
|
123
|
+
log "INFO: skipped #{bibdata.docid} as it is not one of (#{ACCEPTED_STAGES.join(", ")})."
|
|
81
124
|
next
|
|
82
125
|
end
|
|
83
126
|
|
|
@@ -106,8 +149,9 @@ files.each do |file_path|
|
|
|
106
149
|
end
|
|
107
150
|
|
|
108
151
|
# read definitions
|
|
109
|
-
|
|
110
|
-
|
|
152
|
+
part_concepts = []
|
|
153
|
+
current_document.xpath('//definition').each do |definition|
|
|
154
|
+
index = max_encountered_refs_indexes[bibdata.anchor] || 1
|
|
111
155
|
term_id = definition['id']
|
|
112
156
|
unless term_id.nil?
|
|
113
157
|
if encountered_terms[term_id]
|
|
@@ -127,24 +171,107 @@ files.each do |file_path|
|
|
|
127
171
|
file_path: fpath + revision_string
|
|
128
172
|
)
|
|
129
173
|
|
|
130
|
-
|
|
174
|
+
unless term_special_category(bibdata)
|
|
175
|
+
# log "INFO: this part is generic"
|
|
176
|
+
general_concepts << concept
|
|
177
|
+
else
|
|
178
|
+
# log "INFO: this part is special"
|
|
179
|
+
part_concepts << concept
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
max_encountered_refs_indexes[bibdata.anchor] = index + 1
|
|
131
183
|
parsed_bibliography << bibdata
|
|
132
184
|
end
|
|
133
185
|
|
|
186
|
+
current_document.xpath('//arm').each do |arm_node|
|
|
187
|
+
index = max_encountered_refs_indexes[bibdata.anchor] || 1
|
|
188
|
+
|
|
189
|
+
concept = Stepmod::Utils::Concept.parse(
|
|
190
|
+
arm_node,
|
|
191
|
+
reference_anchor: bibdata.anchor,
|
|
192
|
+
reference_clause: nil,
|
|
193
|
+
file_path: fpath + revision_string
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
module_concepts << concept
|
|
197
|
+
# unless term_special_category(bibdata)
|
|
198
|
+
# # log "INFO: this part is generic"
|
|
199
|
+
# general_concepts << concept
|
|
200
|
+
# else
|
|
201
|
+
# # log "INFO: this part is special"
|
|
202
|
+
# part_concepts << concept
|
|
203
|
+
# end
|
|
204
|
+
|
|
205
|
+
max_encountered_refs_indexes[bibdata.anchor] = index + 1
|
|
206
|
+
parsed_bibliography << bibdata
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
current_document.xpath('//schema').each do |schema_node|
|
|
210
|
+
Dir["#{stepmod_dir}/**/#{schema_node['name']}/descriptions.xml"].each do |description|
|
|
211
|
+
description_document = Nokogiri::XML(File.read(description)).root
|
|
212
|
+
description_document.xpath('//ext_description').each do |ext_description|
|
|
213
|
+
index = max_encountered_refs_indexes[bibdata.anchor] || 1
|
|
214
|
+
|
|
215
|
+
concept = Stepmod::Utils::Concept.parse(
|
|
216
|
+
ext_description,
|
|
217
|
+
reference_anchor: bibdata.anchor,
|
|
218
|
+
reference_clause: nil,
|
|
219
|
+
file_path: fpath + revision_string
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
resource_concepts << concept
|
|
223
|
+
# unless term_special_category(bibdata)
|
|
224
|
+
# # log "INFO: this part is generic"
|
|
225
|
+
# general_concepts << concept
|
|
226
|
+
# else
|
|
227
|
+
# # log "INFO: this part is special"
|
|
228
|
+
# part_concepts << concept
|
|
229
|
+
# end
|
|
230
|
+
|
|
231
|
+
max_encountered_refs_indexes[bibdata.anchor] = index + 1
|
|
232
|
+
parsed_bibliography << bibdata
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
134
237
|
log "INFO: Completed processing XML file #{fpath}"
|
|
135
238
|
|
|
239
|
+
if part_concepts.length == 0
|
|
240
|
+
log "INFO: Skipping #{fpath} (#{bibdata.docid}) because it contains no concepts."
|
|
241
|
+
next
|
|
242
|
+
elsif part_concepts.length < 3
|
|
243
|
+
log "INFO: Skipping #{fpath} (#{bibdata.docid}) because it only has #{part_concepts.length} terms."
|
|
244
|
+
|
|
245
|
+
part_concepts.each do |x|
|
|
246
|
+
general_concepts << x
|
|
247
|
+
end
|
|
248
|
+
else
|
|
249
|
+
fn = "03x-stepmod-#{bibdata.part}.adoc"
|
|
250
|
+
File.open(fn, 'w') { |file|
|
|
251
|
+
file.puts("== #{part_to_title(bibdata)}\n\n")
|
|
252
|
+
file.puts(part_concepts.map(&:to_mn_adoc).join("\n"))
|
|
253
|
+
}
|
|
254
|
+
log "INFO: written to: #{fn}"
|
|
255
|
+
end
|
|
256
|
+
|
|
136
257
|
end
|
|
137
258
|
|
|
138
|
-
|
|
259
|
+
File.open('031-stepmod-general.adoc', 'w') { |file|
|
|
260
|
+
file.puts(general_concepts.map(&:to_mn_adoc).join("\n"))
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
File.open('04-stepmod-entities-resources.adoc', 'w') { |file|
|
|
264
|
+
file.puts(resource_concepts.map(&:to_mn_adoc).join("\n"))
|
|
265
|
+
}
|
|
139
266
|
|
|
140
|
-
File.open('
|
|
141
|
-
file.puts(
|
|
267
|
+
File.open('05-stepmod-entities-modules.adoc', 'w') { |file|
|
|
268
|
+
file.puts(module_concepts.map(&:to_mn_adoc).join("\n"))
|
|
142
269
|
}
|
|
143
270
|
|
|
144
|
-
log "INFO: written to: 031-
|
|
271
|
+
log "INFO: written to: 031-stepmod-general.adoc"
|
|
145
272
|
|
|
146
273
|
File.open('991-generated-bibliography.adoc', 'w') { |file|
|
|
147
|
-
file.puts(parsed_bibliography.map(&:to_mn_adoc).uniq.join("\n"))
|
|
274
|
+
file.puts(parsed_bibliography.map(&:to_mn_adoc).sort.uniq.join("\n"))
|
|
148
275
|
}
|
|
149
276
|
|
|
150
277
|
log "INFO: written to: 991-generated-bibliography.adoc"
|
|
@@ -21,8 +21,18 @@ module Stepmod
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def self.parse(definition_xml, reference_anchor:, reference_clause:, file_path:)
|
|
24
|
+
converted_definition = Stepmod::Utils::StepmodDefinitionConverter
|
|
25
|
+
.convert(definition_xml, { reference_anchor: reference_anchor })
|
|
26
|
+
if definition_xml.name == 'arm' || definition_xml.name == 'ext_description'
|
|
27
|
+
converted_definition = <<~TEXT
|
|
28
|
+
#{converted_definition.split("\n")[0..3].join("\n")}
|
|
29
|
+
|
|
30
|
+
NOTE: This term is incompletely defined in this document.
|
|
31
|
+
Reference <<#{reference_anchor}>> for the complete definition.
|
|
32
|
+
TEXT
|
|
33
|
+
end
|
|
24
34
|
new(
|
|
25
|
-
converted_definition:
|
|
35
|
+
converted_definition: converted_definition,
|
|
26
36
|
reference_anchor: reference_anchor,
|
|
27
37
|
reference_clause: reference_clause,
|
|
28
38
|
file_path: file_path
|
|
@@ -35,7 +45,7 @@ module Stepmod
|
|
|
35
45
|
#{converted_definition}
|
|
36
46
|
|
|
37
47
|
[.source]
|
|
38
|
-
<<#{reference_anchor},clause
|
|
48
|
+
<<#{reference_anchor}#{reference_clause ? ",clause=" + reference_clause : ""}>>
|
|
39
49
|
|
|
40
50
|
TEXT
|
|
41
51
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Arm < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
treat_children(node, state)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def treat_children(node, state)
|
|
14
|
+
res = node.children.map { |child| treat(child, state) }
|
|
15
|
+
res.map(&:strip).reject(&:empty?).join("\n\n")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
ReverseAdoc::Converters.register :arm, Arm.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Stepmod
|
|
2
|
+
module Utils
|
|
3
|
+
module Converters
|
|
4
|
+
class StepmodExtDescription < ReverseAdoc::Converters::Base
|
|
5
|
+
def convert(node, state = {})
|
|
6
|
+
state = state.merge(schema_name: node['linkend'])
|
|
7
|
+
<<~TEMPLATE
|
|
8
|
+
=== #{node['linkend'].split('.').last}
|
|
9
|
+
|
|
10
|
+
<STEP resource> #{treat_children(node, state).strip}
|
|
11
|
+
TEMPLATE
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
ReverseAdoc::Converters.register :ext_description, StepmodExtDescription.new
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'stepmod/utils/converters/synonym'
|
|
4
|
+
|
|
5
|
+
module Stepmod
|
|
6
|
+
module Utils
|
|
7
|
+
module Converters
|
|
8
|
+
class Uof < ReverseAdoc::Converters::Base
|
|
9
|
+
def convert(node, state = {})
|
|
10
|
+
<<~TEXT
|
|
11
|
+
=== #{node['name'].strip}
|
|
12
|
+
|
|
13
|
+
<STEP module> #{treat_children(node, state).strip}
|
|
14
|
+
TEXT
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
ReverseAdoc::Converters.register :uof, Uof.new
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'reverse_adoc'
|
|
4
|
+
require 'stepmod/utils/converters/arm'
|
|
4
5
|
require 'stepmod/utils/converters/clause_ref'
|
|
5
6
|
require 'stepmod/utils/converters/express_ref'
|
|
6
7
|
require 'stepmod/utils/converters/module_ref'
|
|
@@ -11,8 +12,10 @@ require 'stepmod/utils/converters/example'
|
|
|
11
12
|
require 'stepmod/utils/converters/note'
|
|
12
13
|
require 'stepmod/utils/converters/ol'
|
|
13
14
|
require 'stepmod/utils/converters/stem'
|
|
15
|
+
require 'stepmod/utils/converters/stepmod_ext_description'
|
|
14
16
|
require 'stepmod/utils/converters/term'
|
|
15
17
|
require 'stepmod/utils/converters/synonym'
|
|
18
|
+
require 'stepmod/utils/converters/uof'
|
|
16
19
|
|
|
17
20
|
require 'reverse_adoc/converters/a'
|
|
18
21
|
require 'reverse_adoc/converters/blockquote'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stepmod-utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
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-05-
|
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -117,6 +117,7 @@ files:
|
|
|
117
117
|
- lib/stepmod/utils/cleaner.rb
|
|
118
118
|
- lib/stepmod/utils/concept.rb
|
|
119
119
|
- lib/stepmod/utils/converters/a.rb
|
|
120
|
+
- lib/stepmod/utils/converters/arm.rb
|
|
120
121
|
- lib/stepmod/utils/converters/blockquote.rb
|
|
121
122
|
- lib/stepmod/utils/converters/br.rb
|
|
122
123
|
- lib/stepmod/utils/converters/bypass.rb
|
|
@@ -153,6 +154,7 @@ files:
|
|
|
153
154
|
- lib/stepmod/utils/converters/schema.rb
|
|
154
155
|
- lib/stepmod/utils/converters/schema_diag.rb
|
|
155
156
|
- lib/stepmod/utils/converters/stem.rb
|
|
157
|
+
- lib/stepmod/utils/converters/stepmod_ext_description.rb
|
|
156
158
|
- lib/stepmod/utils/converters/strong.rb
|
|
157
159
|
- lib/stepmod/utils/converters/sub.rb
|
|
158
160
|
- lib/stepmod/utils/converters/sup.rb
|
|
@@ -160,6 +162,7 @@ files:
|
|
|
160
162
|
- lib/stepmod/utils/converters/table.rb
|
|
161
163
|
- lib/stepmod/utils/converters/term.rb
|
|
162
164
|
- lib/stepmod/utils/converters/text.rb
|
|
165
|
+
- lib/stepmod/utils/converters/uof.rb
|
|
163
166
|
- lib/stepmod/utils/html_to_asciimath.rb
|
|
164
167
|
- lib/stepmod/utils/smrl_description_converter.rb
|
|
165
168
|
- lib/stepmod/utils/smrl_resource_converter.rb
|