text_alignment 0.3.10 → 0.3.11

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: 76e19ea61fda3543526ef26d582ad4ec9cfb3eec33ad03b77a998529af762eb6
4
- data.tar.gz: e386cd97317e6c32c0d4c9ec347b664c2640fcad17bb7dc906b6b5b9c5784b54
3
+ metadata.gz: 01525b6ca5f7e0ae1ebb9dfce2083006e095a66b3ab468ccef0a584bc3005556
4
+ data.tar.gz: bc1137052a12b8db97635b183f299518b0158f3ccecf36d42fa45d746b4f3792
5
5
  SHA512:
6
- metadata.gz: dbb72e3c50713edc4fbf3328bdcc5f78723d1fe03cad4f451f2142bd05075da0ca9c3ea9b7bcdaeda009bf94cb8e26f4ede32ab96f819479fd3e2f9a988f41e9
7
- data.tar.gz: 31443cca978d00e03bd5cf4339575ce4b070b06ad690938277b19f12045de2c33e04395c16799cfe4e336ac1b14264dccaa76b1c4fc48f71dbe9558f4efc6221
6
+ metadata.gz: 9596bea2616c3b4d939c8314d026941a6e627f4380183409051df62722a0ee5e3b35302da3066b0d32e8322582c999877b05a09c54749d878a284a062247342e
7
+ data.tar.gz: 361e3e7a23697167b41e037e7d272bbd286ac397416defb125821ebbcb17bfa386341c75fecbb94fe7f9976cfbc2a8b5f7f9be7c150d23daf6d8c16410509b5d
@@ -27,35 +27,29 @@ class TextAlignment::AnchorFinder
27
27
 
28
28
  def get_next_anchor
29
29
  # find the position of an anchor ngram in s1 and s2
30
- @beg_s2 = nil
31
30
  while @beg_s1 < (@s1.length - @size_ngram)
32
- while @beg_s1 < (@s1.length - @size_ngram)
33
- anchor = @s1[@beg_s1, @size_ngram]
34
- @beg_s2 = if defined? @end_s2_prev
35
- @s2.index(anchor, @end_s2_prev)
36
- else
37
- @s2.index(anchor)
38
- end
39
- break unless @beg_s2.nil?
40
- @beg_s1 += 1
41
- end
31
+ anchor = @s1[@beg_s1, @size_ngram]
32
+
33
+ search_position = 0
34
+ while @beg_s2 = @s2.index(anchor, search_position)
35
+ # if both the begining points are sufficiantly close to the end points of the last match
36
+ break if @end_s1_prev && (@beg_s1 - @end_s1_prev < 5) && (@beg_s2 - @end_s2_prev < 5)
42
37
 
43
- # The loop above is terminated with beg_s2 == nil, which means no more anchor
44
- break if @beg_s2.nil?
38
+ left_window_s1, left_window_s2 = get_left_windows
39
+ break if left_window_s1 && text_similarity(left_window_s1, left_window_s2) > TextAlignment::TEXT_SIMILARITY_TRESHOLD
45
40
 
46
- # if both the begining points are sufficiantly close to the end points of the last match
47
- break if @end_s1_prev && (@beg_s1 - @end_s1_prev < 5) && (@beg_s2 - @end_s2_prev < 5)
41
+ right_window_s1, right_window_s2 = get_right_windows
42
+ break if right_window_s2 && text_similarity(right_window_s1, left_window_s2) > TextAlignment::TEXT_SIMILARITY_TRESHOLD
48
43
 
49
- left_window_s1, left_window_s2 = get_left_windows
50
- break if left_window_s1 && text_similarity(left_window_s1, left_window_s2) > TextAlignment::TEXT_SIMILARITY_TRESHOLD
44
+ search_position = @beg_s2 + 1
45
+ end
51
46
 
52
- right_window_s1, right_window_s2 = get_right_windows
53
- break if right_window_s2 && text_similarity(right_window_s1, left_window_s2) > TextAlignment::TEXT_SIMILARITY_TRESHOLD
47
+ break unless @beg_s2.nil?
54
48
 
55
49
  @beg_s1 += 1
56
50
  end
57
51
 
58
- return nil if @beg_s2.nil?
52
+ return nil if @beg_s1 >= (@s1.length - @size_ngram)
59
53
 
60
54
  # extend the block
61
55
  b1 = @beg_s1
@@ -1,3 +1,3 @@
1
1
  class TextAlignment
2
- VERSION = '0.3.10'
2
+ VERSION = '0.3.11'
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.3.10
4
+ version: 0.3.11
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-08-29 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-dictionary