summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-05-15 16:03:29 +0100
committerNick White <git@njw.name>2019-05-15 16:03:29 +0100
commitd7f07893d08d9c29f46e50c4f779b0e701f411e4 (patch)
treef2d2f7084f98c66de5e260bd4ec66ce7dd89cc5c
parentf49a8a74a8ef2c96cc2bbf34461a8387f7e324d8 (diff)
Return an error if page average calculation cant be done with hocr
-rw-r--r--lib/hocr/hocr.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/hocr/hocr.go b/lib/hocr/hocr.go
index bfc6a98..dcd0494 100644
--- a/lib/hocr/hocr.go
+++ b/lib/hocr/hocr.go
@@ -2,6 +2,7 @@ package hocr
import (
"encoding/xml"
+ "errors"
"io/ioutil"
"regexp"
"strconv"
@@ -121,5 +122,8 @@ func GetAvgConf(hocrfn string) (float64, error) {
num++
}
}
+ if num == 0 {
+ return 0, errors.New("No words found")
+ }
return total / num, nil
}