diff options
author | Nick White <git@njw.name> | 2021-03-23 14:51:14 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-03-23 14:51:14 +0000 |
commit | 179dba971a77701ac7b3f19c7f37c1b049af11e9 (patch) | |
tree | bc8996fe0dc98ec873efd4f19cfad63897458131 /cmd | |
parent | b01b9176c72832cc08aed52422302230fce5e6cb (diff) |
extracthocrlines: Replace -e with -b, its opposite, and make it default
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/extracthocrlines/main.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cmd/extracthocrlines/main.go b/cmd/extracthocrlines/main.go index 3fbafd0..d4f0d53 100644 --- a/cmd/extracthocrlines/main.go +++ b/cmd/extracthocrlines/main.go @@ -20,7 +20,7 @@ import ( "rescribe.xyz/utils/pkg/line" ) -const usage = `Usage: extracthocrlines [-d] [-e] file.hocr [file.hocr] +const usage = `Usage: extracthocrlines [-b] [-d] file.hocr [file.hocr] Copies the text and corresponding image section for each line of a HOCR file into separate files, which is useful for OCR @@ -64,8 +64,8 @@ func main() { fmt.Fprintf(flag.CommandLine.Output(), usage) flag.PrintDefaults() } + usebasepath := flag.Bool("b", false, "Use the image path of the .hocr with the .hocr suffix stripped and replaced with .png, rather than the path embedded in the .hocr") dir := flag.String("d", ".", "Directory to save lines in") - embeddedimgpath := flag.Bool("e", false, "Use image path embedded in hOCR (rather than the path of the .hocr file with a .png suffix)") flag.Parse() if flag.NArg() < 1 { flag.Usage() @@ -75,11 +75,11 @@ func main() { for _, f := range flag.Args() { var err error var newlines line.Details - if *embeddedimgpath { - newlines, err = hocr.GetLineDetails(f) - } else { + if *usebasepath { imgName := strings.TrimSuffix(f, ".hocr") + ".png" newlines, err = hocr.GetLineDetailsCustomImg(f, imgName) + else { + newlines, err = hocr.GetLineDetails(f) } if err != nil { log.Fatal(err) |