banktools-se 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/banktools-se/ocr.rb +4 -16
- data/lib/banktools-se/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b894da43f509502745e6968c8f9d3480d2d72b59
|
4
|
+
data.tar.gz: 47544abc5aff3ab18721b38b81747d8981e2da62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25446e83d4ef271b3a315f42e888913041ec04978cc8167924487e5f621cfe93f9754fbf7a6554eb29aa48c5c12918932b16ecc3728bd1a1608e49d2b967bc70
|
7
|
+
data.tar.gz: 3a24188bd9119006d3896dd9463148fce4ec43fbf60c4d570396e320dd5fec4944068fa9ca40f0c14d59d53ea662db0250b0282cd46250b08930984ee9205449
|
data/lib/banktools-se/ocr.rb
CHANGED
@@ -73,7 +73,7 @@ module BankTools
|
|
73
73
|
|
74
74
|
candidates = []
|
75
75
|
|
76
|
-
# Then find all substrings of min_length, and of all other lengths, up to max_length.
|
76
|
+
# Then find all substrings ("n-grams") of min_length, and of all other lengths, up to max_length.
|
77
77
|
# So e.g. find all four-digit substrings ("1234", "2345", …), all five-digit substrings and so on.
|
78
78
|
|
79
79
|
0.upto(digit_string.length - min_length) do |start_pos|
|
@@ -85,6 +85,8 @@ module BankTools
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
candidates.uniq!
|
89
|
+
|
88
90
|
# Finally, limit these substrings to ones that are actually valid OCRs.
|
89
91
|
|
90
92
|
candidates.select { |candidate|
|
@@ -94,21 +96,7 @@ module BankTools
|
|
94
96
|
rescue InvalidOCR
|
95
97
|
false
|
96
98
|
end
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
private
|
101
|
-
|
102
|
-
private_class_method \
|
103
|
-
def self.with_numbers_found_by_removing_prefix_and_postfix(numbers)
|
104
|
-
numbers + numbers.flat_map { |number|
|
105
|
-
0.upto(number.size).flat_map { |i|
|
106
|
-
[
|
107
|
-
number[0...i],
|
108
|
-
number[i...number.size],
|
109
|
-
]
|
110
|
-
}
|
111
|
-
}
|
99
|
+
}
|
112
100
|
end
|
113
101
|
end
|
114
102
|
end
|
data/lib/banktools-se/version.rb
CHANGED