[jira] [Commented] (TIKA-3207) Invalid language code in TesseractOCRConfig

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (TIKA-3207) Invalid language code in TesseractOCRConfig

Nicholas DiPiazza (Jira)

    [ https://issues.apache.org/jira/browse/TIKA-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17211155#comment-17211155 ]

Hudson commented on TIKA-3207:
------------------------------

SUCCESS: Integrated in Jenkins build Tika ยป tika-main-jdk8 #32 (See [https://ci-builds.apache.org/job/Tika/job/tika-main-jdk8/32/])
TIKA-3207 -- allow for _vert for language codes (tallison: [https://github.com/apache/tika/commit/4c7affbffc2e0723826edacb7ebdc4498cdd05b9])
* (edit) tika-parser-modules/tika-parser-ocr-module/src/main/java/org/apache/tika/parser/ocr/TesseractOCRConfig.java
* (edit) tika-parser-modules/tika-parser-ocr-module/src/test/java/org/apache/tika/parser/ocr/TesseractOCRConfigTest.java


> Invalid language code in TesseractOCRConfig
> -------------------------------------------
>
>                 Key: TIKA-3207
>                 URL: https://issues.apache.org/jira/browse/TIKA-3207
>             Project: Tika
>          Issue Type: Bug
>          Components: ocr
>    Affects Versions: 1.24.1
>            Reporter: Daniel Smyda
>            Assignee: Tim Allison
>            Priority: Minor
>             Fix For: 1.25
>
>         Attachments: tesseract_exe.PNG
>
>
> Some language packs available on Tesseract's [github|https://github.com/tesseract-ocr/tessdata] support vertical orientations of Chinese (chi_sim_vert and chi_tra_vert). Trying to specify them via TesseractOCRConfig.setLanguage(String language) results in an exception because the regex is not expecting another underscore in the name.
> {code:java}
>     /**
>      * Set tesseract language dictionary to be used. Default is "eng".    
>      * Multiple languages may be specified, separated by plus characters.    
>      * e.g. "chi_tra+chi_sim"
>      */
>     public void setLanguage(String language) {
>         if (!language.matches("([a-zA-Z]{3}(_[a-zA-Z]{3,4})?(\\+?))+")
>                 || language.endsWith("+")) {
>             throw new IllegalArgumentException("Invalid language code");
>         }
>         this.language = language;
>     }
> {code}
> What is the reason behind validating language options?
> Either way, I'd be more than happy to supply a patch. Thank you.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)