Skip to content

Commit 349995d

Browse files
committed
fix: Remove longest digit fallback for OCR
It can erroneously identify unrelated numbers and doesn't make sense when `-ocr-match-regex` exists.
1 parent 3f91e09 commit 349995d

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

ocr.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ func parseOCRFixRegex(s string) *ocrFixRule {
105105
}
106106

107107
func extractReading(texts []string, matchRe *regexp.Regexp, fixRule *ocrFixRule) string {
108-
// First pass: apply fix rule if set, then match.
109108
for _, t := range texts {
110109
t = strings.TrimSpace(t)
111110
if fixRule != nil {
@@ -115,19 +114,7 @@ func extractReading(texts []string, matchRe *regexp.Regexp, fixRule *ocrFixRule)
115114
return t
116115
}
117116
}
118-
// Fallback: longest all-digit string.
119-
digitsOnly := regexp.MustCompile(`^\d+$`)
120-
best := ""
121-
for _, t := range texts {
122-
t = strings.TrimSpace(t)
123-
if fixRule != nil {
124-
t = fixRule.Pattern.ReplaceAllString(t, fixRule.Replacement)
125-
}
126-
if digitsOnly.MatchString(t) && len(t) > len(best) {
127-
best = t
128-
}
129-
}
130-
return best
117+
return ""
131118
}
132119

133120
func runOCR(imagePath string) (*ocrOutput, error) {

0 commit comments

Comments
 (0)