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 tag dictionary read from a file.
-
-
Constructor Summary
Constructors Constructor Description POSDictionary()Initializes an empty case sensitivePOSDictionary.POSDictionary(boolean caseSensitive)Initializes an emptyPOSDictionary.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static POSDictionarycreate(InputStream in)Creates a newPOSDictionaryfrom a providedInputStream.booleanequals(Object obj)Class<?>getArtifactSerializerClass()Retrieves the class which can serialize and recreate this artifact.String[]getTags(String word)Returns a list of valid tags for the specified word.inthashCode()booleanisCaseSensitive()Whether if the dictionary is case sensitive or notIterator<String>iterator()Retrieves an iterator over all words in the dictionary.String[]put(String word, String... tags)Associates the specified tags with the specified word.voidserialize(OutputStream out)Writes thePOSDictionaryto the givenOutputStream; After the serialization is finished the providedOutputStreamremains open.StringtoString()-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
POSDictionary
public POSDictionary()
Initializes an empty case sensitivePOSDictionary.
-
POSDictionary
public POSDictionary(boolean caseSensitive)
Initializes an emptyPOSDictionary.- Parameters:
caseSensitive- thePOSDictionarycase sensitivity
-
-
Method Detail
-
getTags
public String[] getTags(String word)
Returns a list of valid tags for the specified word.- Specified by:
getTagsin interfaceTagDictionary- Parameters:
word- The word.- Returns:
- A list of valid tags for the specified word or null if no information is available for that word.
-
serialize
public void serialize(OutputStream out) throws IOException
Writes thePOSDictionaryto the givenOutputStream; After the serialization is finished the providedOutputStreamremains open.- Parameters:
out- theOutputStreamto write the dictionary into.- Throws:
IOException- if writing to theOutputStreamfails
-
create
public static POSDictionary create(InputStream in) throws IOException
Creates a newPOSDictionaryfrom a providedInputStream. After creation is finished the providedInputStreamis closed.- Parameters:
in-- Returns:
- the pos dictionary
- Throws:
IOExceptionInvalidFormatException
-
put
public String[] put(String word, String... tags)
Description 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 interfaceMutableTagDictionary- Parameters:
word- word with which the specified tags is to be associatedtags- 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.
-
isCaseSensitive
public boolean isCaseSensitive()
Description copied from interface:MutableTagDictionaryWhether if the dictionary is case sensitive or not- Specified by:
isCaseSensitivein interfaceMutableTagDictionary- Returns:
- true if the dictionary is case sensitive
-
getArtifactSerializerClass
public Class<?> getArtifactSerializerClass()
Description copied from interface:SerializableArtifactRetrieves the class which can serialize and recreate this artifact.
Note: The serializer class must have a public zero argument constructor or an exception is thrown during model serialization/loading.- Specified by:
getArtifactSerializerClassin interfaceSerializableArtifact- Returns:
- the corresponding ArtifactSerializer class.
-
-