Error with adding Latin language in Tesseract OCR + Tika Core

Viewed 45

I use the latest Tesseract, and basic tesseract data pack - "tessdata".

The list of files with languages ​​is located in the following path:

E:\Program Files\tesseractOCR\tessdata
  configs
  script
  tessconfigs
  ...
  eng.traineddata
  deu.traineddata
  ukr.traineddata
  ...
  yor.traineddata

folder script:

E:\Program Files\tesseractOCR\tessdata\script
  Arabic.traineddata
  ...
  Latin.traineddata

I try to add tesseract data in config:

//other objects
AutoDetectParser parser = new AutoDetectParser();
ParseContext pc = new ParseContext(); 
Metadata metadata = new Metadata();
Tika tika = new Tika();
BodyContentHandler ch = new BodyContentHandler(-1); 
InputStream is = new FileInputStream(new File("src/main/resources/sample.txt"));

//init
TesseractOCRConfig tesserConfig = new TesseractOCRConfig();
tesserConfig.setTesseractPath("E:\\Program Files\\tesseractOCR");
tesserConfig.setTessdataPath("E:\\Program Files\\tesseractOCR\\tessdata"); 

//add
pc.set(TesseractOCRConfig.class, tesserConfig);

//using
parser.parse(is, ch, metadata, pc);  

And I try to add languages, if i try to add files from folder: E:\Program Files\tesseractOCR\tessdata

using the command:

tesserConfig.setLanguage("eng+deu+ukr");

And it all works, but if I want to add files from a folder: E:\Program Files\tesseractOCR\tessdata\script

using the command:

tesserConfig.setLanguage("script/Latin");

An error like this is thrown:

java.lang.IllegalArgumentException: Invalid language code: script/Latin
    at org.apache.tika.parser.ocr.TesseractOCRConfig.setLanguage(TesseractOCRConfig.java:252)

But even if I try other options, these are the commands:

1) tesserConfig.setLanguage("script\\Latin");

2) tesserConfig.setLanguage("Latin");

I see this error again.

Moreover, if you try to get a list of available languages ​​with such a command:

tesseract --list-langs

then you can see the following language names:

...
eng
deu
ukr
...

script/Latin
...

And it is not clear how to set the language so that it is a script

In the documentation for using tesseract via the command line, there is information that to connect languages ​​or scripts, you need to use this command:

-l LANG -l SCRIPT

so to connect eng you need to run this command:

-l end

or

tesserConfig.setLanguage("end");

But at the same time, the connection of scripts does not work, and an error message is displayed, tell me how to be, maybe there is someone who solved this problem, thanks in advance.

0 Answers
Related