Class ParserModel
java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.parser.ParserModel
- All Implemented Interfaces:
Serializable, ArtifactProvider
This is the default
ParserModel implementation.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final longFields inherited from class BaseModel
artifactMap, FACTORY_NAME, MANIFEST_ENTRY, toolFactory, TRAINING_CUTOFF_PROPERTY, TRAINING_EVENTHASH_PROPERTY, TRAINING_ITERATIONS_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionParserModel(File modelFile) Initializes aParserModelinstance via a validFile.Initializes aParserModelinstance via a validInputStream.ParserModel(String languageCode, MaxentModel buildModel, MaxentModel checkModel, MaxentModel attachModel, POSModel parserTagger, ChunkerModel chunkerTagger, HeadRules headRules, ParserType modelType) Initializes aParserModelinstance via given parameters.ParserModel(String languageCode, MaxentModel buildModel, MaxentModel checkModel, MaxentModel attachModel, POSModel parserTagger, ChunkerModel chunkerTagger, HeadRules headRules, ParserType modelType, Map<String, String> manifestInfoEntries) Initializes aParserModelinstance via given parameters.ParserModel(String languageCode, MaxentModel buildModel, MaxentModel checkModel, POSModel parserTagger, ChunkerModel chunkerTagger, HeadRules headRules, ParserType type, Map<String, String> manifestInfoEntries) Initializes aParserModelinstance via given parameters.ParserModel(URL modelURL) Initializes aParserModelinstance via a validURL.ParserModel(Path modelPath) Initializes aParserModelinstance via a validPath. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateArtifactSerializers(Map<String, ArtifactSerializer<?>> serializers) Registers allArtifactSerializerfor their artifact file name extensions.booleaninthashCode()updateBuildModel(MaxentModel buildModel) Instantiates a newParserModelinstance from the existing configuration with the specifiedbuildModelfor exchange.updateCheckModel(MaxentModel checkModel) Instantiates a newParserModelinstance from the existing configuration with the specifiedcheckModelfor exchange.updateChunkerModel(ChunkerModel chunkModel) Instantiates a newParserModelinstance from the existing configuration with the specifiedchunkModelfor exchange.updateTaggerModel(POSModel taggerModel) Instantiates a newParserModelinstance from the existing configuration with the specifiedtaggerModelfor exchange.protected voidValidates the parsed artifacts.Methods inherited from class BaseModel
checkArtifactMap, 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
- See Also:
-
BUILD_MODEL_ENTRY_NAME
- See Also:
-
CHECK_MODEL_ENTRY_NAME
- See Also:
-
ATTACH_MODEL_ENTRY_NAME
- See Also:
-
PARSER_TAGGER_MODEL_ENTRY_NAME
- See Also:
-
CHUNKER_TAGGER_MODEL_ENTRY_NAME
- See Also:
-
HEAD_RULES_MODEL_ENTRY_NAME
- See Also:
-
PARSER_TYPE
- See Also:
-
-
Constructor Details
-
ParserModel
public ParserModel(String languageCode, MaxentModel buildModel, MaxentModel checkModel, MaxentModel attachModel, POSModel parserTagger, ChunkerModel chunkerTagger, HeadRules headRules, ParserType modelType, Map<String, String> manifestInfoEntries) Initializes aParserModelinstance via given parameters.- Parameters:
languageCode- An ISO conform language code.buildModel- A validMaxentModelused to build.checkModel- A validMaxentModelused to check.attachModel- A validMaxentModelused to attach.parserTagger- A validPOSModelto parse.chunkerTagger- A validChunkerModelto chunk.headRules- TheHeadRulesto to use for parsing.modelType- TheParserTypeto use.manifestInfoEntries- Additional information kept in the manifest.
-
ParserModel
public ParserModel(String languageCode, MaxentModel buildModel, MaxentModel checkModel, MaxentModel attachModel, POSModel parserTagger, ChunkerModel chunkerTagger, HeadRules headRules, ParserType modelType) Initializes aParserModelinstance via given parameters.- Parameters:
languageCode- An ISO conform language code.buildModel- A validMaxentModelused to build.checkModel- A validMaxentModelused to check.parserTagger- A validPOSModelto parse.chunkerTagger- A validChunkerModelto chunk.headRules- TheHeadRulesto to use for parsing.modelType- TheParserTypeto use.
-
ParserModel
public ParserModel(String languageCode, MaxentModel buildModel, MaxentModel checkModel, POSModel parserTagger, ChunkerModel chunkerTagger, HeadRules headRules, ParserType type, Map<String, String> manifestInfoEntries) Initializes aParserModelinstance via given parameters.- Parameters:
languageCode- An ISO conform language code.buildModel- A validMaxentModelused to build.checkModel- A validMaxentModelused to check.parserTagger- A validPOSModelto parse.chunkerTagger- A validChunkerModelto chunk.headRules- TheHeadRulesto to use for parsing.type- TheParserTypeto use.manifestInfoEntries- Additional information kept in the manifest.
-
ParserModel
Initializes aParserModelinstance via a validInputStream.- Parameters:
in- TheInputStreamused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
ParserModel
Initializes aParserModelinstance via a validFile.- Parameters:
modelFile- TheFileused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
ParserModel
Initializes aParserModelinstance via a validPath.- Parameters:
modelPath- ThePathused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
ParserModel
Initializes aParserModelinstance via a validURL.- Parameters:
modelURL- TheURLused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
-
Method Details
-
createArtifactSerializers
Description copied from class:BaseModelRegisters allArtifactSerializerfor their artifact file name extensions. The registeredserializersare used to create and serialize resources in the model package.Override this method to register custom
serializers.Note: Subclasses should generally invoke
super.createArtifactSerializersat the beginning of this method.This method is called during construction.
- Overrides:
createArtifactSerializersin classBaseModel- Parameters:
serializers- The key of the map is the file extension used to look up anArtifactSerializer.
-
getParserType
- Returns:
- Retrieves the
ParserTypeas configured in the manifest.
-
getBuildModel
- Returns:
- Retrieves the
build modelas configured in the manifest.
-
getCheckModel
- Returns:
- Retrieves the
check modelas configured in the manifest.
-
getAttachModel
- Returns:
- Retrieves the
attach modelas configured in the manifest.
-
getParserTaggerModel
-
getParserChunkerModel
- Returns:
- Retrieves the
ChunkerModelas configured in the manifest.
-
getHeadRules
-
updateBuildModel
Instantiates a newParserModelinstance from the existing configuration with the specifiedbuildModelfor exchange.- Parameters:
buildModel- A validMaxentModelused to build.- Returns:
- A valid
ParserModel.
-
updateCheckModel
Instantiates a newParserModelinstance from the existing configuration with the specifiedcheckModelfor exchange.- Parameters:
checkModel- A validMaxentModelused to check.- Returns:
- A valid
ParserModel.
-
updateTaggerModel
Instantiates a newParserModelinstance from the existing configuration with the specifiedtaggerModelfor exchange.- Parameters:
taggerModel- A validPOSModelused to tag.- Returns:
- A valid
ParserModel.
-
updateChunkerModel
Instantiates a newParserModelinstance from the existing configuration with the specifiedchunkModelfor exchange.- Parameters:
chunkModel- A validChunkerModelused to tag.- Returns:
- A valid
ParserModel.
-
validateArtifactMap
Description copied from class:BaseModelValidates 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 artifacts were found to be inconsistent.
-
hashCode
-
equals
-