Class MosesTranslator

All Implemented Interfaces:

public class MosesTranslator extends ExternalTranslator
Translator that uses the Moses decoder for translation. Users must install the Moses system before using this Translator. @link
  • Constructor Details

    • MosesTranslator

      public MosesTranslator()
      Default constructor that attempts to read the smt jar and script paths from the file.
      AssertionError - When the properties file is unreadable.
    • MosesTranslator

      public MosesTranslator(String smtPath, String scriptPath)
      Create a Moses Translator with the specified smt jar and script paths.
      smtPath - Full path to the jar to run.
      scriptPath - Full path to the script to pass to the smt jar.
  • Method Details

    • translate

      public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException
      Description copied from interface: Translator
      Translate text between given languages.
      text - The text to translate.
      sourceLanguage - The input text language (for example, "en").
      targetLanguage - The desired language to translate to (for example, "fr").
      The translation result. If translation is unavailable, returns the same text back.
      TikaException - When there is an error translating.
    • isAvailable

      public boolean isAvailable()
      true if this Translator is probably able to translate right now.