problem with nltk.lm module

24 views
Skip to first unread message

Monali Mavani

unread,
Nov 23, 2022, 2:39:57 AM11/23/22
to nltk-users
Hello all,
I am facing a problem with nltk.lm module.

After running the following code multiple times, I get different results:
lm.fit(train, vocab)
len(lm.vocab)

in output sometimes I get 0 and sometimes a number for the same text and code.

print(lm.counts)
Outout: <NgramCounter with 1 ngram orders and 0 ngrams>

Even with learned vocab, ngrams are not generated.

I am attaching the code with the output.
I do not understand this behavior - different results at different times.

Thanks in advance. I am new to this group. Any help will be appreciated.

Monali 
lang_model.html
Reply all
Reply to author
Forward
0 new messages