text_alignment 0.5.1 → 0.5.2

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: 041aa1d92ea6bb54ca9fd005d0a8684b8c012b0cb55e5ea00d54be357eae646c
4
- data.tar.gz: f821ae66f4c64eb7043ec85515694c207510be860568cc86fc47b89c8e504f87
3
+ metadata.gz: 07e02285cce988b857421b5eae20c6b39394dbd0c904de2f416344cad69b725f
4
+ data.tar.gz: 6ccdf9930bc97fc5bc6fc2a2d92f732867744342a6c828eaa3ac8029339f33c3
5
5
  SHA512:
6
- metadata.gz: 9bf264a8789a2630e6a820b0a0833854f6b03de802d78ea60b5849e5ee6ceb0119494221fadb2220ad27edb92f44711530ef840c05c044396402e2227f71c004
7
- data.tar.gz: c4a95752b186092d2acc48dbdbeedde6ca952da02dcf206c95304f11f6d0c433dd2ad25f50729dceb5610fee438f9ca4df7171db66af7f2904a247ba50105149
6
+ metadata.gz: 477e77a9349857cd9ab69b5da4d048dd2b36b1d51a7af742a9d05cb1ee20eba8c6d67cd4882c380f5e2737be1ca0d6fa13c0a81b2c3b257a7f249ccb1f4e589c
7
+ data.tar.gz: 904fe737512c8774a03c23ae7229df55dd0727fd1a41d3a73031b96e6458920c78c02c66990577624c830525734918c54a8821d1e700eb55d7c8b871ecd6edf3
@@ -137,26 +137,26 @@ else
137
137
 
138
138
  source_text = source_annotations[:text]
139
139
 
140
- # puts "[block alignment]"
140
+ puts "[block alignment]"
141
141
  puts alignment.alignment_show
142
- # puts "====="
142
+ puts "====="
143
143
  # exit
144
144
 
145
145
  # verification of source denotations
146
- # puts "[Invalid source denotations]"
147
- # source_annotations[:denotations] do |d|
148
- # p d unless d[:span][:begin] && d[:span][:end] && d[:span][:begin] < d[:span][:end] && d[:span][:begin] >= 0 && d[:span][:end] < source_text.length
149
- # end
150
- # puts "====="
151
- # puts
146
+ puts "[Invalid source denotations]"
147
+ source_annotations[:denotations] do |d|
148
+ p d unless d[:span][:begin] && d[:span][:end] && d[:span][:begin] < d[:span][:end] && d[:span][:begin] >= 0 && d[:span][:end] < source_text.length
149
+ end
150
+ puts "====="
151
+ puts
152
152
 
153
153
  denotations = alignment.transform_hdenotations(source_annotations[:denotations])
154
- # puts "[Invalid transformation]"
155
- # denotations.each do |d|
156
- # p d unless d[:span][:begin] && d[:span][:end] && d[:span][:begin] < d[:span][:end] && d[:span][:begin] >= 0 && d[:span][:end] < target_text.length
157
- # end
158
- # puts "====="
159
- # puts
154
+ puts "[Invalid transformation]"
155
+ denotations.each do |d|
156
+ p d unless d[:span][:begin] && d[:span][:end] && d[:span][:begin] < d[:span][:end] && d[:span][:begin] >= 0 && d[:span][:end] < target_text.length
157
+ end
158
+ puts "====="
159
+ puts
160
160
 
161
161
  lost_annotations += alignment.lost_annotations if alignment.lost_annotations
162
162
 
@@ -33,7 +33,8 @@ 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
+ mlcs = sdiff.count{|d| d.action == '=' && d.old_element =~ /\S/ && d.new_element =~ /\S/}
37
+ @similarity = 2 * mlcs / (str1[@str1_match_initial .. @str1_match_final].scan(/\S/).count + str2[@str2_match_initial .. @str2_match_final].scan(/\S/).count).to_f
37
38
  else
38
39
  @str1_match_initial = 0
39
40
  @str2_match_initial = 0
@@ -1,3 +1,3 @@
1
1
  class TextAlignment
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
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.5.1
4
+ version: 0.5.2
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: 2020-10-04 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-dictionary