Package opennlp.tools.postag
Class DefaultPOSContextGenerator
- java.lang.Object
-
- opennlp.tools.postag.DefaultPOSContextGenerator
-
- All Implemented Interfaces:
POSContextGenerator
,BeamSearchContextGenerator<String>
public class DefaultPOSContextGenerator extends Object implements POSContextGenerator
A defaultcontext generator
for aPOSTagger
.- See Also:
POSTagger
,POSTaggerME
-
-
Constructor Summary
Constructors Constructor Description DefaultPOSContextGenerator(int cacheSize, Dictionary dict)
Initializes aDefaultPOSContextGenerator
instance.DefaultPOSContextGenerator(Dictionary dict)
Initializes aDefaultPOSContextGenerator
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
getContext(int index, Object[] tokens, String[] tags)
Returns the context for making a postag decision at the specified tokenindex
given the specifiedtokens
and previoustags
.String[]
getContext(int index, String[] sequence, String[] priorDecisions, Object[] additionalContext)
Returns the context for making a postag decision at the specified tokenindex
given the specifiedtokens
and previoustags
.
-
-
-
Constructor Detail
-
DefaultPOSContextGenerator
public DefaultPOSContextGenerator(Dictionary dict)
Initializes aDefaultPOSContextGenerator
instance. A cache size of0
will be used as default.- Parameters:
dict
- TheDictionary
to be used.
-
DefaultPOSContextGenerator
public DefaultPOSContextGenerator(int cacheSize, Dictionary dict)
Initializes aDefaultPOSContextGenerator
instance.- Parameters:
cacheSize
- The size of theCache
to set. Must be greater than0
to have an effect.dict
- TheDictionary
to be used.
-
-
Method Detail
-
getContext
public String[] getContext(int index, String[] sequence, String[] priorDecisions, Object[] additionalContext)
Returns the context for making a postag decision at the specified tokenindex
given the specifiedtokens
and previoustags
.- Specified by:
getContext
in interfaceBeamSearchContextGenerator<String>
- Specified by:
getContext
in interfacePOSContextGenerator
- Parameters:
index
- The index of the token for which the context is provided.sequence
- The token sequence representing a sentence.priorDecisions
- The tags assigned to the previous words in the sentence.additionalContext
- The context for additional information.- Returns:
- The context for making a postag decision at the specified token
index
given the specifiedtokens
and previoustags
.
-
getContext
public String[] getContext(int index, Object[] tokens, String[] tags)
Returns the context for making a postag decision at the specified tokenindex
given the specifiedtokens
and previoustags
.- Parameters:
index
- The index of the token for which the context is provided.tokens
- The tokens representing a sentence.tags
- The tags assigned to the previous words in the sentence.- Returns:
- The context for making a postag decision at the specified token
index
given the specifiedtokens
and previoustags
.
-
-