summaryrefslogtreecommitdiff
path: root/go/ocr-numbers/ocr_numbers.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/ocr-numbers/ocr_numbers.go')
-rw-r--r--go/ocr-numbers/ocr_numbers.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/go/ocr-numbers/ocr_numbers.go b/go/ocr-numbers/ocr_numbers.go
index fb9c502..b9cf0c0 100644
--- a/go/ocr-numbers/ocr_numbers.go
+++ b/go/ocr-numbers/ocr_numbers.go
@@ -56,6 +56,7 @@ func splitLineByGroup(line string) []string {
}
func Recognize(s string) []string {
+ // sanitize input, split by groups
re, _ := regexp.Compile("\n *\n")
s = re.ReplaceAllString(s, "\n\n")
groups := strings.Split(s, "\n\n")
@@ -85,7 +86,7 @@ func recognizeDigit(s string) string {
}
var ret []rune
for _, v := range o {
- if len(v) > 0 {
+ if len(v) == 1 {
ret = append(ret, rune('0'+v[0]))
} else {
ret = append(ret, '?')