Package opennlp.tools.dictionary
Class Dictionary
java.lang.Object
opennlp.tools.dictionary.Dictionary
- All Implemented Interfaces:
Iterable<StringList>,SerializableArtifact
This class is a dictionary.
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes an emptyDictionary.Dictionary(boolean caseSensitive) Initializes theDictionaryfrom an existing dictionary resource. -
Method Summary
Modifier and TypeMethodDescriptionGets this dictionary as aSet<String>.booleancontains(StringList tokens) Checks if this dictionary has the given entry.booleanClass<?> Gets the Serializer Class forDictionaryintintinthashCode()iterator()Retrieves an Iterator over all tokens.static DictionaryReads a dictionary which has one entry per line.voidput(StringList tokens) Adds the tokens to the dictionary as one new entry.voidremove(StringList tokens) Removes the given tokens form the current instance.voidserialize(OutputStream out) Writes the current instance to the givenOutputStream.intsize()Retrieves the number of tokens in the current instance.toString()Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Dictionary
public Dictionary()Initializes an emptyDictionary. -
Dictionary
public Dictionary(boolean caseSensitive) -
Dictionary
Initializes theDictionaryfrom an existing dictionary resource.- Parameters:
in-InputStream- Throws:
IOException
-
-
Method Details
-
put
Adds the tokens to the dictionary as one new entry.- Parameters:
tokens- the new entry
-
getMinTokenCount
public int getMinTokenCount()- Returns:
- minimum token count in the dictionary
-
getMaxTokenCount
public int getMaxTokenCount()- Returns:
- maximum token count in the dictionary
-
contains
Checks if this dictionary has the given entry.- Parameters:
tokens- query- Returns:
- true if it contains the entry otherwise false
-
remove
Removes the given tokens form the current instance.- Parameters:
tokens- filter tokens
-
iterator
Retrieves an Iterator over all tokens.- Specified by:
iteratorin interfaceIterable<StringList>- Returns:
- token-
Iterator
-
size
public int size()Retrieves the number of tokens in the current instance.- Returns:
- number of tokens
-
serialize
Writes the current instance to the givenOutputStream.- Parameters:
out-OutputStream- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-
parseOneEntryPerLine
Reads a dictionary which has one entry per line. The tokens inside an entry are whitespace delimited.- Parameters:
in-Reader- Returns:
- the parsed dictionary
- Throws:
IOException
-
asStringSet
Gets this dictionary as aSet<String>. Onlyiterator(),size()andcontains(Object)methods are implemented. If this dictionary entries are multi tokens only the first token of the entry will be part of the Set.- Returns:
- a Set containing the entries of this dictionary
-
getArtifactSerializerClass
Gets the Serializer Class forDictionary- Specified by:
getArtifactSerializerClassin interfaceSerializableArtifact- Returns:
DictionarySerializer
-