stepmod-utils 0.3.0 → 0.3.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0bf29e9cab4e7f1564993380efa536e105ad6f7aa54612b242d1bd993a4b06f
|
4
|
+
data.tar.gz: 68bae8817c50a70a89fb1b159e0b600ced160435ff45c75f6af063eb6a640c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58071bec7536d36329370d7be259b7a23efd00870e8aac6d2ecb116a568ec87f08bed596ce3d85e4be3e58b9603e7d4d040f0220d3709ffa8063eb12e77ba9f1
|
7
|
+
data.tar.gz: c48c7d2b6ed22d2b6dd80a3d4ce4ba574f793bc1005ee4e8512b7c696bd06d802bce681ade9919e3ae606ef8807f8993f9ee26d77a12c4430aed23340c8546f9
|
data/exe/stepmod-extract-terms
CHANGED
@@ -170,6 +170,7 @@ files.each do |file_path|
|
|
170
170
|
reference_clause: ref_clause,
|
171
171
|
file_path: fpath + revision_string
|
172
172
|
)
|
173
|
+
next unless concept
|
173
174
|
|
174
175
|
unless term_special_category(bibdata)
|
175
176
|
# log "INFO: this part is generic"
|
@@ -183,34 +184,38 @@ files.each do |file_path|
|
|
183
184
|
parsed_bibliography << bibdata
|
184
185
|
end
|
185
186
|
|
186
|
-
|
187
|
-
|
188
|
-
|
187
|
+
part_modules = []
|
188
|
+
current_document.xpath('//arm/uof').each do |uof_node|
|
189
189
|
concept = Stepmod::Utils::Concept.parse(
|
190
|
-
|
190
|
+
uof_node,
|
191
191
|
reference_anchor: bibdata.anchor,
|
192
192
|
reference_clause: nil,
|
193
193
|
file_path: fpath + revision_string
|
194
194
|
)
|
195
|
+
# puts concept.inspect
|
195
196
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
197
|
+
next unless concept
|
198
|
+
|
199
|
+
unless term_special_category(bibdata)
|
200
|
+
# log "INFO: this part is generic"
|
201
|
+
module_concepts << concept
|
202
|
+
else
|
203
|
+
# log "INFO: this part is special"
|
204
|
+
part_modules << concept
|
205
|
+
end
|
204
206
|
|
205
|
-
max_encountered_refs_indexes[bibdata.anchor] = index + 1
|
206
207
|
parsed_bibliography << bibdata
|
207
208
|
end
|
208
209
|
|
210
|
+
part_resources = []
|
211
|
+
# Assumption: every schema is only linked by a single resource_docs document.
|
209
212
|
current_document.xpath('//schema').each do |schema_node|
|
210
|
-
|
211
|
-
|
213
|
+
schema_name = schema_node['name']
|
214
|
+
|
215
|
+
Dir["#{stepmod_path}/*/#{schema_name}/descriptions.xml"].each do |description_xml_path|
|
216
|
+
log "INFO: Processing resources schema #{description_xml_path}"
|
217
|
+
description_document = Nokogiri::XML(File.read(description_xml_path)).root
|
212
218
|
description_document.xpath('//ext_description').each do |ext_description|
|
213
|
-
index = max_encountered_refs_indexes[bibdata.anchor] || 1
|
214
219
|
|
215
220
|
concept = Stepmod::Utils::Concept.parse(
|
216
221
|
ext_description,
|
@@ -218,17 +223,16 @@ files.each do |file_path|
|
|
218
223
|
reference_clause: nil,
|
219
224
|
file_path: fpath + revision_string
|
220
225
|
)
|
226
|
+
next unless concept
|
221
227
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
# end
|
228
|
+
unless term_special_category(bibdata)
|
229
|
+
# log "INFO: this part is generic"
|
230
|
+
resource_concepts << concept
|
231
|
+
else
|
232
|
+
# log "INFO: this part is special"
|
233
|
+
part_resources << concept
|
234
|
+
end
|
230
235
|
|
231
|
-
max_encountered_refs_indexes[bibdata.anchor] = index + 1
|
232
236
|
parsed_bibliography << bibdata
|
233
237
|
end
|
234
238
|
end
|
@@ -236,7 +240,7 @@ files.each do |file_path|
|
|
236
240
|
|
237
241
|
log "INFO: Completed processing XML file #{fpath}"
|
238
242
|
|
239
|
-
if part_concepts.
|
243
|
+
if part_concepts.empty?
|
240
244
|
log "INFO: Skipping #{fpath} (#{bibdata.docid}) because it contains no concepts."
|
241
245
|
next
|
242
246
|
elsif part_concepts.length < 3
|
@@ -254,6 +258,24 @@ files.each do |file_path|
|
|
254
258
|
log "INFO: written to: #{fn}"
|
255
259
|
end
|
256
260
|
|
261
|
+
unless part_resources.empty?
|
262
|
+
fn = "04x-stepmod-entities-resources-#{bibdata.part}.adoc"
|
263
|
+
File.open(fn, 'w') { |file|
|
264
|
+
file.puts("== #{part_to_title(bibdata)}\n\n")
|
265
|
+
file.puts(part_resources.map(&:to_mn_adoc).join("\n"))
|
266
|
+
}
|
267
|
+
log "INFO: written to: #{fn}"
|
268
|
+
end
|
269
|
+
|
270
|
+
unless part_modules.empty?
|
271
|
+
fn = "04x-stepmod-entities-modules-#{bibdata.part}.adoc"
|
272
|
+
File.open(fn, 'w') { |file|
|
273
|
+
file.puts("== #{part_to_title(bibdata)}\n\n")
|
274
|
+
file.puts(part_modules.map(&:to_mn_adoc).join("\n"))
|
275
|
+
}
|
276
|
+
log "INFO: written to: #{fn}"
|
277
|
+
end
|
278
|
+
|
257
279
|
end
|
258
280
|
|
259
281
|
File.open('031-stepmod-general.adoc', 'w') { |file|
|
@@ -23,7 +23,10 @@ module Stepmod
|
|
23
23
|
def self.parse(definition_xml, reference_anchor:, reference_clause:, file_path:)
|
24
24
|
converted_definition = Stepmod::Utils::StepmodDefinitionConverter
|
25
25
|
.convert(definition_xml, { reference_anchor: reference_anchor })
|
26
|
-
|
26
|
+
|
27
|
+
return nil if converted_definition.nil? || converted_definition.strip.empty?
|
28
|
+
|
29
|
+
if definition_xml.name == 'uof' || definition_xml.name == 'ext_description'
|
27
30
|
converted_definition = <<~TEXT
|
28
31
|
#{converted_definition.split("\n")[0..3].join("\n")}
|
29
32
|
|
@@ -4,6 +4,11 @@ module Stepmod
|
|
4
4
|
class StepmodExtDescription < ReverseAdoc::Converters::Base
|
5
5
|
def convert(node, state = {})
|
6
6
|
state = state.merge(schema_name: node['linkend'])
|
7
|
+
linkend = node['linkend'].split('.')
|
8
|
+
|
9
|
+
# We ignore all the WHERE and IP rules because those are not terms
|
10
|
+
return nil if linkend.last =~ /^wr/
|
11
|
+
|
7
12
|
<<~TEMPLATE
|
8
13
|
=== #{node['linkend'].split('.').last}
|
9
14
|
|
@@ -40,19 +40,21 @@ module Stepmod
|
|
40
40
|
module Utils
|
41
41
|
class StepmodDefinitionConverter
|
42
42
|
def self.convert(input, options = {})
|
43
|
-
root =
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
root = case input
|
44
|
+
when String
|
45
|
+
Nokogiri::XML(input).root
|
46
|
+
when Nokogiri::XML::Document
|
47
|
+
input.root
|
48
|
+
when Nokogiri::XML::Node
|
49
|
+
input
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
+
return '' unless root
|
52
53
|
|
53
54
|
ReverseAdoc.config.with(options) do
|
54
55
|
result = ReverseAdoc::Converters.lookup(root.name).convert(root)
|
55
|
-
|
56
|
+
return '' unless result
|
57
|
+
ReverseAdoc.cleaner.tidy(result.dup)
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|