summaryrefslogtreecommitdiff
path: root/avg-lines/html.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-10-08 12:52:33 +0100
committerNick White <git@njw.name>2019-10-08 12:52:33 +0100
commit7482157a03ed3e9d7f45e54a126b391001f34948 (patch)
tree52f87b9ca159fe4c04a0349de95ea9de82692b3c /avg-lines/html.go
parentd43c11bf653bfe3c1ad1ed277f1ec08bf155cf98 (diff)
Separate out bookpipeline from catch-all go.git repo, and rename to rescribe.xyz/bookpipeline
The dependencies from the go.git repo will follow in due course.
Diffstat (limited to 'avg-lines/html.go')
-rw-r--r--avg-lines/html.go61
1 files changed, 0 insertions, 61 deletions
diff --git a/avg-lines/html.go b/avg-lines/html.go
deleted file mode 100644
index 443cc4a..0000000
--- a/avg-lines/html.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package main
-
-import (
- "fmt"
- "os"
- "path/filepath"
-
- "rescribe.xyz/go.git/lib/line"
-)
-
-func copylineimg(fn string, l line.Detail) error {
- f, err := os.Create(fn)
- if err != nil {
- return err
- }
- defer f.Close()
-
- return l.Img.CopyLineTo(f)
-}
-
-func htmlout(dir string, lines line.Details) error {
- err := os.MkdirAll(dir, 0700)
- if err != nil {
- return err
- }
-
- fn := filepath.Join(dir, "index.html")
- f, err := os.Create(fn)
- if err != nil {
- return err
- }
- defer f.Close()
-
- _, err = fmt.Fprintf(f, "<!DOCTYPE html><html><head><meta charset='UTF-8'><title></title>"+
- "<style>td {border: 1px solid #444}</style></head><body>\n<table>\n")
- if err != nil {
- return err
- }
- for _, l := range lines {
- fn = filepath.Base(l.OcrName) + "_" + l.Name + ".png"
- err = copylineimg(filepath.Join(dir, fn), l)
- if err != nil {
- return err
- }
- _, err = fmt.Fprintf(f, "<tr>\n"+
- "<td><h1>%.4f%%</h1></td>\n"+
- "<td>%s %s</td>\n"+
- "<td><img src='%s' width='100%%' /><br />%s</td>\n"+
- "</tr>\n",
- l.Avgconf, l.OcrName, l.Name, fn, l.Text)
- if err != nil {
- return err
- }
- }
- _, err = fmt.Fprintf(f, "</table>\n</body></html>\n")
- if err != nil {
- return err
- }
-
- return nil
-}