stepmod-utils 0.3.17 → 0.3.18
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/lib/stepmod/utils/terms_extractor.rb +81 -4
- data/lib/stepmod/utils/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d666c11f9282db59fefb04c07c40a88f6167cd214d316f2b1a14ae7117ce898
|
4
|
+
data.tar.gz: fe07f66170d74a97a95003b0f5e3594c5f2bbeaa3d431b716ce52f01d13d418d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b2fea45d8a30e633e393afac572894481d7de3bf5a33cd19043b6b55cb5b2c948666eb705b4cc9e69a12fe7b43217ca80f8f9a47d7aab4507b1b00c4136476e
|
7
|
+
data.tar.gz: 8e5334b99ece0ad5bff37d8ffd7cd70c64fd4998c3e0f4da58825802420f8537493a7858a6158b00ffcfdb3907a532e44067ab4ba07f7cc8f6091b5bb7912517
|
@@ -238,7 +238,7 @@ module Stepmod
|
|
238
238
|
id: "#{reference_anchor}.#{reference_clause}",
|
239
239
|
reference_anchor: reference_anchor,
|
240
240
|
reference_clause: reference_clause,
|
241
|
-
file_path: Pathname.new(
|
241
|
+
file_path: Pathname.new(exp_annotated_path)
|
242
242
|
.relative_path_from(stepmod_path),
|
243
243
|
language_code: "en",
|
244
244
|
)
|
@@ -297,7 +297,7 @@ module Stepmod
|
|
297
297
|
id: "#{reference_anchor}.#{reference_clause}",
|
298
298
|
reference_anchor: reference_anchor,
|
299
299
|
reference_clause: reference_clause,
|
300
|
-
file_path: Pathname.new(
|
300
|
+
file_path: Pathname.new(exp_annotated_path)
|
301
301
|
.relative_path_from(stepmod_path),
|
302
302
|
language_code: "en",
|
303
303
|
)
|
@@ -340,7 +340,7 @@ module Stepmod
|
|
340
340
|
id: "#{reference_anchor}.#{reference_clause}",
|
341
341
|
reference_anchor: reference_anchor,
|
342
342
|
reference_clause: reference_clause,
|
343
|
-
file_path: Pathname.new(
|
343
|
+
file_path: Pathname.new(exp_annotated_path)
|
344
344
|
.relative_path_from(stepmod_path),
|
345
345
|
language_code: "en",
|
346
346
|
)
|
@@ -397,6 +397,81 @@ module Stepmod
|
|
397
397
|
concept.add_l10n(localized_concept)
|
398
398
|
end
|
399
399
|
|
400
|
+
def combine_paragraphs(full_paragraph, next_paragraph)
|
401
|
+
# If full_paragraph already contains a period, extract that.
|
402
|
+
if m = full_paragraph.match(/\A(?<inner_first>[^\n]*?\.)\s/)
|
403
|
+
# puts "CONDITION 1"
|
404
|
+
if m[:inner_first]
|
405
|
+
return m[:inner_first]
|
406
|
+
else
|
407
|
+
return full_paragraph
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
# If full_paragraph ends with a period, this is the last.
|
412
|
+
if full_paragraph =~ /\.\s*\Z/
|
413
|
+
# puts "CONDITION 2"
|
414
|
+
return full_paragraph
|
415
|
+
end
|
416
|
+
|
417
|
+
# If next_paragraph is a list
|
418
|
+
if next_paragraph.match(/\A\*/)
|
419
|
+
# puts "CONDITION 3"
|
420
|
+
return full_paragraph + "\n\n" + next_paragraph
|
421
|
+
end
|
422
|
+
|
423
|
+
# If next_paragraph is a continuation of a list
|
424
|
+
if next_paragraph.match(/\Awhich/) || next_paragraph.match(/\Athat/)
|
425
|
+
# puts "CONDITION 4"
|
426
|
+
return full_paragraph + "\n\n" + next_paragraph
|
427
|
+
end
|
428
|
+
|
429
|
+
# puts "CONDITION 5"
|
430
|
+
full_paragraph
|
431
|
+
end
|
432
|
+
|
433
|
+
def trim_definition(definition)
|
434
|
+
# Unless the first paragraph ends with "between" and is followed by a
|
435
|
+
# list, don't split
|
436
|
+
paragraphs = definition.split("\n\n")
|
437
|
+
|
438
|
+
# puts paragraphs.inspect
|
439
|
+
|
440
|
+
first_paragraph = paragraphs.first
|
441
|
+
|
442
|
+
if paragraphs.length > 1
|
443
|
+
combined = paragraphs[1..-1].inject(first_paragraph) do |acc, p|
|
444
|
+
combine_paragraphs(acc, p)
|
445
|
+
end
|
446
|
+
else
|
447
|
+
combined = combine_paragraphs(first_paragraph, "")
|
448
|
+
end
|
449
|
+
|
450
|
+
# puts "combined--------- #{combined}"
|
451
|
+
|
452
|
+
# Remove comments until end of line
|
453
|
+
combined = combined + "\n"
|
454
|
+
combined.gsub!(/\n\/\/.*?\n/, "\n")
|
455
|
+
combined.strip!
|
456
|
+
|
457
|
+
combined
|
458
|
+
# # TODO: If the definition contains a list immediately after the first paragraph, don't split
|
459
|
+
# return definition if definition =~ /\n\* /
|
460
|
+
|
461
|
+
# unless (
|
462
|
+
# first_paragraph =~ /between:?\s*\Z/ ||
|
463
|
+
# first_paragraph =~ /include:?\s*\Z/ ||
|
464
|
+
# first_paragraph =~ /of:?\s*\Z/ ||
|
465
|
+
# first_paragraph =~ /[:;]\s*\Z/
|
466
|
+
# ) &&
|
467
|
+
# definition =~ /\n\n\*/
|
468
|
+
|
469
|
+
# # Only taking the first paragraph of the definition
|
470
|
+
# first_paragraph
|
471
|
+
# end
|
472
|
+
end
|
473
|
+
|
474
|
+
|
400
475
|
# rubocop:disable Layout/LineLength
|
401
476
|
def generate_entity_definition(entity, domain, old_definition)
|
402
477
|
return "" if entity.nil?
|
@@ -419,10 +494,12 @@ module Stepmod
|
|
419
494
|
DEFINITION
|
420
495
|
|
421
496
|
unless old_definition.nil? || old_definition.blank?
|
497
|
+
old_definition = trim_definition(old_definition)
|
498
|
+
|
422
499
|
definition << <<~OLD_DEFINITION
|
423
500
|
[NOTE]
|
424
501
|
--
|
425
|
-
#{old_definition
|
502
|
+
#{old_definition.strip}
|
426
503
|
--
|
427
504
|
OLD_DEFINITION
|
428
505
|
end
|
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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -253,7 +253,7 @@ homepage: https://github.com/metanorma/stepmod-utils
|
|
253
253
|
licenses:
|
254
254
|
- BSD-2-Clause
|
255
255
|
metadata: {}
|
256
|
-
post_install_message:
|
256
|
+
post_install_message:
|
257
257
|
rdoc_options: []
|
258
258
|
require_paths:
|
259
259
|
- lib
|
@@ -268,8 +268,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
268
|
- !ruby/object:Gem::Version
|
269
269
|
version: '0'
|
270
270
|
requirements: []
|
271
|
-
rubygems_version: 3.
|
272
|
-
signing_key:
|
271
|
+
rubygems_version: 3.1.6
|
272
|
+
signing_key:
|
273
273
|
specification_version: 4
|
274
274
|
summary: Stepmod-utils is a toolkit that works on STEPmod data.
|
275
275
|
test_files: []
|