Package opennlp.tools.util.model
Class ModelUtil
java.lang.Object
opennlp.tools.util.model.ModelUtil
Utility class for handling of 
models.- 
Method SummaryModifier 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- 
writeModelpublic static void writeModel(MaxentModel model, OutputStream out) throws IOException, IllegalArgumentException Writes the givenMaxentModelto the specifiedOutputStream.Note: The provided stream is not closed. - Parameters:
- model- The- modelto be written.
- out- the- streamto be used for writing.
- Throws:
- IOException- Thrown if IO errors occurred.
- IllegalArgumentException- Thrown if one of the parameters is- null.
 
- 
validateOutcomesChecks if theexpectedOutcomesare all contained as outcomes in the givenmodel.- Parameters:
- model- A valid- MaxentModelinstance.
- expectedOutcomes- The outcomes to be checked for.
- Returns:
- trueif all expected outcomes are the only outcomes of the model- falseotherwise.
 
- 
readReads from the providedInputStreaminto a byte array.- Parameters:
- in- A valid, open- InputStreamto read data from.
- Returns:
- A byte[]with the data read.
- Throws:
- IOException- Thrown if IO errors occurred.
 
- 
addCutoffAndIterationspublic static void addCutoffAndIterations(Map<String, String> manifestInfoEntries, int cutoff, int iterations) AddscutoffanditerationstomanifestInfoEntries.- Parameters:
- manifestInfoEntries- A- Maprepresenting a- manifest.propertiesconfig.
- cutoff- The cut-off value to set. Must be greater than- 0.
- iterations- The number of iterations to set. Must be greater than- 0.
 
- 
createDefaultTrainingParametersCreates the defaultTrainingParametersin case they are not provided.Note: Do not use this method, internal use only! - Returns:
- The TrainingParametersinstance with default configuration.
 
 
-