Package opennlp.tools.depparse
Class DependencyModel
java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.depparse.DependencyModel
- All Implemented Interfaces:
Serializable,ArtifactProvider
The persisted form of a trained
DependencyParserME: the transition
classification model plus the standard model manifest, serialized and loaded through
the same BaseModel machinery as every other tool model.- Since:
- 3.0.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe component name recorded in the model manifest.(package private) static final StringThe artifact map entry holding the transition classification model.private static final longFields inherited from class opennlp.tools.util.model.BaseModel
artifactMap, FACTORY_NAME, MANIFEST_ENTRY, toolFactory, TRAINING_CUTOFF_PROPERTY, TRAINING_EVENTHASH_PROPERTY, TRAINING_ITERATIONS_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionDependencyModel(File modelFile) Initializes aDependencyModelfrom a serialized model file.Initializes aDependencyModelfrom a serialized model.DependencyModel(String languageCode, MaxentModel parserModel, Map<String, String> manifestInfoEntries) Initializes aDependencyModelfrom a trained transition model.DependencyModel(Path modelPath) Initializes aDependencyModelfrom a serialized model file. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidValidates the parsed artifacts.Methods inherited from class opennlp.tools.util.model.BaseModel
checkArtifactMap, createArtifactSerializers, createArtifactSerializers, deserialize, getArtifact, getArtifactSerializer, getDefaultFactory, getLanguage, getManifestProperty, getVersion, isLoadedFromSerialized, serialize, serialize, serialize, setManifestProperty, skipEntryForSerialization
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
COMPONENT_NAME
The component name recorded in the model manifest.- See Also:
-
PARSER_MODEL_ENTRY_NAME
The artifact map entry holding the transition classification model.- See Also:
-
-
Constructor Details
-
DependencyModel
public DependencyModel(String languageCode, MaxentModel parserModel, Map<String, String> manifestInfoEntries) Initializes aDependencyModelfrom a trained transition model.- Parameters:
languageCode- The ISO language code of the training data. Must not benull.parserModel- The transition classification model. Must not benull.manifestInfoEntries- Additional entries for the manifest, ornull.- Throws:
IllegalArgumentException- Thrown iflanguageCodeorparserModelisnull.
-
DependencyModel
Initializes aDependencyModelfrom a serialized model.- Parameters:
in- The stream to read the model from. Must not benull.- Throws:
IOException- Thrown if reading fails or the content is not a valid model.IllegalArgumentException- Thrown ifinisnull.
-
DependencyModel
Initializes aDependencyModelfrom a serialized model file.- Parameters:
modelFile- The file to read the model from. Must not benull.- Throws:
IOException- Thrown if reading fails or the content is not a valid model.IllegalArgumentException- Thrown ifmodelFileisnull.
-
DependencyModel
Initializes aDependencyModelfrom a serialized model file.- Parameters:
modelPath- The path to read the model from. Must not benull.- Throws:
IOException- Thrown if reading fails or the content is not a valid model.IllegalArgumentException- Thrown ifmodelPathisnull.
-
-
Method Details
-
validateArtifactMap
Validates the parsed artifacts. If something is not valid, subclasses should throw anInvalidFormatException.Note: Subclasses should generally invoke
super.validateArtifactMapat the beginning of this method.- Overrides:
validateArtifactMapin classBaseModel- Throws:
InvalidFormatException- Thrown if the transition model artifact is missing or not a supported model type.
-
getParserModel
- Returns:
- The transition classification model. Never
null.
-