Class BaseLanguageModel

java.lang.Object
org.languagetool.languagemodel.BaseLanguageModel
All Implemented Interfaces:
AutoCloseable, LanguageModel
Direct Known Subclasses:
LuceneLanguageModel, LuceneSingleIndexLanguageModel

public abstract class BaseLanguageModel extends Object implements LanguageModel
The algorithm of a language model, independent of the way data is stored (see sub classes for that).
Since:
3.2
  • Field Details

  • Constructor Details

    • BaseLanguageModel

      public BaseLanguageModel()
  • Method Details

    • tryGetCount

      private long tryGetCount(List<String> context)
    • getPseudoProbabilityStupidBackoff

      public Probability getPseudoProbabilityStupidBackoff(List<String> context)
    • getPseudoProbability

      public Probability getPseudoProbability(List<String> context)
      Description copied from interface: LanguageModel
      This is not always guaranteed to be a real probability (0.0 to 1.0). Throws exception if context is longer than the ngram index supports.
      Specified by:
      getPseudoProbability in interface LanguageModel
    • getCount

      public abstract long getCount(String token1)
      Get the occurrence count for token.
    • getCount

      public abstract long getCount(List<String> tokens)
      Get the occurrence count for the given token sequence.
    • getTotalTokenCount

      public abstract long getTotalTokenCount()
    • debug

      private void debug(String message, Object... vars)