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

Invalid language code in TesseractOCRConfig

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.24.1
    • 1.25
    • ocr
    • 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

        1. tesseract_exe.PNG
          14 kB
          Daniel Smyda

        Issue Links

          Activity

            People

              tallison Tim Allison
              dsmyda Daniel Smyda
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: