banktools-se 2.6.2 → 2.6.3
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 +6 -3
- 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: 6df052c5e1e856bc395b39e9e9355817f5a0bcdb
|
4
|
+
data.tar.gz: 82f54243c1e5ed41b80c4689d3c6e0cd7656aa21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cc99d6b3c4e554c68401414da3e8b679f552603654d42c4667e0a723ce730785f4b0c3ee7a0652e7bc30b610bec98681459df40f4cd5dc0548458cee03ce6dc
|
7
|
+
data.tar.gz: 49557f51445e632e2f6ac97717d1a13c98696fcae3a865cf2a62a4918d3733fdbca7948642984b0e7102e1d8717a3f16dd529505ac6bcacefb3dcdf473ebe374
|
data/lib/banktools-se/ocr.rb
CHANGED
@@ -68,14 +68,15 @@ module BankTools
|
|
68
68
|
def self.find_all_in_string(string, length_digit: false, pad: "", min_length: 4, max_length: 19)
|
69
69
|
# First, treat the input as one long string of digits.
|
70
70
|
# E.g. "1234 and 5678" becomes "12345678".
|
71
|
-
digit_string = string.gsub(/\D/, "")
|
72
|
-
digit_string_length = digit_string.length
|
73
71
|
|
74
|
-
|
72
|
+
digit_string = string.gsub(/\D/, "")
|
75
73
|
|
76
74
|
# Then find all substrings ("n-grams") of min_length, and of all other lengths, up to max_length.
|
77
75
|
# So e.g. find all four-digit substrings ("1234", "2345", …), all five-digit substrings and so on.
|
78
76
|
|
77
|
+
digit_string_length = digit_string.length
|
78
|
+
candidates = []
|
79
|
+
|
79
80
|
0.upto(digit_string.length - min_length) do |start_pos|
|
80
81
|
min_end_pos = start_pos + min_length - 1
|
81
82
|
max_end_pos = [ start_pos + max_length, digit_string_length ].min - 1
|
@@ -85,6 +86,8 @@ module BankTools
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
89
|
+
# Get rid of any duplicates.
|
90
|
+
|
88
91
|
candidates.uniq!
|
89
92
|
|
90
93
|
# Finally, limit these substrings to ones that are actually valid OCRs.
|
data/lib/banktools-se/version.rb
CHANGED