diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hocr/hocr.go | 4 |
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 } |