diff options
author | Nick White <git@njw.name> | 2019-01-25 09:55:55 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2019-01-25 09:55:55 +0000 |
commit | 30c088b90e7b6a25d93cbdad7564ff063e62afd3 (patch) | |
tree | c47d7bc086a076cfe5e702628c4e5e3b1eab1aa5 /parse/prob | |
parent | 1c17766952bdcd6f7d31d0fa1a2e504b1aa4f14a (diff) |
Reorganisation and cleanup
Diffstat (limited to 'parse/prob')
-rw-r--r-- | parse/prob/prob.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/parse/prob/prob.go b/parse/prob/prob.go deleted file mode 100644 index 8d01cab..0000000 --- a/parse/prob/prob.go +++ /dev/null @@ -1,69 +0,0 @@ -package prob - -import ( - "io/ioutil" - "path/filepath" - "strconv" - "strings" - - "git.rescribe.xyz/testingtools/parse" -) - -func getLineAvg(f string) (float64, error) { - totalconf := float64(0) - num := 0 - - prob, err := ioutil.ReadFile(f) - if err != nil { - return 0, err - } - - for _, line := range strings.Split(string(prob), "\n") { - fields := strings.Fields(line) - - if len(fields) == 2 { - conf, err := strconv.ParseFloat(fields[1], 64) - if err != nil { - continue - } - totalconf += conf - num += 1 - } - } - if num <= 0 { - return 0, nil - } - avg := totalconf / float64(num) - return avg, nil -} - -// Note this only processes one line at a time -func GetLineDetails(probfn string) (parse.LineDetails, error) { - var line parse.LineDetail - lines := make(parse.LineDetails, 0) - - avg, err := getLineAvg(probfn) - if err != nil { - return lines, err - } - - filebase := strings.Replace(probfn, ".prob", "", 1) - - txt, err := ioutil.ReadFile(filebase + ".txt") - if err != nil { - return lines, err - } - - line.Name = filepath.Base(filebase) - line.Avgconf = avg - line.Text = string(txt) - line.OcrName = filepath.Dir(filebase) - - var imgfn parse.ImgPath - imgfn.Path = filebase + ".bin.png" - line.Img = imgfn - - lines = append(lines, line) - - return lines, nil -} |