public abstract class ExternalTranslator extends Object implements Translator
for an example of extending this class.
Constructor and Description |
---|
ExternalTranslator() |
Modifier and Type | Method and Description |
---|---|
boolean |
checkCommand(String checkCommandString,
int... successCodes)
Checks to see if the command can be run.
|
Reader |
runAndGetOutput(String command,
String[] env,
File workingDirectory)
Run the given command and return the output written to standard out.
|
String |
translate(String text,
String targetLanguage)
Default translate method which uses built Tika language identification.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isAvailable, translate
public Reader runAndGetOutput(String command, String[] env, File workingDirectory) throws IOException, InterruptedException
command
- The complete command to run.env
- The environment to pass along to the Runtime.workingDirectory
- The directory from which to run the command.IOException
InterruptedException
public boolean checkCommand(String checkCommandString, int... successCodes)
checkCommandString
- The command to run and check the return code of.successCodes
- Return codes that signify success.public String translate(String text, String targetLanguage) throws TikaException, IOException
translate
in interface Translator
text
- The text to translate.targetLanguage
- The desired language to translate to (for example, "hi").Exception
TikaException
- When there is an error translating.IOException
Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.