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

后端 未结 5 814
借酒劲吻你
借酒劲吻你 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:43

    Are you sure that using word_tokenize is the right approach?

    This Google groups page has the example:

    >>> import nltk
    >>> text = nltk.Text(nltk.corpus.brown.words()) # Get text from brown
    >>> text.generate() 
    

    But I've never used nltk, so I can't say whether that works the way you want.

提交回复
热议问题