text_alignment 0.12.5 → 0.12.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 354d6971ab0c7d6e80af0633512d5f7257b5e6e1a4bef021bfc1e1eee6e546c1
|
4
|
+
data.tar.gz: bae6c626e170de96ae32beb24c9d074b1e56283e497dffc53c2da270c20de058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3409a5c7419c43a311e76468a6783b6a6a808c12dd14343eace7c0242dc3cd79d01616069dce12d49f5db8cc77b293ab469efa07b6a5878e1bade341f24f1c1d
|
7
|
+
data.tar.gz: fe7df5b352f14989701c0dbf0bc94169b415a5c155b7e04f670803d154576e4a39ea7dddf3f320a9df8e8e9c3fb3bc67ddc051d7e3d939ca9bc7a58de1b3b952
|
@@ -154,7 +154,8 @@ class TextAlignment::CharMapping
|
|
154
154
|
|
155
155
|
# To perform the single letter mapping replacement
|
156
156
|
char_mapping.each do |one, long|
|
157
|
-
text.gsub!(one, long) if long.length == 1
|
157
|
+
# text.gsub!(one, long) if long.length == 1
|
158
|
+
text.tr!(one, long) if long.length == 1
|
158
159
|
end
|
159
160
|
|
160
161
|
# To get the replacement positions, (position, old_length, new_length), for char mappings
|
@@ -21,7 +21,7 @@ class << TextAlignment
|
|
21
21
|
mappings.delete_if{|m| m[0].length == 1 && m[1].length == 1}
|
22
22
|
characters_from = character_mappings.collect{|m| m[0]}.join
|
23
23
|
characters_to = character_mappings.collect{|m| m[1]}.join
|
24
|
-
characters_to.gsub!(
|
24
|
+
characters_to.gsub!('-', '\-')
|
25
25
|
|
26
26
|
source.tr!(characters_from, characters_to)
|
27
27
|
targets.each{|target| target[:text].tr!(characters_from, characters_to)}
|
@@ -10,7 +10,7 @@ class << TextAlignment
|
|
10
10
|
character_mappings = mappings.select{|m| m[0].length == 1 && m[1].length == 1}
|
11
11
|
characters_from = character_mappings.collect{|m| m[0]}.join
|
12
12
|
characters_to = character_mappings.collect{|m| m[1]}.join
|
13
|
-
characters_to.gsub!(
|
13
|
+
characters_to.gsub!('-', '\-')
|
14
14
|
|
15
15
|
str1.tr!(characters_from, characters_to)
|
16
16
|
|
@@ -13,6 +13,9 @@ end
|
|
13
13
|
class TextAlignment::LCSMin
|
14
14
|
attr_reader :sdiff, :lcs, :m1_initial, :m1_final, :m2_initial, :m2_final
|
15
15
|
|
16
|
+
WHITESPACE = ["\t", "\n", "\v", "\f", "\r", " "].join.freeze
|
17
|
+
Ractor.make_shareable(WHITESPACE)
|
18
|
+
|
16
19
|
PLACEHOLDER_CHAR = '_'
|
17
20
|
|
18
21
|
def initialize (str1, str2)
|
@@ -23,7 +26,7 @@ class TextAlignment::LCSMin
|
|
23
26
|
# str2 is copied with w/s characters replaced with the placeholder characters,
|
24
27
|
# to avoid overfitting to w/s characters during LCS computation.
|
25
28
|
@str1 = str1
|
26
|
-
@str2 = str2.
|
29
|
+
@str2 = str2.tr(WHITESPACE, PLACEHOLDER_CHAR)
|
27
30
|
|
28
31
|
# find the corresponding minimal range of the two strings
|
29
32
|
r = _find_min_range(0, @str1.length - 1, 0, @str2.length - 1)
|