Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-3207

Invalid language code in TesseractOCRConfig

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.24.1
    • Fix Version/s: 1.25
    • Component/s: ocr
    • Labels:
      None

      Description

      Some language packs available on Tesseract's github 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.

          /**
           * 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;
          }
      

      What is the reason behind validating language options?

      Either way, I'd be more than happy to supply a patch. Thank you.

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              tallison Tim Allison
              Reporter:
              dsmyda Daniel Smyda

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment