Class Lingo24LangDetector
java.lang.Object
org.apache.tika.language.detect.LanguageDetector
org.apache.tika.langdetect.lingo24.Lingo24LangDetector
An implementation of a Language Detector using the
Premium MT API v1.
You can sign up for an access plan online on the Lingo24 Developer Portal and set your Application's User Key in the
You can sign up for an access plan online on the Lingo24 Developer Portal and set your Application's User Key in the
langdetect.lingo24.properties file.-
Field Summary
Fields inherited from class org.apache.tika.language.detect.LanguageDetector
mixedLanguages, shortText -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor which first checks for the presence of thelangdetect.lingo24.propertiesfile to set the API Key. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddText(char[] cbuf, int off, int len) Add statistics about this text for the current document.Detect languages based on previously submitted text (via addText calls).booleanProvide information about whether a model exists for a specific language.booleanLoad (or re-load) all available language models.loadModels(Set<String> set) Load (or re-load) the models specified in. voidreset()Reset statistics about the current document being processedSet the a-priori probabilities for these languages.Methods inherited from class org.apache.tika.language.detect.LanguageDetector
addText, detect, detect, detectAll, getDefaultLanguageDetector, getLanguageDetectors, getLanguageDetectors, hasEnoughText, isMixedLanguages, isShortText, setMixedLanguages, setShortText
-
Constructor Details
-
Lingo24LangDetector
public Lingo24LangDetector()Default constructor which first checks for the presence of thelangdetect.lingo24.propertiesfile to set the API Key.If a key is available, it sets the detector as available and also loads the languages supported by the detector.
-
-
Method Details
-
loadModels
Description copied from class:LanguageDetectorLoad (or re-load) all available language models. This must be called after any settings that would impact the models being loaded (e.g. mixed language/short text), but before any of the document processing routines (below) are called. Note that it only needs to be called once.- Specified by:
loadModelsin classLanguageDetector- Returns:
- this
- Throws:
IOException
-
loadModels
Description copied from class:LanguageDetectorLoad (or re-load) the models specified in. These use the ISO 639-1 names, with an optional "- " for more specific specification (e.g. "zh-CN" for Chinese in China). - Specified by:
loadModelsin classLanguageDetector- Parameters:
set- list of target languages.- Returns:
- this
- Throws:
IOException
-
hasModel
Description copied from class:LanguageDetectorProvide information about whether a model exists for a specific language.- Specified by:
hasModelin classLanguageDetector- Parameters:
language- ISO 639-1 name for language- Returns:
- true if a model for this language exists.
-
setPriors
Description copied from class:LanguageDetectorSet the a-priori probabilities for these languages. The provided map uses the language as the key, and the probability (0.0 > probability < 1.0) of text being in that language. Note that if the probabilities don't sum to 1.0, these values will be normalized.If hasModel() returns false for any of the languages, an IllegalArgumentException is thrown.
Use of these probabilities is detector-specific, and thus might not impact the results at all. As such, these should be viewed as a hint.
- Specified by:
setPriorsin classLanguageDetector- Parameters:
languageProbabilities- Map from language to probability- Returns:
- this
- Throws:
IOException
-
reset
public void reset()Description copied from class:LanguageDetectorReset statistics about the current document being processed- Specified by:
resetin classLanguageDetector
-
addText
public void addText(char[] cbuf, int off, int len) Description copied from class:LanguageDetectorAdd statistics about this text for the current document. Note that we assume an implicit word break exists before/after each of these runs of text.- Specified by:
addTextin classLanguageDetector- Parameters:
cbuf- Character bufferoff- Offset into cbuf to first character in the run of textlen- Number of characters in the run of text.
-
detectAll
Description copied from class:LanguageDetectorDetect languages based on previously submitted text (via addText calls).- Specified by:
detectAllin classLanguageDetector- Returns:
- list of all possible languages with at least medium confidence, sorted by confidence from highest to lowest. There will always be at least one result, which might have a confidence of NONE.
-
isAvailable
public boolean isAvailable()- Returns:
- true if this Detector is probably able to detect right now.
-