You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Daniel Smyda (Jira)" <ji...@apache.org> on 2020/10/08 21:54:00 UTC
[jira] [Updated] (TIKA-3207) Invalid language code in
TesseractOCRConfig
[ https://issues.apache.org/jira/browse/TIKA-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Smyda updated TIKA-3207:
-------------------------------
Description:
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.
was:
Some language packs available on Tesseract's [github|https://github.com/tesseract-ocr/tessdata] support vertical orientations of Chinese. 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.
> 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
> Priority: Minor
>
> 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)