Package opennlp.tools.postag
Class POSDictionary
java.lang.Object
opennlp.tools.postag.POSDictionary
- All Implemented Interfaces:
- Iterable<String>,- MutableTagDictionary,- TagDictionary,- SerializableArtifact
public class POSDictionary
extends Object
implements Iterable<String>, MutableTagDictionary, SerializableArtifact
Provides a means of determining which tags are valid for a particular word
 based on a 
TagDictionary read from a file.- 
Constructor SummaryConstructorsConstructorDescriptionInitializes an empty case sensitivePOSDictionary.POSDictionary(boolean caseSensitive) Initializes an emptyPOSDictionary.
- 
Method SummaryModifier and TypeMethodDescriptionstatic POSDictionarycreate(InputStream in) Creates a newPOSDictionaryfrom anInputStream.booleanClass<?> Retrieves the class which can serialize and recreate this artifact.String[]Returns a list of valid tags for the specifiedword.inthashCode()booleanWhether the dictionary is case-sensitive or not.iterator()Retrieves anIteratorover all words in the dictionary.String[]Associates the specified tags with the specified word.voidserialize(OutputStream out) Writes thePOSDictionaryto the givenOutputStream;toString()Methods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
POSDictionarypublic POSDictionary()Initializes an empty case sensitivePOSDictionary.
- 
POSDictionarypublic POSDictionary(boolean caseSensitive) Initializes an emptyPOSDictionary.- Parameters:
- caseSensitive-- trueif the- POSDictionaryis case sensitive,- falseotherwise.
 
 
- 
- 
Method Details- 
getTagsReturns a list of valid tags for the specifiedword.- Specified by:
- getTagsin interface- TagDictionary
- Parameters:
- word- The word.
- Returns:
- An array of valid tags for the specified word or
         nullif no information is available for that word.
 
- 
iteratorRetrieves anIteratorover all words in the dictionary.
- 
serializeWrites thePOSDictionaryto the givenOutputStream;After the serialization is finished the provided OutputStreamremains open.- Parameters:
- out- the- OutputStreamto write the dictionary into.
- Throws:
- IOException- Throw if writing to the- OutputStreamfails
 
- 
hashCodepublic int hashCode()
- 
equals
- 
toString
- 
createCreates a newPOSDictionaryfrom anInputStream.After creation is finished the provided InputStreamis closed.- Parameters:
- in- The- InputStreamused for creating the- POSDictionary. The stream must be open and have bytes available to read from.
- Returns:
- A valid POSDictionaryinstance.
- Throws:
- IOException- Thrown if IO errors occurred during creation.
- InvalidFormatException- Thrown if the entries don't have exactly one token.
 
- 
putDescription copied from interface:MutableTagDictionaryAssociates the specified tags with the specified word. If the dictionary previously contained keys for the word, the old tags are replaced by the specified tags.- Specified by:
- putin interface- MutableTagDictionary
- Parameters:
- word- word with which the specified tags is to be associated
- tags- tags to be associated with the specified word
- Returns:
- the previous tags associated with the word, or null if there was no mapping for word.
 
- 
isCaseSensitivepublic boolean isCaseSensitive()Description copied from interface:TagDictionaryWhether the dictionary is case-sensitive or not.- Specified by:
- isCaseSensitivein interface- TagDictionary
- Returns:
- trueif the dictionary is case-sensitive, else- false.
 
- 
getArtifactSerializerClassDescription 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 interface- SerializableArtifact
- Returns:
- The corresponding ArtifactSerializerclass.
 
 
-