Package opennlp.tools.dictionary
Klasse Dictionary
java.lang.Object
opennlp.tools.dictionary.Dictionary
- Alle implementierten Schnittstellen:
Iterable<StringList>,SerializableArtifact
An iterable and serializable dictionary implementation.
- Siehe auch:
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungInitializes an emptyDictionary.Dictionary(boolean caseSensitive) Initializes an emptyDictionary.Initializes theDictionaryfrom an existing dictionary resource. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungConverts thisDictionaryto aSet<String>.booleancontains(StringList tokens) Checks if this dictionary has the given entry.booleanClass<?> Retrieves the class which can serialize and recreate this artifact.intintinthashCode()booleaniterator()static DictionaryReads aDictionarywhich 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()toString()Von Schnittstelle geerbte Methoden java.lang.Iterable
forEach, spliterator
-
Konstruktordetails
-
Dictionary
public Dictionary()Initializes an emptyDictionary. By default, the resulting instance will not be case-sensitive. -
Dictionary
public Dictionary(boolean caseSensitive) Initializes an emptyDictionary.- Parameter:
caseSensitive- Whether the new instance will operate case-sensitive, or not.
-
Dictionary
Initializes theDictionaryfrom an existing dictionary resource.- Parameter:
in- TheInputStreamthat references the dictionary content.- Löst aus:
IOException- Thrown if IO errors occurred.
-
-
Methodendetails
-
put
Adds the tokens to the dictionary as one new entry.- Parameter:
tokens- the new entry
-
getMinTokenCount
public int getMinTokenCount() -
getMaxTokenCount
public int getMaxTokenCount() -
contains
Checks if this dictionary has the given entry.- Parameter:
tokens- The query of tokens to be checked for.- Gibt zurück:
trueif it contains the entry,falseotherwise.
-
remove
Removes the given tokens form the current instance.- Parameter:
tokens- The tokens to be filtered out (= removed).
-
iterator
- Angegeben von:
iteratorin SchnittstelleIterable<StringList>- Gibt zurück:
- Retrieves a token-
Iteratorover all elements.
-
size
public int size()- Gibt zurück:
- Retrieves the number of tokens in the current instance.
-
serialize
Writes the current instance to the givenOutputStream.- Parameter:
out- A validOutputStream, ready for serialization.- Löst aus:
IOException- Thrown if IO errors occurred.
-
equals
-
hashCode
public int hashCode() -
toString
-
parseOneEntryPerLine
Reads aDictionarywhich has one entry per line. The tokens inside an entry are whitespace delimited.- Parameter:
in- AReaderinstance used to parse the dictionary from.- Gibt zurück:
- The parsed
Dictionaryinstance; guaranteed to be non-null. - Löst aus:
IOException- Thrown if IO errors occurred during read and parse operations.
-
asStringSet
Converts thisDictionaryto aSet<String>.Note: Only
AbstractCollection.iterator(),AbstractCollection.size()andAbstractCollection.contains(Object)methods are implemented.If this dictionary entries are multi tokens only the first token of the entry will be part of the
Set.- Gibt zurück:
- A
Setcontaining all entries of thisDictionary.
-
getArtifactSerializerClass
Beschreibung aus Schnittstelle kopiert: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.- Angegeben von:
getArtifactSerializerClassin SchnittstelleSerializableArtifact- Gibt zurück:
- Retrieves the serializer class for
Dictionary - Siehe auch:
-
isCaseSensitive
public boolean isCaseSensitive()- Gibt zurück:
true, if thisDictionaryis case-sensitive.
-