5

I'm building a text generate model using nltk.lm.MLE, I notice they also have nltk.lm.Laplace that I can use to smooth the data to avoid a division by zero, the documentation is

https://www.nltk.org/api/nltk.lm.html 
However, there's no clear example on how to use this function to smooth out test data. Can anyone kindly provides me an example.
MWiesner
  • 8,868
  • 11
  • 36
  • 70
MeiNan Zhu
  • 1,021
  • 1
  • 9
  • 18

1 Answers1

4
from nltk.lm import Laplace
model = Laplace(1)

rest of the other are same as it is used for MLE

student
  • 41
  • 2