Class CmdLineUtil
java.lang.Object
opennlp.tools.cmdline.CmdLineUtil
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckInputFile(String name, File inFile) Check that the given input file is valid.static voidcheckLanguageCode(String code) static voidcheckOutputFile(String name, File outFile) Tries to ensure that it is possible to write to an output file.static booleancontainsParam(String param, String[] args) static InputStreamFactorycreateInputStreamFactory(File file) static TerminateToolExceptionstatic DoublegetDoubleParameter(String param, String[] args) Retrieves the specified parameter from the specified arguments.static IntegergetIntParameter(String param, String[] args) Retrieves the specified parameter from the specified arguments.static StringgetParameter(String param, String[] args) Retrieves the specified parameter from the given arguments.static intgetParameterIndex(String param, String[] args) Returns the index of the parameter in the arguments, or-1if the parameter is not found.static voidstatic voidstatic TrainingParametersloadTrainingParameters(String paramFile, boolean supportSequenceTraining) static FileInputStreamopenInFile(File file) static voidwriteModel(String modelName, File modelFile, BaseModel model) Writes aBaseModelto disk.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
IO_BUFFER_SIZE
static final int IO_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
CmdLineUtil
private CmdLineUtil()
-
-
Method Details
-
checkInputFile
Check that the given input file is valid.To pass the test it must:
- exist
- not be a directory,
- and be accessibly.- Parameters:
name- the name which is used to refer to the file in an error message, it should start with a capital letter.inFile- the particularFileto check to qualify an input file- Throws:
TerminateToolException- if test does not pass this exception is thrown and an error message is printed to the console.
-
checkOutputFile
Tries to ensure that it is possible to write to an output file.The method does nothing if it is possible to write otherwise it prints an appropriate error message and a
TerminateToolExceptionis 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.
- Parameters:
name- human-friendly file name. for example perceptron modeloutFile- the particularFileto check to qualify an output file
-
openInFile
-
createInputStreamFactory
-
writeModel
Writes aBaseModelto disk. Occurring errors are printed to the console to inform the user.- Parameters:
modelName- name of the model, name is used in error messages.modelFile- output file of the modelmodel- the model itself which should be written to disk
-
getParameterIndex
-
getParameter
-
getIntParameter
-
getDoubleParameter
-
checkLanguageCode
-
containsParam
-
handleStdinIoError
-
createObjectStreamError
-
handleCreateObjectStreamError
-
loadTrainingParameters
public static TrainingParameters loadTrainingParameters(String paramFile, boolean supportSequenceTraining)
-