|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object opennlp.tools.cmdline.CmdLineUtil
public final class CmdLineUtil
Util class for the command line interface.
Note: Do not use this class, internal use only!
Method Summary | |
---|---|
static void |
checkInputFile(String name,
File inFile)
Check that the given input file is valid. |
static void |
checkLanguageCode(String code)
|
static void |
checkOutputFile(String name,
File outFile)
Tries to ensure that it is possible to write to an output file. |
static boolean |
containsParam(String param,
String[] args)
|
static Double |
getDoubleParameter(String param,
String[] args)
Retrieves the specified parameters from the specified arguments. |
static Charset |
getEncodingParameter(String[] args)
Retrieves the "-encoding" parameter. |
static Integer |
getIntParameter(String param,
String[] args)
Retrieves the specified parameters from the specified arguments. |
static String |
getParameter(String param,
String[] args)
Retrieves the specified parameters from the given arguments. |
static void |
handleStdinIoError(IOException e)
|
static FileInputStream |
openInFile(File file)
|
static void |
printTrainingIoError(IOException e)
|
static void |
writeModel(String modelName,
File modelFile,
BaseModel model)
Writes a BaseModel to disk. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void checkInputFile(String name, File inFile)
To pass the test it must:
- exist
- not be a directory
- accessibly
name
- the name which is used to refer to the file in an error message, it
should start with a capital letter.inFile
- the particular file to check to qualify an input file
TerminateToolException
- if test does not pass this exception is
thrown and an error message is printed to the console.public static void checkOutputFile(String name, File outFile)
The method does nothing if it is possible to write otherwise
it prints an appropriate error message and a TerminateToolException
is thrown.
Computing the contents of an output file (e.g. ME model) can be very time consuming. Prior to this computation it should be checked once that writing this output file is possible to be able to fail fast if not. If this validation is only done after a time consuming computation it could frustrate the user.
name
- outFile
- public static FileInputStream openInFile(File file)
public static void writeModel(String modelName, File modelFile, BaseModel model)
BaseModel
to disk. Occurring errors are printed to the console
to inform the user.
modelName
- type of the model, name is used in error messages.modelFile
- output file of the modelmodel
- the model itself which should be written to diskpublic static String getParameter(String param, String[] args)
param
- args
-
public static Integer getIntParameter(String param, String[] args)
param
- args
-
public static Double getDoubleParameter(String param, String[] args)
param
- args
-
public static Charset getEncodingParameter(String[] args)
param
- args
-
public static void checkLanguageCode(String code)
public static boolean containsParam(String param, String[] args)
public static void printTrainingIoError(IOException e)
public static void handleStdinIoError(IOException e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |