text_alignment 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c61a711930d19f5a72bd4a4128f5f36038a185eeb203b9ca68afce143694dbd3
4
- data.tar.gz: 173fa1ed0277f0384f0804e7a1ea02c3bd1a1eda20a5d3f57523028f815e69ac
3
+ metadata.gz: 554ab8168601f32f8d2dc92db4b38e4c556bce415d405e2952da3e1f5b8fab9f
4
+ data.tar.gz: 391db86a6c6c735088d34ea5c9f90a5e79316d046d748efc5dd737142bb281ea
5
5
  SHA512:
6
- metadata.gz: 8f2a018145a07ec1d9a5c2277fd4d1e4bdb694726cf0936c92e8f25addb325e485545b7a1373a265e3b60fe2da0e39cdccbad586968aef093ed2154070242173
7
- data.tar.gz: 488390234e0e3b9d7d67389f303aed6e59bb0e16b1ad94908c8020be64b9c0bac9a9f404e42944fd37ece188377c930fd43596678a80ee24f3b00174c9e33aa4
6
+ metadata.gz: 46efef8246d0d9e0ac957525de6ab2f599004f122d5da140582198dc1465191a76557959489f585ed2bd752c260247ca34148c2d8d028df19933c15a1e2d2456
7
+ data.tar.gz: 7ed3b9c16d44a2d8bab68726539c8457ee9db2fe74fb291296a73daf694e2e79b5e2a8f05bb9c3857735c5722c780c43d316dfb3b67e8af342e75fd969ee76b7
@@ -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 "\n=====\n\n"
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
 
@@ -37,7 +37,7 @@ class << TextAlignment
37
37
  end
38
38
  end
39
39
 
40
- cdiff_str1.gsub(/\n/, ' ') + "\n" + cdiff_str2.gsub(/\n/, ' ')
40
+ cdiff_str1.gsub(/\n/, ' ') + "\n>>>>><<<<<\n" + cdiff_str2.gsub(/\n/, ' ')
41
41
  end
42
42
 
43
43
  end
@@ -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 = 2 * lcs / ((@str1_match_final - @str1_match_initial + 1) + (@str2_match_final - @str2_match_initial + 1)).to_f
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
- {:begin=>@position_map_begin[span[:begin]], :end=>@position_map_end[span[:end]]}
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
- unless hdenotations.nil?
95
- hdenotations_new = Array.new(hdenotations)
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
@@ -1,3 +1,3 @@
1
1
  class TextAlignment
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
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
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 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-dictionary