@Override
    public String translate(String text, String sourceLanguage, String targetLanguage)
            throws TikaException, IOException {
        if (!isAvailable() || !checkCommand(buildCheckCommand(smtPath), 1)) {
            return text;
        }
        File tmpFile = new File(TMP_FILE_NAME);
        try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(tmpFile),
                Charset.defaultCharset())) {
            out.append(text).append('\n').close();
        }

        Runtime.getRuntime().exec(buildCommand(smtPath, scriptPath), new String[]{},
                buildWorkingDirectory(scriptPath));

        File tmpTranslatedFile = new File(TMP_FILE_NAME + ".translated");

        StringBuilder stringBuilder = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(
                new InputStreamReader(new FileInputStream(tmpTranslatedFile),
                        Charset.defaultCharset()))) {
            String line;
            while ((line = reader.readLine()) != null) stringBuilder.append(line);
        }

        if (!tmpFile.delete() || !tmpTranslatedFile.delete()) {
            throw new IOException("Failed to delete temporary files.");
        }
        return stringBuilder.toString();
    }
Create a Moses Translator with the specified smt jar and script paths.

@param smtPath    Full path to the jar to run.
@param scriptPath Full path to the script to pass to the smt jar.
tika-translate/src/main/java/org/apache/tika/language/translate/impl/MosesTranslator.java