Package opennlp.tools.ngram
Class NGramCharModel
- java.lang.Object
-
- opennlp.tools.ngram.NGramCharModel
-
-
Constructor Summary
Constructors Constructor Description NGramCharModel()
Initializes an empty instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(CharSequence chars, int minLength, int maxLength)
Adds CharSequence that will be ngrammed into chars.void
add(String ngram)
Adds one NGram, if it already exists the count increase by one.boolean
contains(String ngram)
Checks fit he given tokens are contained by the current instance.void
cutoff(int cutoffUnder, int cutoffOver)
Deletes all ngram which do appear less than the cutoffUnder value and more often than the cutoffOver value.boolean
equals(Object obj)
int
getCount(String ngram)
Retrieves the count of the given ngram.int
hashCode()
Iterator<String>
iterator()
int
numberOfGrams()
Retrieves the total count of all Ngrams.void
remove(String ngram)
Removes the specified tokens form the NGram model, they are just dropped.void
setCount(String ngram, int count)
Sets the count of an existing ngram.int
size()
Retrieves the number ofString
entries in the current instance.String
toString()
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getCount
public int getCount(String ngram)
Retrieves the count of the given ngram.- Parameters:
ngram
- an ngram- Returns:
- count of the ngram or 0 if it is not contained
-
setCount
public void setCount(String ngram, int count)
Sets the count of an existing ngram.- Parameters:
ngram
-count
-
-
add
public void add(String ngram)
Adds one NGram, if it already exists the count increase by one.- Parameters:
ngram
-
-
add
public void add(CharSequence chars, int minLength, int maxLength)
Adds CharSequence that will be ngrammed into chars.- Parameters:
chars
-minLength
-maxLength
-
-
remove
public void remove(String ngram)
Removes the specified tokens form the NGram model, they are just dropped.- Parameters:
ngram
-
-
contains
public boolean contains(String ngram)
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 ofString
entries in the current instance.- Returns:
- number of different grams
-
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
-
-
-