Class MarianTranslator
- java.lang.Object
- 
- org.apache.tika.language.translate.impl.AbstractTranslator
- 
- org.apache.tika.language.translate.impl.MarianTranslator
 
 
- 
- All Implemented Interfaces:
- Translator
 
 public class MarianTranslator extends AbstractTranslator Translator that uses the Marian NMT decoder for translation.Users must install Marian NMT and configure model locations before using this Translator. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classMarianTranslator.MarianServerClientInternal Client for marian-server Web Socket Server.
 - 
Constructor SummaryConstructors Constructor Description MarianTranslator()Default constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisAvailable()booleanisAvailable(String sourceLanguage, String targetLanguage)Checks if the approproate Marian engine is available.Stringtranslate(String text, String targetLanguage)Default translate method which uses built Tika language identification.Stringtranslate(String text, String sourceLanguage, String targetLanguage)Translate method with specific source and target languages.- 
Methods inherited from class org.apache.tika.language.translate.impl.AbstractTranslatordetectLanguage
 
- 
 
- 
- 
- 
Method Detail- 
translatepublic String translate(String text, String targetLanguage) throws TikaException, IOException 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.
 
 - 
translatepublic 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.
 
 - 
isAvailablepublic boolean isAvailable() - Returns:
- true if this Translator is probably able to translate right now.
 
 - 
isAvailablepublic boolean isAvailable(String sourceLanguage, String targetLanguage) 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:
 
 
- 
 
-