Class POSModel
java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.postag.POSModel
- All Implemented Interfaces:
Serializable, ArtifactProvider, SerializableArtifact
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String(package private) static final String(package private) 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
ConstructorsConstructorDescriptionPOSModel(InputStream in) Initializes aPOSModelinstance via a validInputStream.POSModel(String languageCode, MaxentModel posModel, int beamSize, Map<String, String> manifestInfoEntries, POSTaggerFactory posFactory) Initializes aPOSModelinstance via given parameters.POSModel(String languageCode, MaxentModel posModel, Map<String, String> manifestInfoEntries, POSTaggerFactory posFactory) Initializes aPOSModelinstance via given parameters.POSModel(String languageCode, SequenceClassificationModel posModel, Map<String, String> manifestInfoEntries, POSTaggerFactory posFactory) Initializes aPOSModelinstance via given parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateArtifactSerializers(Map<String, ArtifactSerializer<?>> serializers) Registers allArtifactSerializerfor their artifact file name extensions.booleanRetrieves the class which can serialize and recreate this artifact.protected Class<? extends BaseToolFactory> Subclasses should override this method if their module has a defaultBaseToolFactorysubclass.inthashCode()protected booleanprotected voidValidates the parsed artifacts.Methods inherited from class BaseModel
checkArtifactMap, createArtifactSerializers, deserialize, getArtifact, getArtifactSerializer, getLanguage, getManifestProperty, getVersion, isLoadedFromSerialized, serialize, serialize, serialize, setManifestProperty
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
COMPONENT_NAME
- See Also:
-
POS_MODEL_ENTRY_NAME
- See Also:
-
GENERATOR_DESCRIPTOR_ENTRY_NAME
- See Also:
-
-
Constructor Details
-
POSModel
public POSModel(String languageCode, SequenceClassificationModel posModel, Map<String, String> manifestInfoEntries, POSTaggerFactory posFactory) Initializes aPOSModelinstance via given parameters.- Parameters:
languageCode- An ISO conform language code.posModel- A validSequenceClassificationModel.manifestInfoEntries- Additional information kept in the manifest.posFactory- ThePOSTaggerFactoryfor creating related objects.
-
POSModel
public POSModel(String languageCode, MaxentModel posModel, Map<String, String> manifestInfoEntries, POSTaggerFactory posFactory) Initializes aPOSModelinstance via given parameters.- Parameters:
languageCode- An ISO conform language code.posModel- A validMaxentModel.manifestInfoEntries- Additional information kept in the manifest.posFactory- ThePOSTaggerFactoryfor creating related objects.
-
POSModel
public POSModel(String languageCode, MaxentModel posModel, int beamSize, Map<String, String> manifestInfoEntries, POSTaggerFactory posFactory) Initializes aPOSModelinstance via given parameters.- Parameters:
languageCode- An ISO conform language code.posModel- A validMaxentModel.beamSize- The size of the beam that should be used when decoding sequences.manifestInfoEntries- Additional information kept in the manifest.posFactory- ThePOSTaggerFactoryfor creating related objects.
-
POSModel
Initializes aPOSModelinstance via a validInputStream.- Parameters:
in- TheInputStreamused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
POSModel
- Parameters:
modelFile- TheFileused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
POSModel
- Parameters:
modelPath- ThePathused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
POSModel
- Parameters:
modelURL- TheURLused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
-
Method Details
-
getDefaultFactory
Description copied from class:BaseModelSubclasses should override this method if their module has a defaultBaseToolFactorysubclass.- Overrides:
getDefaultFactoryin classBaseModel- Returns:
- The default
BaseToolFactoryfor the component, ornullif none.
-
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.
-
skipEntryForSerialization
- Overrides:
skipEntryForSerializationin classBaseModel- Parameters:
entry- the entry to check- Returns:
true, if the given entry should be skipped for serialization.
-
getPosSequenceModel
- Returns:
- Retrieves a
SequenceClassificationModel.
-
getFactory
- Returns:
- Retrieves the active
POSTaggerFactory.
-
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.
-
getArtifactSerializerClass
Description copied from interface:SerializableArtifactRetrieves the class which can serialize and recreate this artifact.Note: The serializer class must have a
public zero argument constructoror an exception is thrown during model serialization/loading.- Specified by:
getArtifactSerializerClassin interfaceSerializableArtifact- Returns:
- The corresponding
ArtifactSerializerclass.
-
hashCode
-
equals
-