Package org.codelibs.fess.helper
Class LanguageHelper
java.lang.Object
org.codelibs.fess.helper.LanguageHelper
Helper class for language detection.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.opensearch.script.ScriptcreateScript(Map<String, Object> doc, String code) Creates a script for updating a document with language information.protected StringdetectLanguage(String text) Detects the language of a text.protected StringgetDetectText(String text) Returns the text to be used for language detection.Returns the reindex script source.protected StringgetSupportedLanguage(String lang) Returns the supported language for a given language.voidinit()Initializes the helper.voidsetDetector(org.apache.tika.language.detect.LanguageDetector detector) Sets the language detector.voidupdateDocument(Map<String, Object> doc) Updates a document with language information.
-
Field Details
-
langFields
An array of language fields. -
supportedLanguages
An array of supported languages. -
detector
protected org.apache.tika.language.detect.LanguageDetector detectorThe language detector. -
maxTextLength
protected int maxTextLengthThe maximum text length for language detection.
-
-
Constructor Details
-
LanguageHelper
public LanguageHelper()Default constructor.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the helper. -
updateDocument
Updates a document with language information.- Parameters:
doc- The document to update.
-
detectLanguage
Detects the language of a text.- Parameters:
text- The text to detect the language from.- Returns:
- The detected language.
-
getDetectText
Returns the text to be used for language detection.- Parameters:
text- The original text.- Returns:
- The text for language detection.
-
getSupportedLanguage
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
Creates a script for updating a document with language information.- Parameters:
doc- The document.code- The script code.- Returns:
- The script.
-
getReindexScriptSource
Returns the reindex script source.- Returns:
- The reindex script source.
-