diff options
author | Nick White <git@njw.name> | 2021-06-22 14:30:02 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-06-22 14:30:02 +0100 |
commit | 302feb863e3ae9c1cc168652d4a6d8eafd7fc57d (patch) | |
tree | 90e098f0e9b27f25d7888ace0f96f4447d912196 /cmd/rescribe/main.go | |
parent | 99175ac316657e3339c6adf66637a96c78a34603 (diff) |
rescribe: allow use of embedded training even if -systess is used
Diffstat (limited to 'cmd/rescribe/main.go')
-rw-r--r-- | cmd/rescribe/main.go | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go index c000190..56c9777 100644 --- a/cmd/rescribe/main.go +++ b/cmd/rescribe/main.go @@ -179,11 +179,12 @@ func main() { verboselog = log.New(n, "", 0) } - if !*systess && runtime.GOOS == "windows" { // TODO: drop the GOOS check here once support for other oses is done - tessdir, err = ioutil.TempDir("", "tesseract") - if err != nil { - log.Fatalln("Error setting up tesseract directory:", err) - } + tessdir, err = ioutil.TempDir("", "tesseract") + if err != nil { + log.Fatalln("Error setting up tesseract directory:", err) + } + + if !*systess { switch runtime.GOOS { case "windows": err = unpackZip(tesszip, tessdir) @@ -193,23 +194,23 @@ func main() { tessCommand = filepath.Join(tessdir, "tesseract.exe") // TODO: add linux and osx } + } - tessdatadir := filepath.Join(tessdir, "tessdata") - err = os.MkdirAll(tessdatadir, 0755) - if err != nil { - log.Fatalln("Error setting up tessdata directory:", err) - } - err = unpackZip(tessdatazip, tessdatadir) - if err != nil { - log.Fatalln("Error unpacking embedded tessdata zip:", err) - } + tessdatadir := filepath.Join(tessdir, "tessdata") + err = os.MkdirAll(tessdatadir, 0755) + if err != nil { + log.Fatalln("Error setting up tessdata directory:", err) + } + err = unpackZip(tessdatazip, tessdatadir) + if err != nil { + log.Fatalln("Error unpacking embedded tessdata zip:", err) + } - // if trainingPath doesn't exist, set it to the embedded training instead - _, err = os.Stat(trainingPath) - if !os.IsExist(err) { - trainingPath = filepath.Base(trainingPath) - trainingPath = filepath.Join(tessdatadir, trainingPath) - } + // if trainingPath doesn't exist, set it to the embedded training instead + _, err = os.Stat(trainingPath) + if !os.IsExist(err) { + trainingPath = filepath.Base(trainingPath) + trainingPath = filepath.Join(tessdatadir, trainingPath) } f, err := os.Open(trainingPath) |