From f49a8a74a8ef2c96cc2bbf34461a8387f7e324d8 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 14 May 2019 18:02:34 +0100 Subject: Rewrite pgconf to be more accurate by measuring average word confidence rather than average line confidence --- pgconf/main.go | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'pgconf') diff --git a/pgconf/main.go b/pgconf/main.go index d254f42..bc09c23 100644 --- a/pgconf/main.go +++ b/pgconf/main.go @@ -7,7 +7,6 @@ import ( "os" "rescribe.xyz/go.git/lib/hocr" - "rescribe.xyz/go.git/lib/line" ) func main() { @@ -22,31 +21,10 @@ func main() { os.Exit(1) } - var err error - lines := make(line.Details, 0) - - for _, f := range flag.Args() { - var newlines line.Details - newlines, err = hocr.GetLineBasics(f) - if err != nil { - log.Fatal(err) - } - - for _, l := range newlines { - lines = append(lines, l) - } - } - - if len(lines) == 0 { - fmt.Printf("No lines found\n") - os.Exit(0) - } - - var total float64 - for _, l := range lines { - total += l.Avgconf + avg, err := hocr.GetAvgConf(flag.Arg(0)) + if err != nil { + log.Fatalf("Error retreiving confidence for %s: %v\n", flag.Arg(0), err) } - avg := total / float64(len(lines)) - fmt.Printf("%0.0f\n", avg * 100) + fmt.Printf("%0.0f\n", avg) } -- cgit v1.2.1-24-ge1ad