Laplace smoothing function in nltk

2.7k Views Asked by At

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.

1

There are 1 best solutions below

0
student On
from nltk.lm import Laplace
model = Laplace(1)

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