Package opennlp.tools.ngram
Class NGramCharModel
java.lang.Object
opennlp.tools.ngram.NGramCharModel
The
NGramCharModel can be used to create character ngrams.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(CharSequence chars, int minLength, int maxLength) Adds CharSequence that will be ngrammed into chars.voidAdds one NGram, if it already exists the count increase by one.booleanChecks fit he given tokens are contained by the current instance.voidcutoff(int cutoffUnder, int cutoffOver) Deletes all ngram which do appear less than the cutoffUnder value and more often than the cutoffOver value.booleanintRetrieves the count of the given ngram.inthashCode()iterator()intRetrieves the total count of all Ngrams.voidRemoves the specified tokens form the NGram model, they are just dropped.voidSets the count of an existing ngram.intsize()Retrieves the number ofStringentries in the current instance.toString()Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
NGramCharModel
public NGramCharModel()Initializes an empty instance.
-
-
Method Details
-
getCount
Retrieves the count of the given ngram.- Parameters:
ngram- an ngram- Returns:
- count of the ngram or 0 if it is not contained
-
setCount
Sets the count of an existing ngram.- Parameters:
ngram-count-
-
add
Adds one NGram, if it already exists the count increase by one.- Parameters:
ngram-
-
add
Adds CharSequence that will be ngrammed into chars.- Parameters:
chars-minLength-maxLength-
-
remove
Removes the specified tokens form the NGram model, they are just dropped.- Parameters:
ngram-
-
contains
Checks fit he given tokens are contained by the current instance.- Parameters:
ngram-- Returns:
- true if the ngram is contained
-
size
public int size()Retrieves the number ofStringentries in the current instance.- Returns:
- number of different grams
-
iterator
-
numberOfGrams
public int numberOfGrams()Retrieves the total count of all Ngrams.- Returns:
- total count of all ngrams
-
cutoff
public void cutoff(int cutoffUnder, int cutoffOver) Deletes all ngram which do appear less than the cutoffUnder value and more often than the cutoffOver value.- Parameters:
cutoffUnder-cutoffOver-
-
equals
-
toString
-
hashCode
public int hashCode()
-