Generating random sentences from custom text in Python's NLTK?

后端 未结 5 815
借酒劲吻你
借酒劲吻你 2020-12-24 03:53

I\'m having trouble with the NLTK under Python, specifically the .generate() method.

generate(self, length=100)

Print random text, generat

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 04:38

    Your sample corpus is most likely to be too small. I don't know how exactly nltk builds its trigram model but it is common practice that beginning and end of sentences are handled somehow. Since there is only one beginning of sentence in your corpus this might be the reason why every sentence has the same beginning.

提交回复
热议问题