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 +4 -4
- data/bin/align_annotations +1 -1
- data/lib/text_alignment/char_mapping.rb +12 -8
- data/lib/text_alignment/mixed_alignment.rb +2 -1
- data/lib/text_alignment/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52ad7c8b5822308ae15153e35626e13b5ec60d77428c80cbe3f1dd69f36edac1
|
|
4
|
+
data.tar.gz: efbcbbea9eb87606b1614661187356e15f65965b85c30ebf7d349d2f7e1028b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 59a2a8dd68066271b61b950c18f513b03d2b674e86c0d6d065e265367e079c99bfa973cb41c75bdc2f2d19443a9b6f8e46dcca27bb71eecd27ed00d00c07533e
|
|
7
|
+
data.tar.gz: 4779c1cbe899021125f56204d87462a8c1222c961f547e1ddc9ba4c46e29211da564bdc6492346baaa16ad4eaaedce4601f6afdcc0a16031a29be79f624c4935
|
data/bin/align_annotations
CHANGED
|
@@ -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{
|
|
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,
|
|
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
|
-
|
|
150
|
+
m
|
|
150
151
|
end
|
|
151
|
-
|
|
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
|
-
|
|
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{
|
|
169
|
+
text.gsub!(/\s{1,}/, '')
|
|
166
170
|
|
|
167
171
|
[text, offset_mapping]
|
|
168
172
|
end
|