stepmod-utils 0.3.18 → 0.3.19
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 +5 -1
- data/lib/stepmod/utils/terms_extractor.rb +48 -20
- data/lib/stepmod/utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4541a1fb0b4b3671d2aadf8cb833e93ca8b45f0c591b0da2df55e4614c2bcbf4
|
4
|
+
data.tar.gz: dbf98829e92bfcd54b468691011ab0de3781cf515b4d4b511ec394846f556ac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8410dd3702701b592aa67af784813058dcf2299ffe9dd60d45cab59b7035952111e17144b3b3b446e03135ae84a2a7ac5467f155b92ff768aa155d96437f0387
|
7
|
+
data.tar.gz: ea2fb98127cb384a70bd5aaf5febab17a92460170c820b250c52c0dca884bdc8d298f5ecdcf54f52ded4d1d22e75cbbce0fc65582499a04413e5e95cc8eb6b85
|
data/exe/stepmod-extract-terms
CHANGED
@@ -153,10 +153,13 @@ end
|
|
153
153
|
|
154
154
|
log "INFO: written summary file to: 04x-stepmod-entities-resources.adoc"
|
155
155
|
|
156
|
-
part_modules.
|
156
|
+
part_modules.sort_by do |(bibdata, part_modules_arm, part_modules_mim)|
|
157
|
+
bibdata.part.to_i
|
158
|
+
end.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
157
159
|
fn = "05x-stepmod-entities-modules-#{bibdata.part}.adoc"
|
158
160
|
File.open(fn, "w") do |file|
|
159
161
|
file.puts("")
|
162
|
+
|
160
163
|
unless part_modules_arm.empty?
|
161
164
|
schema_name = part_modules_arm.first.first
|
162
165
|
concepts = part_modules_arm.first.last.to_a.map do |n|
|
@@ -181,6 +184,7 @@ part_modules.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
|
181
184
|
file.puts(replace_images(concepts.map(&:to_mn_adoc).join("\n")))
|
182
185
|
end
|
183
186
|
end
|
187
|
+
|
184
188
|
log "INFO: written to: #{fn}"
|
185
189
|
end
|
186
190
|
|
@@ -134,8 +134,8 @@ module Stepmod
|
|
134
134
|
end
|
135
135
|
|
136
136
|
unless ACCEPTED_STAGES.include? bibdata.doctype
|
137
|
-
log "INFO: skipped #{bibdata.docid} as it is not \
|
138
|
-
one of (#{ACCEPTED_STAGES.join(', ')})."
|
137
|
+
log "INFO: skipped #{bibdata.docid} as it is not " \
|
138
|
+
"one of (#{ACCEPTED_STAGES.join(', ')})."
|
139
139
|
next
|
140
140
|
end
|
141
141
|
|
@@ -200,7 +200,7 @@ module Stepmod
|
|
200
200
|
log "INFO: FILE PATH IS #{file_path}"
|
201
201
|
case file_path.to_s
|
202
202
|
when /resource.xml$/
|
203
|
-
log "INFO: Processing resource.xml for #{
|
203
|
+
log "INFO: Processing resource.xml for #{fpath}"
|
204
204
|
|
205
205
|
current_document.xpath("//schema").each do |schema_node|
|
206
206
|
schema_name = schema_node["name"]
|
@@ -259,7 +259,7 @@ module Stepmod
|
|
259
259
|
end
|
260
260
|
|
261
261
|
when /module.xml$/
|
262
|
-
log "INFO: Processing module.xml for #{
|
262
|
+
log "INFO: Processing module.xml for #{fpath}"
|
263
263
|
# Assumption: every schema is only linked by a single module document.
|
264
264
|
# puts current_document.xpath('//module').length
|
265
265
|
schema_name = current_document.xpath("//module").first["name"]
|
@@ -284,7 +284,8 @@ module Stepmod
|
|
284
284
|
schema.entities.each do |entity|
|
285
285
|
old_definition = entity.remarks.first
|
286
286
|
|
287
|
-
|
287
|
+
# See: metanorma/iso-10303-2#90
|
288
|
+
domain = "application object: #{schema.id}"
|
288
289
|
entity_definition = generate_entity_definition(entity, domain, old_definition)
|
289
290
|
|
290
291
|
reference_anchor = bibdata.anchor
|
@@ -362,11 +363,11 @@ module Stepmod
|
|
362
363
|
|
363
364
|
log "INFO: Completed processing XML file #{fpath}"
|
364
365
|
if current_part_concepts.to_a.empty?
|
365
|
-
log "INFO: Skipping #{fpath} (#{bibdata.docid}) \
|
366
|
-
because it contains no concepts."
|
366
|
+
log "INFO: Skipping #{fpath} (#{bibdata.docid}) " \
|
367
|
+
"because it contains no concepts."
|
367
368
|
elsif current_part_concepts.to_a.length < 3
|
368
|
-
log "INFO: Skipping #{fpath} (#{bibdata.docid}) \
|
369
|
-
because it only has #{current_part_concepts.to_a.length} terms."
|
369
|
+
log "INFO: Skipping #{fpath} (#{bibdata.docid}) " \
|
370
|
+
"because it only has #{current_part_concepts.to_a.length} terms."
|
370
371
|
|
371
372
|
current_part_concepts.to_a.each do |x|
|
372
373
|
general_concepts.store(x)
|
@@ -377,23 +378,24 @@ module Stepmod
|
|
377
378
|
current_part_concepts]
|
378
379
|
end
|
379
380
|
end
|
381
|
+
|
380
382
|
unless current_part_resources.to_a.empty?
|
381
383
|
part_resources << [bibdata,
|
382
384
|
current_part_resources]
|
383
385
|
end
|
386
|
+
|
384
387
|
if (current_part_modules_arm.to_a.size +
|
385
388
|
current_part_modules_mim.to_a.size).positive?
|
386
389
|
part_modules << [bibdata, current_part_modules_arm,
|
387
390
|
current_part_modules_mim]
|
388
391
|
end
|
392
|
+
|
389
393
|
end
|
390
394
|
end
|
391
395
|
|
392
396
|
def find_or_initialize_concept(collection, localized_concept)
|
393
|
-
concept_id = SecureRandom.uuid
|
394
|
-
|
395
397
|
concept = collection
|
396
|
-
.store(Glossarist::Concept.new(id:
|
398
|
+
.store(Glossarist::Concept.new(id: SecureRandom.uuid))
|
397
399
|
concept.add_l10n(localized_concept)
|
398
400
|
end
|
399
401
|
|
@@ -471,19 +473,45 @@ module Stepmod
|
|
471
473
|
# end
|
472
474
|
end
|
473
475
|
|
476
|
+
def entity_name_to_text(entity_id)
|
477
|
+
entity_id.downcase.gsub(/_/, " ")
|
478
|
+
end
|
474
479
|
|
475
480
|
# rubocop:disable Layout/LineLength
|
476
481
|
def generate_entity_definition(entity, domain, old_definition)
|
477
482
|
return "" if entity.nil?
|
478
483
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
484
|
+
# See: metanorma/iso-10303-2#90
|
485
|
+
# TODO: This is not DRY in case we have to further customize
|
486
|
+
entity_text = if domain =~ /\Aapplication object:/
|
487
|
+
|
488
|
+
if entity.subtype_of.size.zero?
|
489
|
+
"application object that represents the " +
|
490
|
+
"{{#{entity.id},#{entity_name_to_text(entity.id)}}} entity"
|
491
|
+
else
|
492
|
+
entity_subtypes = entity.subtype_of.map do |e|
|
493
|
+
"{{#{e.id},#{entity_name_to_text(e.id)}}}"
|
494
|
+
end
|
495
|
+
"application object that is a type of " +
|
496
|
+
"#{entity_subtypes.join(' and ')} that represents the " +
|
497
|
+
"{{#{entity.id},#{entity_name_to_text(entity.id)}}} entity"
|
498
|
+
end
|
499
|
+
|
500
|
+
else
|
501
|
+
|
502
|
+
# Not "application object"
|
503
|
+
if entity.subtype_of.size.zero?
|
504
|
+
"entity data type that represents " +
|
505
|
+
entity.id.indefinite_article + " {{#{entity.id}}} entity"
|
506
|
+
else
|
507
|
+
entity_subtypes = entity.subtype_of.map do |e|
|
508
|
+
"{{#{e.id}}}"
|
509
|
+
end
|
510
|
+
"entity data type that is a type of "+
|
511
|
+
"#{entity_subtypes.join(' and ')} that represents " +
|
512
|
+
entity.id.indefinite_article + " {{#{entity.id}}} entity"
|
513
|
+
end
|
514
|
+
end
|
487
515
|
|
488
516
|
definition = <<~DEFINITION
|
489
517
|
=== #{entity.id}
|
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.3.
|
4
|
+
version: 0.3.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|