stepmod-utils 0.3.28 → 0.3.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/stepmod-extract-concepts +56 -0
- data/lib/stepmod/utils/terms_extractor.rb +24 -10
- 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: 94969385c7a15c9c97396a1f41bb772001e7114cef8896cf3a4291635f6b0087
|
4
|
+
data.tar.gz: 568556c9711f6b04cd6dbb83bfc1ba3d14da334711f841dbed2609014eb6b642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dd2832e232332d5062e368e6e74bb8bbdb1a0bc76ab2e171e1351a83b684fbca26a0a6f16f346d82b1d2e8cce2a76fe7febc2d5b0684642b8864ebbf36a1dd1
|
7
|
+
data.tar.gz: 05727db1fdd1631ebe6cb19fac8f09306cacab603c03ade34c6c5683be9a2283f13e22e364a3580952414d132554adfbc2238c3d951f9cc92ac02a76fa5880c3
|
@@ -139,8 +139,47 @@ def replace_content(content)
|
|
139
139
|
content
|
140
140
|
end
|
141
141
|
|
142
|
+
def extract_bibliographies(concepts, bibliographies)
|
143
|
+
concepts.each do |concept|
|
144
|
+
sources = concept.default_lang.sources
|
145
|
+
|
146
|
+
sources.each do |source|
|
147
|
+
next if bibliographies[source.origin.text]
|
148
|
+
|
149
|
+
bibliographies[source.origin.text] = {
|
150
|
+
"type" => source.type,
|
151
|
+
"origin" => {
|
152
|
+
"ref" => source.origin.text,
|
153
|
+
# "link" => source.origin.link,
|
154
|
+
},
|
155
|
+
}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def extract_sections(concepts, container)
|
161
|
+
concepts.each do |concept|
|
162
|
+
domain = concept.default_lang.domain
|
163
|
+
|
164
|
+
next if container[domain]
|
165
|
+
|
166
|
+
container[domain] = {
|
167
|
+
"domain" => domain,
|
168
|
+
"title" => domain.split(":").last.strip,
|
169
|
+
}
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
yaml_outputs = {
|
174
|
+
clause_4_sections: {},
|
175
|
+
clause_5_sections: {},
|
176
|
+
bibliographies: {}
|
177
|
+
}
|
178
|
+
|
142
179
|
part_resources.each do |(_bibdata, current_part_resources)|
|
143
180
|
current_part_resources.save_to_files(output_dir)
|
181
|
+
extract_sections(current_part_resources, yaml_outputs[:clause_4_sections])
|
182
|
+
extract_bibliographies(current_part_resources, yaml_outputs[:bibliographies])
|
144
183
|
end
|
145
184
|
log "INFO: part_resources written to YAML files in #{output_dir}"
|
146
185
|
|
@@ -150,12 +189,16 @@ end.each do |(_bibdata, part_modules_arm, part_modules_mim)|
|
|
150
189
|
unless part_modules_arm.empty?
|
151
190
|
part_modules_arm.values.map do |managed_concept|
|
152
191
|
managed_concept.save_to_files(output_dir)
|
192
|
+
extract_sections(managed_concept, yaml_outputs[:clause_5_sections])
|
193
|
+
extract_bibliographies(managed_concept, yaml_outputs[:bibliographies])
|
153
194
|
end
|
154
195
|
end
|
155
196
|
|
156
197
|
unless part_modules_mim.empty?
|
157
198
|
part_modules_mim.values.map do |managed_concept|
|
158
199
|
managed_concept.save_to_files(output_dir)
|
200
|
+
extract_sections(managed_concept, yaml_outputs[:clause_5_sections])
|
201
|
+
extract_bibliographies(managed_concept, yaml_outputs[:bibliographies])
|
159
202
|
end
|
160
203
|
end
|
161
204
|
end
|
@@ -163,3 +206,16 @@ log "INFO: part_modules written to YAML files in #{output_dir}"
|
|
163
206
|
|
164
207
|
resource_concepts.save_to_files(output_dir)
|
165
208
|
log "INFO: resource_concepts written to YAML files in #{output_dir}"
|
209
|
+
|
210
|
+
extract_sections(resource_concepts, yaml_outputs[:clause_4_sections])
|
211
|
+
extract_bibliographies(resource_concepts, yaml_outputs[:bibliographies])
|
212
|
+
|
213
|
+
{
|
214
|
+
clause_4_sections: "resource_sections.yaml",
|
215
|
+
clause_5_sections: "module_sections.yaml",
|
216
|
+
bibliographies: "bib.yaml"
|
217
|
+
}.each_pair do |var, filename|
|
218
|
+
path = File.join(output_dir, filename)
|
219
|
+
File.write(path, yaml_outputs[var].values.to_yaml)
|
220
|
+
log "INFO: #{var.to_s} written to #{path}."
|
221
|
+
end
|
@@ -243,13 +243,15 @@ module Stepmod
|
|
243
243
|
bibdata: bibdata,
|
244
244
|
# See: metanorma/iso-10303-2#90
|
245
245
|
domain_prefix: "application module",
|
246
|
+
schema_type: type,
|
246
247
|
)
|
247
248
|
when "module_mim"
|
248
249
|
mim_concepts = parse_annotated_module(
|
249
250
|
schema: schema,
|
250
251
|
bibdata: bibdata,
|
251
252
|
# See: metanorma/iso-10303-2#90
|
252
|
-
domain_prefix: "application
|
253
|
+
domain_prefix: "application module",
|
254
|
+
schema_type: type,
|
253
255
|
)
|
254
256
|
when "resource"
|
255
257
|
parse_annotated_resource(schema: schema, bibdata: bibdata)
|
@@ -268,7 +270,7 @@ module Stepmod
|
|
268
270
|
}[match.captures[0]] || "resource"
|
269
271
|
end
|
270
272
|
|
271
|
-
def parse_annotated_module(schema:, bibdata:, domain_prefix:)
|
273
|
+
def parse_annotated_module(schema:, bibdata:, domain_prefix:, schema_type:)
|
272
274
|
log "INFO: parse_annotated_module: " \
|
273
275
|
"Processing modules schema #{schema.file}"
|
274
276
|
|
@@ -285,6 +287,7 @@ module Stepmod
|
|
285
287
|
"name" => schema.id,
|
286
288
|
"type" => "module",
|
287
289
|
"path" => extract_file_path(entity.parent.file),
|
290
|
+
"schema_type" => schema_type
|
288
291
|
},
|
289
292
|
document: {
|
290
293
|
"type" => "module",
|
@@ -330,6 +333,7 @@ module Stepmod
|
|
330
333
|
"name" => schema.id,
|
331
334
|
"type" => "resource",
|
332
335
|
"path" => extract_file_path(entity.parent.file),
|
336
|
+
"schema_type" => "resource"
|
333
337
|
},
|
334
338
|
document: {
|
335
339
|
"type" => "resource",
|
@@ -363,7 +367,8 @@ module Stepmod
|
|
363
367
|
# rubocop:disable Metrics/MethodLength
|
364
368
|
def generate_concept_from_entity(entity:, schema:, domain:, bibdata:, document:)
|
365
369
|
old_definition = trim_definition(entity.remarks.first)
|
366
|
-
|
370
|
+
schema_type = schema["schema_type"]
|
371
|
+
definition = generate_entity_definition(entity, domain, schema_type)
|
367
372
|
|
368
373
|
notes = [old_definition].reject { |note| redundant_note?(note) }
|
369
374
|
|
@@ -382,7 +387,11 @@ module Stepmod
|
|
382
387
|
{
|
383
388
|
"type" => "authoritative",
|
384
389
|
"ref" => bibdata.docid,
|
385
|
-
|
390
|
+
|
391
|
+
# TODO: Commenting out link right now since it's not needed.
|
392
|
+
# GitHub: metanorma/iso-10303-2#286
|
393
|
+
#
|
394
|
+
# "link" => "https://www.iso.org/standard/32858.html",
|
386
395
|
},
|
387
396
|
],
|
388
397
|
notes: notes,
|
@@ -511,15 +520,20 @@ module Stepmod
|
|
511
520
|
# end
|
512
521
|
|
513
522
|
# rubocop:disable Layout/LineLength
|
514
|
-
def generate_entity_definition(entity, domain)
|
523
|
+
def generate_entity_definition(entity, domain, schema_type)
|
515
524
|
return "" if entity.nil?
|
516
525
|
|
517
526
|
# See: metanorma/iso-10303-2#90
|
518
|
-
entity_type =
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
527
|
+
entity_type = case schema_type
|
528
|
+
when "module_arm"
|
529
|
+
"{{application object}}"
|
530
|
+
when "module_mim"
|
531
|
+
"{{entity data type}}"
|
532
|
+
when "resource", "business_object_model"
|
533
|
+
"{{entity data type}}"
|
534
|
+
else
|
535
|
+
raise Error.new("[stepmod-utils] encountered unsupported schema_type")
|
536
|
+
end
|
523
537
|
|
524
538
|
if entity.subtype_of.size.zero?
|
525
539
|
"#{entity_type} " \
|
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.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|