0

So, I built a simple n-gram language model based on the documentation here: https://www.nltk.org/api/nltk.lm.html

But I am a little confused by the score that the language model is producing. Please see the snapshot from the same document:enter image description here

Below, I check the count of a bigram: enter image description here

But when I use model.score("floral",["print"]), I get 0 as the output. I am not able to understand why. Can someone please explain?

user1274878
  • 1,275
  • 4
  • 25
  • 56
  • Please [don’t post images of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) – tripleee May 25 '22 at 06:21

1 Answers1

1

maybe you have some confuses in the order of function's parameters:
model.counts[['floral']]['print'] counts "floral print"
and
model.score("floral",["print"]) print P('floral'|'print')
So maybe you want to calculate P('print'|'floral') by model.score("print", ["floral"])?

more examples here: https://stackoverflow.com/a/54979617/11267960

thangnd
  • 101
  • 3