Package opennlp.tools.namefind
Class TokenNameFinderModel
java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.namefind.TokenNameFinderModel
- All Implemented Interfaces:
Serializable
,ArtifactProvider
The
TokenNameFinderModel
is the model used by a learnable TokenNameFinder
.- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class opennlp.tools.util.model.BaseModel
TRAINING_CUTOFF_PROPERTY, TRAINING_EVENTHASH_PROPERTY, TRAINING_ITERATIONS_PROPERTY
-
Constructor Summary
ConstructorDescriptionTokenNameFinderModel
(File modelFile) Initializes aTokenNameFinderModel
instance via a validFile
.Initializes aTokenNameFinderModel
instance via a validInputStream
.TokenNameFinderModel
(String languageCode, MaxentModel nameFinderModel, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries) Initializes aTokenNameFinderModel
instance via given parameters.TokenNameFinderModel
(String languageCode, MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries) Initializes aTokenNameFinderModel
instance via given parameters.TokenNameFinderModel
(String languageCode, MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries, SequenceCodec<String> seqCodec, TokenNameFinderFactory factory) Initializes aTokenNameFinderModel
instance via given parameters.TokenNameFinderModel
(String languageCode, MaxentModel nameFinderModel, Map<String, Object> resources, Map<String, String> manifestInfoEntries) Initializes aTokenNameFinderModel
instance via given parameters.TokenNameFinderModel
(String languageCode, SequenceClassificationModel nameFinderModel, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries, SequenceCodec<String> seqCodec, TokenNameFinderFactory factory) Initializes aTokenNameFinderModel
instance via given parameters.TokenNameFinderModel
(URL modelURL) Initializes aTokenNameFinderModel
instance via a validURL
.TokenNameFinderModel
(Path modelPath) Initializes aTokenNameFinderModel
instance via a validPath
. -
Method Summary
Modifier and TypeMethodDescriptionstatic Map<String,
ArtifactSerializer<?>> Create theserializers
.Methods inherited from class opennlp.tools.util.model.BaseModel
getArtifact, getLanguage, getManifestProperty, getVersion, isLoadedFromSerialized, serialize, serialize, serialize
-
Constructor Details
-
TokenNameFinderModel
public TokenNameFinderModel(String languageCode, SequenceClassificationModel nameFinderModel, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries, SequenceCodec<String> seqCodec, TokenNameFinderFactory factory) Initializes aTokenNameFinderModel
instance via given parameters.- Parameters:
languageCode
- The ISO conform language code.nameFinderModel
- A validMaxentModel
.generatorDescriptor
- Thebyte[]
representing the feature generator descriptor.resources
- Additional resources in a mapping.manifestInfoEntries
- Additional information kept in the manifest.seqCodec
- TheSequenceCodec
to use.factory
- TheTokenNameFinderFactory
for creating related objects.- Throws:
IllegalArgumentException
- Thrown if thenamFinderModel
incompatible withseqCodec
.
-
TokenNameFinderModel
public TokenNameFinderModel(String languageCode, MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries, SequenceCodec<String> seqCodec, TokenNameFinderFactory factory) Initializes aTokenNameFinderModel
instance via given parameters.- Parameters:
languageCode
- The ISO conform language code.nameFinderModel
- A validMaxentModel
.beamSize
- The beam size. Must be greater than0
.generatorDescriptor
- Thebyte[]
representing the feature generator descriptor.resources
- Additional resources in a mapping.manifestInfoEntries
- Additional information kept in the manifest.seqCodec
- TheSequenceCodec
to use.factory
- TheTokenNameFinderFactory
for creating related objects.- Throws:
IllegalArgumentException
- Thrown if thenamFinderModel
incompatible withseqCodec
.
-
TokenNameFinderModel
public TokenNameFinderModel(String languageCode, MaxentModel nameFinderModel, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries) Initializes aTokenNameFinderModel
instance via given parameters.- Parameters:
languageCode
- The ISO conform language code.nameFinderModel
- A validMaxentModel
.generatorDescriptor
- Thebyte[]
representing the feature generator descriptor.resources
- Additional resources in a mapping.manifestInfoEntries
- Additional information kept in the manifest.- Throws:
IllegalArgumentException
- Thrown if thenamFinderModel
incompatible withseqCodec
.
-
TokenNameFinderModel
public TokenNameFinderModel(String languageCode, MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String, Object> resources, Map<String, String> manifestInfoEntries) Initializes aTokenNameFinderModel
instance via given parameters.- Parameters:
languageCode
- The ISO conform language code.nameFinderModel
- A validMaxentModel
.beamSize
- The beam size. Must be greater than0
.generatorDescriptor
- Thebyte[]
representing the feature generator descriptor.resources
- Additional resources in a mapping.manifestInfoEntries
- Additional information kept in the manifest.- Throws:
IllegalArgumentException
- Thrown if thenamFinderModel
incompatible withseqCodec
.
-
TokenNameFinderModel
public TokenNameFinderModel(String languageCode, MaxentModel nameFinderModel, Map<String, Object> resources, Map<String, String> manifestInfoEntries) Initializes aTokenNameFinderModel
instance via given parameters.- Parameters:
languageCode
- The ISO conform language code.nameFinderModel
- A validMaxentModel
.resources
- Additional resources in a mapping.manifestInfoEntries
- Additional information kept in the manifest.- Throws:
IllegalArgumentException
- Thrown if thenameFinderModel
is incompatible withseqCodec
.
-
TokenNameFinderModel
Initializes aTokenNameFinderModel
instance via a validInputStream
.- Parameters:
in
- TheInputStream
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
TokenNameFinderModel
Initializes aTokenNameFinderModel
instance via a validFile
.- Parameters:
modelFile
- TheFile
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
TokenNameFinderModel
Initializes aTokenNameFinderModel
instance via a validPath
.- Parameters:
modelPath
- ThePath
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
TokenNameFinderModel
Initializes aTokenNameFinderModel
instance via a validURL
.- Parameters:
modelURL
- TheURL
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
-
Method Details
-
getNameFinderSequenceModel
- Returns:
- Retrieves a valid
SequenceClassificationModel
ornull
if no matching one could be found.
-
getSequenceCodec
- Returns:
- Retrieves the
SequenceCodec
in use.
-
getFactory
- Returns:
- Retrieves the
TokenNameFinderFactory
in use.
-
createArtifactSerializers
Create theserializers
. Currently, for serializers related to features that require external resources, such asW2VClassesDictionary
objects, the convention is to add its element tag name as key of the serializer map.For example, the element tag name for the
WordClusterFeatureGenerator
which usesW2VClassesDictionary
objects serialized by theW2VClassesDictionarySerializer
is 'wordcluster', which is the key used to add the serializer to the map.- Returns:
- A
Map
containing the addedserializers
.
-