Package opennlp.tools.util.model
Class ModelUtil
- java.lang.Object
-
- opennlp.tools.util.model.ModelUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddCutoffAndIterations(Map<String,String> manifestInfoEntries, int cutoff, int iterations)AddscutoffanditerationstomanifestInfoEntries.static TrainingParameterscreateDefaultTrainingParameters()Creates 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 Detail
-
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
public static boolean validateOutcomes(MaxentModel model, String... expectedOutcomes)
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
public static byte[] read(InputStream in) throws IOException
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
@Internal public static TrainingParameters createDefaultTrainingParameters()
Creates the defaultTrainingParametersin case they are not provided.Note: Do not use this method, internal use only!
- Returns:
- The
TrainingParametersinstance with default configuration.
-
-