From 988658936cbcd8e92b35a66e1943bea0f9eaf3bc Mon Sep 17 00:00:00 2001 From: Nick White Date: Fri, 25 Jan 2019 17:41:52 +0000 Subject: gofmt --- lib/hocr/hocr.go | 24 ++++++++++++------------ lib/hocr/lines.go | 12 ++++++------ lib/line/line.go | 12 ++++++------ lib/prob/prob.go | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/hocr/hocr.go b/lib/hocr/hocr.go index 0d10819..bbcf8a2 100644 --- a/lib/hocr/hocr.go +++ b/lib/hocr/hocr.go @@ -12,27 +12,27 @@ type Hocr struct { } type OcrLine struct { - Class string `xml:"class,attr"` - Id string `xml:"id,attr"` - Title string `xml:"title,attr"` + Class string `xml:"class,attr"` + Id string `xml:"id,attr"` + Title string `xml:"title,attr"` Words []OcrWord `xml:"span"` - Text string `xml:",chardata"` + Text string `xml:",chardata"` } type OcrWord struct { - Class string `xml:"class,attr"` - Id string `xml:"id,attr"` - Title string `xml:"title,attr"` + Class string `xml:"class,attr"` + Id string `xml:"id,attr"` + Title string `xml:"title,attr"` Chars []OcrChar `xml:"span"` - Text string `xml:",chardata"` + Text string `xml:",chardata"` } type OcrChar struct { - Class string `xml:"class,attr"` - Id string `xml:"id,attr"` - Title string `xml:"title,attr"` + Class string `xml:"class,attr"` + Id string `xml:"id,attr"` + Title string `xml:"title,attr"` Chars []OcrChar `xml:"span"` - Text string `xml:",chardata"` + Text string `xml:",chardata"` } // Returns the confidence for a word based on its x_wconf value diff --git a/lib/hocr/lines.go b/lib/hocr/lines.go index 84c2130..00acd1f 100644 --- a/lib/hocr/lines.go +++ b/lib/hocr/lines.go @@ -36,27 +36,27 @@ func parseLineDetails(h Hocr, i image.Image, name string) (line.Details, error) var ln line.Detail ln.Name = l.Id - ln.Avgconf = (totalconf/float64(num)) / 100 + ln.Avgconf = (totalconf / float64(num)) / 100 linetext := "" linetext = l.Text - if(noText(linetext)) { + if noText(linetext) { linetext = "" for _, w := range l.Words { - if(w.Class != "ocrx_word") { + if w.Class != "ocrx_word" { continue } linetext += w.Text + " " } } - if(noText(linetext)) { + if noText(linetext) { linetext = "" for _, w := range l.Words { - if(w.Class != "ocrx_word") { + if w.Class != "ocrx_word" { continue } for _, c := range w.Chars { - if(c.Class != "ocrx_cinfo") { + if c.Class != "ocrx_cinfo" { continue } linetext += c.Text diff --git a/lib/line/line.go b/lib/line/line.go index 3adac0a..656fbce 100644 --- a/lib/line/line.go +++ b/lib/line/line.go @@ -8,15 +8,15 @@ import ( ) type Detail struct { - Name string + Name string Avgconf float64 - Img CopyableImg - Text string + Img CopyableImg + Text string OcrName string } type CopyableImg interface { - CopyLineTo(io.Writer) (error) + CopyLineTo(io.Writer) error } type Details []Detail @@ -38,7 +38,7 @@ type ImgDirect struct { Img image.Image } -func (i ImgDirect) CopyLineTo(w io.Writer) (error) { +func (i ImgDirect) CopyLineTo(w io.Writer) error { err := png.Encode(w, i.Img) if err != nil { return err @@ -52,7 +52,7 @@ type ImgPath struct { Path string } -func (i ImgPath) CopyLineTo(w io.Writer) (error) { +func (i ImgPath) CopyLineTo(w io.Writer) error { f, err := os.Open(i.Path) if err != nil { return err diff --git a/lib/prob/prob.go b/lib/prob/prob.go index 2fd7fb9..31a484d 100644 --- a/lib/prob/prob.go +++ b/lib/prob/prob.go @@ -14,7 +14,7 @@ func getLineAvg(f string) (float64, error) { num := 0 prob, err := ioutil.ReadFile(f) - if err != nil { + if err != nil { return 0, err } -- cgit v1.2.1-24-ge1ad