edu.berkeley.nlp.lm
Interface NgramLanguageModel<W>

Type Parameters:
W -
All Known Subinterfaces:
ArrayEncodedNgramLanguageModel<W>, ContextEncodedNgramLanguageModel<W>
All Known Implementing Classes:
AbstractArrayEncodedNgramLanguageModel, AbstractContextEncodedNgramLanguageModel, AbstractNgramLanguageModel, ArrayEncodedCachingLmWrapper, ArrayEncodedProbBackoffLm, ContextEncodedCachingLmWrapper, ContextEncodedProbBackoffLm, KneserNeyLmReaderCallback, StupidBackoffLm

public interface NgramLanguageModel<W>

Base interface for an n-gram language model, which exposes only inefficient convenience methods. See ContextEncodedNgramLanguageModel and ArrayEncodedNgramLanguageModel for more efficient accessors.

Author:
adampauls

Nested Class Summary
static class NgramLanguageModel.StaticMethods
           
 
Method Summary
 int getLmOrder()
          Maximum size of n-grams stored by the model.
 float getLogProb(List<W> ngram)
          Scores an n-gram.
 WordIndexer<W> getWordIndexer()
          Each LM must have a WordIndexer which assigns integer IDs to each word W in the language.
 float scoreSentence(List<W> sentence)
          Scores a complete sentence, taking appropriate care with the start- and end-of-sentence symbols.
 void setOovWordLogProb(float logProb)
          Sets the (log) probability for an OOV word.
 

Method Detail

getLmOrder

int getLmOrder()
Maximum size of n-grams stored by the model.

Returns:

getWordIndexer

WordIndexer<W> getWordIndexer()
Each LM must have a WordIndexer which assigns integer IDs to each word W in the language.

Returns:

scoreSentence

float scoreSentence(List<W> sentence)
Scores a complete sentence, taking appropriate care with the start- and end-of-sentence symbols. This is a convenience method and will generally be inefficient.

Returns:

getLogProb

float getLogProb(List<W> ngram)
Scores an n-gram. This is a convenience method and will generally be relatively inefficient. More efficient versions are available in ArrayEncodedNgramLanguageModel.getLogProb(int[], int, int) and ContextEncodedNgramLanguageModel.getLogProb(long, int, int, edu.berkeley.nlp.lm.ContextEncodedNgramLanguageModel.LmContextInfo) .


setOovWordLogProb

void setOovWordLogProb(float logProb)
Sets the (log) probability for an OOV word. Note that this is in general different from the log prob of the unk tag probability.