Class MarianTranslator
java.lang.Object
org.apache.tika.language.translate.impl.AbstractTranslator
org.apache.tika.language.translate.impl.MarianTranslator
- All Implemented Interfaces:
Translator
Translator that uses the Marian NMT decoder for translation.
Users must install Marian NMT and configure model locations before using this Translator.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Internal Client for marian-server Web Socket Server. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
isAvailable
(String sourceLanguage, String targetLanguage) Checks if the approproate Marian engine is available.Default translate method which uses built Tika language identification.Translate method with specific source and target languages.Methods inherited from class org.apache.tika.language.translate.impl.AbstractTranslator
detectLanguage
-
Constructor Details
-
MarianTranslator
public MarianTranslator()Default constructor.
-
-
Method Details
-
translate
Default translate method which uses built Tika language identification.- Parameters:
text
- The text to translate.targetLanguage
- The desired language to translate to (for example, "hi").- Returns:
- The translated text.
- Throws:
TikaException
- on any error performing translation.IOException
- on any I/O error performing translation.
-
translate
public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException Translate method with specific source and target languages.- Parameters:
text
- The text to translate.sourceLanguage
- The language to translate from (for example, "en").targetLanguage
- The desired language to translate to (for example, "hi").- Returns:
- The translated text.
- Throws:
TikaException
- on any error performing translation.IOException
- on any I/O error performing translation.
-
isAvailable
public boolean isAvailable()- Returns:
- true if this Translator is probably able to translate right now.
-
isAvailable
Checks if the approproate Marian engine is available.- Parameters:
sourceLanguage
- The language to translate from (for example, "en").targetLanguage
- The desired language to translate to (for example, "hi").- Returns:
-