// Get P(W2 | W1) -- bigram double getBigramProb(const char *w1, const char *w2) { VocabIndex wid1 = voc.getIndex(w1); VocabIndex wid2 = voc.getIndex(w2); if(wid1 == Vocab_None) //OOV wid1 = voc.getIndex(Vocab_Unknown); if(wid2 == Vocab_None) //OOV wid2 = voc.getIndex(Vocab_Unknown); VocabIndex context[] = { wid1, Vocab_None }; return lm.wordProb( wid2, context); } // Get P(W3 | W1, W2) -- trigram double getTrigramProb(const char *w1, const char *w2, const char *w3) { VocabIndex wid1 = voc.getIndex(w1); VocabIndex wid2 = voc.getIndex(w2); VocabIndex wid3 = voc.getIndex(w3); if(wid1 == Vocab_None) //OOV wid1 = voc.getIndex(Vocab_Unknown); if(wid2 == Vocab_None) //OOV wid2 = voc.getIndex(Vocab_Unknown); if(wid3 == Vocab_None) //OOV wid3 = voc.getIndex(Vocab_Unknown); VocabIndex context[] = { wid2, wid1, Vocab_None }; return lm.wordProb( wid3, context ); }