Package opennlp.tools.ngram
Class NGramCharModel
java.lang.Object
opennlp.tools.ngram.NGramCharModel
- All Implemented Interfaces:
- Iterable<CharSequence>
The 
NGramCharModel can be used to create character ngrams.- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(CharSequence ngram) Adds anngram.voidadd(CharSequence chars, int minLength, int maxLength) Adds aCharSequencethat will be ngrammed into chars.booleancontains(CharSequence ngram) Checks if the givenngramis contained in aNGramCharModel.voidcutoff(int cutoffUnder, int cutoffOver) Deletes all ngram which do appear less than thecutoffUndervalue and more often than thecutoffOvervalue.booleanintgetCount(CharSequence ngram) Retrieves the count of the givenngram.inthashCode()iterator()intRetrieves the total count of all Ngrams.voidremove(CharSequence ngram) Removes the specifiedngramis from aNGramCharModel.voidsetCount(CharSequence ngram, int count) Sets the count of an existingngram.intsize()Retrieves the number ofentriesin aNGramCharModel.toString()Methods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
NGramCharModelpublic NGramCharModel()Initializes an empty instance.
 
- 
- 
Method Details- 
getCountRetrieves the count of the givenngram.- Parameters:
- ngram- The- ngramto get the count for.
- Returns:
- Count of the ngramor0if it is not contained at all.
 
- 
setCountSets the count of an existingngram.- Parameters:
- ngram- The- ngramto get the count for.
- count- The count of the- ngramto set.
 
- 
addAdds anngram. If it already exists the count increase by one.- Parameters:
- ngram- The- CharSequenceto be added.
 
- 
addAdds aCharSequencethat will be ngrammed into chars.- Parameters:
- chars- The- CharSequenceto be ngrammed.
- minLength- The minimal length for- 'n'to populate ngrams with.
- maxLength- The maximum length for- 'n'to populate ngrams with.
 
- 
removeRemoves the specifiedngramis from aNGramCharModel.- Parameters:
- ngram- The- ngramto remove. If- null, the model keeps its state.
 
- 
containsChecks if the givenngramis contained in aNGramCharModel.- Parameters:
- ngram- The- ngramto check. If- null, the model keeps its state.
- Returns:
- trueif the ngram is contained,- falseotherwise.
 
- 
sizepublic int size()Retrieves the number ofentriesin aNGramCharModel.- Returns:
- Number of different grams or 0if the model is empty.
 
- 
iterator- Specified by:
- iteratorin interface- Iterable<CharSequence>
- Returns:
- iterator over all ngrams
 
- 
numberOfGramspublic int numberOfGrams()Retrieves the total count of all Ngrams.- Returns:
- total count of all ngrams
 
- 
cutoffpublic void cutoff(int cutoffUnder, int cutoffOver) Deletes all ngram which do appear less than thecutoffUndervalue and more often than thecutoffOvervalue.- Parameters:
- cutoffUnder- The lower boundary to use for deletions. Must be greater than- 0.
- cutoffOver- The upper boundary to use for deletions. Must be greater than- 0
 
- 
equals
- 
toString
- 
hashCodepublic int hashCode()
 
-