text_alignment 0.11.6 → 0.11.7

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: 5ed6071b0293e9b7fa86acf4a737c80c9d784f453d3fb77992e3d9f1acc02bbe
4
- data.tar.gz: 7a57b7afbe21061d9aac2f96cd9f7a3c83ff2f01b6c3973905f7681a40463287
3
+ metadata.gz: 52ad7c8b5822308ae15153e35626e13b5ec60d77428c80cbe3f1dd69f36edac1
4
+ data.tar.gz: efbcbbea9eb87606b1614661187356e15f65965b85c30ebf7d349d2f7e1028b0
5
5
  SHA512:
6
- metadata.gz: 141158c2f6b80975bacf68babc713b06d809f02b96cfd7accdecb00c6b4c362b9d130e29820074be7b89ac53c7cc93f850ec3d7ea9796eaad5021d441528e82b
7
- data.tar.gz: 8bc4cc9ca9becc1c5638b6501268d33dd7700e8369d7c20c1ec6fd9ef11e9fd73e6a1354cb37376af250c8462e945cccf08417ba6d258f08660c53eb418e4658
6
+ metadata.gz: 59a2a8dd68066271b61b950c18f513b03d2b674e86c0d6d065e265367e079c99bfa973cb41c75bdc2f2d19443a9b6f8e46dcca27bb71eecd27ed00d00c07533e
7
+ data.tar.gz: 4779c1cbe899021125f56204d87462a8c1222c961f547e1ddc9ba4c46e29211da564bdc6492346baaa16ad4eaaedce4601f6afdcc0a16031a29be79f624c4935
@@ -151,4 +151,4 @@ else
151
151
  source_annotations.merge({text:reference_text, denotations:denotations})
152
152
  end
153
153
 
154
- puts target_annotations.to_json
154
+ # puts target_annotations.to_json
@@ -120,7 +120,7 @@ class TextAlignment::CharMapping
120
120
 
121
121
  init_next = 0
122
122
  while loc = text.index(long, init_next)
123
- loc_len << [loc, long.length]
123
+ loc_len << [loc, long.length, 1]
124
124
  init_next = loc + long.length
125
125
  end
126
126
 
@@ -130,9 +130,9 @@ class TextAlignment::CharMapping
130
130
 
131
131
  # To get the (location, length) index for consecutive whitespace sequences
132
132
  init_next = 0
133
- while loc = text.index(/\s{2,}/, init_next)
133
+ while loc = text.index(/\s{1,}/, init_next)
134
134
  len = $~[0].length
135
- loc_len << [loc, len]
135
+ loc_len << [loc, len, 0]
136
136
  init_next = loc + len
137
137
  end
138
138
 
@@ -143,17 +143,21 @@ class TextAlignment::CharMapping
143
143
  init_next = 0
144
144
  j = 0
145
145
 
146
- loc_len.each do |loc, len|
146
+ loc_len.each do |loc, old_len, new_len|
147
147
  offset_mapping += (init_next .. loc).map do |i|
148
+ m = [i, j]
148
149
  j += 1
149
- [i, j - 1]
150
+ m
150
151
  end
151
- init_next = loc + len
152
+
153
+ init_next = loc + old_len
154
+ j += (new_len - 1)
152
155
  end
153
156
 
154
157
  offset_mapping += (init_next .. text.length).map do |i|
158
+ m = [i, j]
155
159
  j += 1
156
- [i, j - 1]
160
+ m
157
161
  end
158
162
 
159
163
  # To execute the long letter mapping
@@ -162,7 +166,7 @@ class TextAlignment::CharMapping
162
166
  end
163
167
 
164
168
  # To replace multi whitespace sequences to a space
165
- text.gsub!(/\s{2,}/, ' ')
169
+ text.gsub!(/\s{1,}/, '')
166
170
 
167
171
  [text, offset_mapping]
168
172
  end
@@ -157,7 +157,8 @@ class TextAlignment::MixedAlignment
157
157
  when '-'
158
158
  ''
159
159
  when '+'
160
- (d.new_element =~ /\S/) ? '+' : ''
160
+ # (d.new_element =~ /\S/) ? '+' : ''
161
+ '+'
161
162
  else
162
163
  ''
163
164
  end
@@ -1,3 +1,3 @@
1
1
  class TextAlignment
2
- VERSION = '0.11.6'
2
+ VERSION = '0.11.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_alignment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.6
4
+ version: 0.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jin-Dong Kim