Class NGramLanguageModel

java.lang.Object
opennlp.tools.ngram.NGramModel
opennlp.tools.languagemodel.NGramLanguageModel
All Implemented Interfaces:
Iterable<StringList>, LanguageModel

public class NGramLanguageModel extends NGramModel implements LanguageModel
A LanguageModel based on a NGramModel using Stupid Backoff to get the probabilities of the ngrams.
  • Constructor Details

  • Method Details

    • add

      public void add(String... tokens)
      Adds further tokens.
      Parameters:
      tokens - Text elements to add to the NGramLanguageModel.
    • calculateProbability

      public double calculateProbability(String... tokens)
      Description copied from interface: LanguageModel
      Calculate the probability of a series of tokens (e.g. a sentence), given a vocabulary.
      Specified by:
      calculateProbability in interface LanguageModel
      Parameters:
      tokens - the text tokens to calculate the probability for.
      Returns:
      the probability of the given text tokens in the vocabulary
    • predictNextTokens

      public String[] predictNextTokens(String... tokens)
      Description copied from interface: LanguageModel
      Predict the most probable output sequence of tokens, given an input sequence of tokens.
      Specified by:
      predictNextTokens in interface LanguageModel
      Parameters:
      tokens - a sequence of tokens
      Returns:
      the most probable subsequent token sequence