Package opennlp.tools.util.model
Class ModelUtil
java.lang.Object
opennlp.tools.util.model.ModelUtil
Utility class for handling of
MaxentModels.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCutoffAndIterations(Map<String, String> manifestInfoEntries, int cutoff, int iterations) static TrainingParametersCreates the default training parameters in case they are not provided.static byte[]read(InputStream in) Writes the providedInputStreaminto a byte array which is returnedstatic booleanvalidateOutcomes(MaxentModel model, String... expectedOutcomes) Checks if the expected outcomes are all contained as outcomes in the given model.static voidwriteModel(MaxentModel model, OutputStream out) Writes the given model to the givenOutputStream.
-
Method Details
-
writeModel
public static void writeModel(MaxentModel model, OutputStream out) throws IOException, IllegalArgumentException Writes the given model to the givenOutputStream. This methods does not closes the provided stream.- Parameters:
model- the model to be writtenout- the stream the model should be written to- Throws:
IOExceptionIllegalArgumentException- in case one of the parameters is null
-
validateOutcomes
Checks if the expected outcomes are all contained as outcomes in the given model.- Parameters:
model-expectedOutcomes-- Returns:
- true if all expected outcomes are the only outcomes of the model.
-
read
Writes the providedInputStreaminto a byte array which is returned- Parameters:
in- stream to read data for the byte array from- Returns:
- byte array with the contents of the stream
- Throws:
IOException- if an exception is thrown while reading from the providedInputStream
-
addCutoffAndIterations
-
createDefaultTrainingParameters
Creates the default training parameters in case they are not provided. Note: Do not use this method, internal use only!- Returns:
- training parameters instance
-