Class LanguageHelper

java.lang.Object
org.codelibs.fess.helper.LanguageHelper

public class LanguageHelper extends Object
Helper class for language detection.
  • Field Details

    • langFields

      protected String[] langFields
      An array of language fields.
    • supportedLanguages

      protected String[] supportedLanguages
      An array of supported languages.
    • detector

      protected org.apache.tika.language.detect.LanguageDetector detector
      The language detector.
    • maxTextLength

      protected int maxTextLength
      The maximum text length for language detection.
  • Constructor Details

    • LanguageHelper

      public LanguageHelper()
      Default constructor.
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the helper.
    • updateDocument

      public void updateDocument(Map<String,Object> doc)
      Updates a document with language information.
      Parameters:
      doc - The document to update.
    • detectLanguage

      protected String detectLanguage(String text)
      Detects the language of a text.
      Parameters:
      text - The text to detect the language from.
      Returns:
      The detected language.
    • getDetectText

      protected String getDetectText(String text)
      Returns the text to be used for language detection.
      Parameters:
      text - The original text.
      Returns:
      The text for language detection.
    • getSupportedLanguage

      protected String getSupportedLanguage(String lang)
      Returns the supported language for a given language.
      Parameters:
      lang - The language to check.
      Returns:
      The supported language, or null if not supported.
    • setDetector

      public void setDetector(org.apache.tika.language.detect.LanguageDetector detector)
      Sets the language detector.
      Parameters:
      detector - The language detector.
    • createScript

      public org.opensearch.script.Script createScript(Map<String,Object> doc, String code)
      Creates a script for updating a document with language information.
      Parameters:
      doc - The document.
      code - The script code.
      Returns:
      The script.
    • getReindexScriptSource

      public String getReindexScriptSource()
      Returns the reindex script source.
      Returns:
      The reindex script source.