text_alignment 0.2.4 → 0.2.5
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: 554ab8168601f32f8d2dc92db4b38e4c556bce415d405e2952da3e1f5b8fab9f
|
4
|
+
data.tar.gz: 391db86a6c6c735088d34ea5c9f90a5e79316d046d748efc5dd737142bb281ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46efef8246d0d9e0ac957525de6ab2f599004f122d5da140582198dc1465191a76557959489f585ed2bd752c260247ca34148c2d8d028df19933c15a1e2d2456
|
7
|
+
data.tar.gz: 7ed3b9c16d44a2d8bab68726539c8457ee9db2fe74fb291296a73daf694e2e79b5e2a8f05bb9c3857735c5722c780c43d316dfb3b67e8af342e75fd969ee76b7
|
data/bin/align_annotations
CHANGED
@@ -17,12 +17,29 @@ str2 = anns2[:text]
|
|
17
17
|
|
18
18
|
denotations = anns1[:denotations]
|
19
19
|
|
20
|
+
puts "[Alignment1]====="
|
20
21
|
align = TextAlignment::TextAlignment.new(str1, str2, TextAlignment::MAPPINGS)
|
21
22
|
puts TextAlignment::sdiff2cdiff(align.sdiff)
|
22
|
-
puts
|
23
|
-
|
23
|
+
puts
|
24
|
+
puts "[Similarity]\n#{align.similarity}"
|
25
|
+
puts
|
26
|
+
puts '[Denotations original]'
|
27
|
+
pp denotations
|
28
|
+
puts
|
29
|
+
puts '[Denotations transformed]'
|
30
|
+
new_denotations = align.transform_hdenotations(denotations)
|
31
|
+
pp new_denotations
|
32
|
+
puts
|
33
|
+
puts "[Alignment2 (downcased)]====="
|
34
|
+
align = TextAlignment::TextAlignment.new(str1.downcase, str2.downcase, TextAlignment::MAPPINGS)
|
35
|
+
puts TextAlignment::sdiff2cdiff(align.sdiff)
|
36
|
+
puts
|
37
|
+
puts "[Similarity]\n#{align.similarity}"
|
38
|
+
puts
|
39
|
+
puts '[Denotations original]'
|
24
40
|
pp denotations
|
25
|
-
puts
|
41
|
+
puts
|
42
|
+
puts '[Denotations transformed]'
|
26
43
|
new_denotations = align.transform_hdenotations(denotations)
|
27
44
|
pp new_denotations
|
28
45
|
|
@@ -33,7 +33,7 @@ class TextAlignment::LCSComparison
|
|
33
33
|
@str2_match_initial = sdiff[match_initial].new_position
|
34
34
|
@str1_match_final = sdiff[match_final].old_position
|
35
35
|
@str2_match_final = sdiff[match_final].new_position
|
36
|
-
@similarity =
|
36
|
+
@similarity = lcs / [@str1_match_final - @str1_match_initial + 1, @str2_match_final - @str2_match_initial + 1].min.to_f
|
37
37
|
else
|
38
38
|
@str1_match_initial = 0
|
39
39
|
@str2_match_initial = 0
|
@@ -79,7 +79,7 @@ class TextAlignment::TextAlignment
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def transform_a_span(span)
|
82
|
-
{:
|
82
|
+
{begin: @position_map_begin[span[:begin]], end: @position_map_end[span[:end]]}
|
83
83
|
end
|
84
84
|
|
85
85
|
def transform_spans(spans)
|
@@ -91,11 +91,8 @@ class TextAlignment::TextAlignment
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def transform_hdenotations(hdenotations)
|
94
|
-
|
95
|
-
|
96
|
-
(0...hdenotations.length).each {|i| hdenotations_new[i][:span] = transform_a_span(hdenotations[i][:span])}
|
97
|
-
hdenotations_new
|
98
|
-
end
|
94
|
+
return nil if hdenotations.nil?
|
95
|
+
hdenotations.collect{|d| d.dup.merge({span:transform_a_span(d[:span])})}
|
99
96
|
end
|
100
97
|
|
101
98
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_alignment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jin-Dong Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-dictionary
|