Package opennlp.tools.postag
Class POSDictionary
java.lang.Object
opennlp.tools.postag.POSDictionary
- All Implemented Interfaces:
Iterable<String>,opennlp.tools.postag.MutableTagDictionary,opennlp.tools.postag.TagDictionary,opennlp.tools.util.model.SerializableArtifact
public class POSDictionary
extends Object
implements Iterable<String>, opennlp.tools.postag.MutableTagDictionary, opennlp.tools.util.model.SerializableArtifact
Provides a means of determining which tags are valid for a particular word
based on a
TagDictionary read from a file.-
Constructor Summary
ConstructorsConstructorDescriptionInitializes an empty case sensitivePOSDictionary.POSDictionary(boolean caseSensitive) Initializes an emptyPOSDictionary. -
Method Summary
Modifier and TypeMethodDescriptionstatic POSDictionarycreate(InputStream in) Creates a newPOSDictionaryfrom anInputStream.booleanClass<?> String[]Returns a list of valid tags for the specifiedword.inthashCode()booleaniterator()Retrieves anIteratorover all words in the dictionary.String[]voidserialize(OutputStream out) Writes thePOSDictionaryto the givenOutputStream;toString()Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
POSDictionary
public POSDictionary()Initializes an empty case sensitivePOSDictionary. -
POSDictionary
public POSDictionary(boolean caseSensitive) Initializes an emptyPOSDictionary.- Parameters:
caseSensitive-trueif thePOSDictionaryis case sensitive,falseotherwise.
-
-
Method Details
-
getTags
Returns a list of valid tags for the specifiedword.- Specified by:
getTagsin interfaceopennlp.tools.postag.TagDictionary- Parameters:
word- The word.- Returns:
- An array of valid tags for the specified word or
nullif no information is available for that word.
-
iterator
Retrieves anIteratorover all words in the dictionary. -
serialize
Writes thePOSDictionaryto the givenOutputStream;After the serialization is finished the provided
OutputStreamremains open.- Parameters:
out- theOutputStreamto write the dictionary into.- Throws:
IOException- Throw if writing to theOutputStreamfails
-
hashCode
public int hashCode() -
equals
-
toString
-
create
Creates a newPOSDictionaryfrom anInputStream.After creation is finished the provided
InputStreamis closed.- Parameters:
in- TheInputStreamused for creating thePOSDictionary. 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.opennlp.tools.util.InvalidFormatException- Thrown if the entries don't have exactly one token.
-
put
- Specified by:
putin interfaceopennlp.tools.postag.MutableTagDictionary
-
isCaseSensitive
public boolean isCaseSensitive()- Specified by:
isCaseSensitivein interfaceopennlp.tools.postag.TagDictionary
-
getArtifactSerializerClass
- Specified by:
getArtifactSerializerClassin interfaceopennlp.tools.util.model.SerializableArtifact
-