public class MarianTranslator extends AbstractTranslator
Users must install Marian NMT and configure model locations before using this Translator.
Modifier and Type | Class and Description |
---|---|
static class |
MarianTranslator.MarianServerClient
Internal Client for marian-server Web Socket Server.
|
Constructor and Description |
---|
MarianTranslator()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isAvailable() |
boolean |
isAvailable(String sourceLanguage,
String targetLanguage)
Checks if the approproate Marian engine is available.
|
String |
translate(String text,
String targetLanguage)
Default translate method which uses built Tika language identification.
|
String |
translate(String text,
String sourceLanguage,
String targetLanguage)
Translate method with specific source and target languages.
|
detectLanguage
public String translate(String text, String targetLanguage) throws TikaException, IOException
text
- The text to translate.targetLanguage
- The desired language to translate to (for example, "hi").TikaException
- on any error performing translation.IOException
- on any I/O error performing translation.public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException
text
- The text to translate.sourceLanguage
- The language to translate from (for example, "en").targetLanguage
- The desired language to translate to (for example, "hi").TikaException
- on any error performing translation.IOException
- on any I/O error performing translation.public boolean isAvailable()
public boolean isAvailable(String sourceLanguage, String targetLanguage)
sourceLanguage
- The language to translate from (for example, "en").targetLanguage
- The desired language to translate to (for example, "hi").Copyright © 2007–2022 The Apache Software Foundation. All rights reserved.