Package opennlp.tools.util.model
Class ModelUtil
java.lang.Object
opennlp.tools.util.model.ModelUtil
Utility class for handling of
models.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCutoffAndIterations(Map<String, String> manifestInfoEntries, int cutoff, int iterations) AddscutoffanditerationstomanifestInfoEntries.static TrainingParametersCreates the defaultTrainingParametersin case they are not provided.static byte[]read(InputStream in) Reads from the providedInputStreaminto a byte array.static booleanvalidateOutcomes(MaxentModel model, String... expectedOutcomes) Checks if theexpectedOutcomesare all contained as outcomes in the givenmodel.static voidwriteModel(MaxentModel model, OutputStream out) Writes the givenMaxentModelto the specifiedOutputStream.
-
Method Details
-
writeModel
public static void writeModel(MaxentModel model, OutputStream out) throws IOException, IllegalArgumentException Writes the givenMaxentModelto the specifiedOutputStream.Note: The provided stream is not closed.
- Parameters:
model- Themodelto be written.out- thestreamto be used for writing.- Throws:
IOException- Thrown if IO errors occurred.IllegalArgumentException- Thrown if one of the parameters isnull.
-
validateOutcomes
Checks if theexpectedOutcomesare all contained as outcomes in the givenmodel.- Parameters:
model- A validMaxentModelinstance.expectedOutcomes- The outcomes to be checked for.- Returns:
trueif all expected outcomes are the only outcomes of the modelfalseotherwise.
-
read
Reads from the providedInputStreaminto a byte array.- Parameters:
in- A valid, openInputStreamto read data from.- Returns:
- A
byte[]with the data read. - Throws:
IOException- Thrown if IO errors occurred.
-
addCutoffAndIterations
public static void addCutoffAndIterations(Map<String, String> manifestInfoEntries, int cutoff, int iterations) AddscutoffanditerationstomanifestInfoEntries.- Parameters:
manifestInfoEntries- AMaprepresenting amanifest.propertiesconfig.cutoff- The cut-off value to set. Must be greater than0.iterations- The number of iterations to set. Must be greater than0.
-
createDefaultTrainingParameters
Creates the defaultTrainingParametersin case they are not provided.Note: Do not use this method, internal use only!
- Returns:
- The
TrainingParametersinstance with default configuration.
-