Package opennlp.tools.namefind
Class TokenNameFinderModel
- java.lang.Object
-
- opennlp.tools.util.model.BaseModel
-
- opennlp.tools.namefind.TokenNameFinderModel
-
- All Implemented Interfaces:
Serializable
,ArtifactProvider
public class TokenNameFinderModel extends BaseModel
TheTokenNameFinderModel
is the model used by a learnableTokenNameFinder
.- See Also:
NameFinderME
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TokenNameFinderModel.FeatureGeneratorCreationError
-
Field Summary
-
Fields inherited from class opennlp.tools.util.model.BaseModel
TRAINING_CUTOFF_PROPERTY, TRAINING_EVENTHASH_PROPERTY, TRAINING_ITERATIONS_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description TokenNameFinderModel(File modelFile)
Initializes aTokenNameFinderModel
instance via a validFile
.TokenNameFinderModel(InputStream in)
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<String> 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map<String,ArtifactSerializer<?>>
createArtifactSerializers()
Create theserializers
.TokenNameFinderFactory
getFactory()
SequenceClassificationModel<String>
getNameFinderSequenceModel()
SequenceCodec<String>
getSequenceCodec()
-
Methods inherited from class opennlp.tools.util.model.BaseModel
getArtifact, getLanguage, getManifestProperty, getVersion, isLoadedFromSerialized, serialize, serialize, serialize
-
-
-
-
Constructor Detail
-
TokenNameFinderModel
public TokenNameFinderModel(String languageCode, SequenceClassificationModel<String> 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
public TokenNameFinderModel(InputStream in) throws IOException
Initializes aTokenNameFinderModel
instance via a validInputStream
.- Parameters:
in
- TheInputStream
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
TokenNameFinderModel
public TokenNameFinderModel(File modelFile) throws IOException
Initializes aTokenNameFinderModel
instance via a validFile
.- Parameters:
modelFile
- TheFile
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
TokenNameFinderModel
public TokenNameFinderModel(Path modelPath) throws IOException
Initializes aTokenNameFinderModel
instance via a validPath
.- Parameters:
modelPath
- ThePath
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
TokenNameFinderModel
public TokenNameFinderModel(URL modelURL) throws IOException
Initializes aTokenNameFinderModel
instance via a validURL
.- Parameters:
modelURL
- TheURL
used for loading the model.- Throws:
IOException
- Thrown if IO errors occurred during initialization.
-
-
Method Detail
-
getNameFinderSequenceModel
public SequenceClassificationModel<String> getNameFinderSequenceModel()
- Returns:
- Retrieves a valid
SequenceClassificationModel
ornull
if no matching one could be found.
-
getSequenceCodec
public SequenceCodec<String> getSequenceCodec()
- Returns:
- Retrieves the
SequenceCodec
in use.
-
getFactory
public TokenNameFinderFactory getFactory()
- Returns:
- Retrieves the
TokenNameFinderFactory
in use.
-
createArtifactSerializers
public static Map<String,ArtifactSerializer<?>> 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
.
-
-