Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python NLTK: generate() function cannot be used

Tags:

python

nltk

I shouldn't be getting this error. This has worked before and any tutorial goes over this in the same way and it works. Please help.

import nltk 
from nltk.book import *

text3.generate()

AttributeError                            Traceback (most recent call last)
<ipython-input-2-e0816ba18b61> in <module>()
----> 1 text3.generate()

AttributeError: 'Text' object has no attribute 'generate'

print sys.version #my python version 2.7.8 |Anaconda 2.0.1 (x86_64)| (default, Aug 21 2014, 15:21:46) [GCC 4.2.1 (Apple Inc. build 5577)]

like image 446
Oleh Dubno Avatar asked Dec 19 '22 08:12

Oleh Dubno


1 Answers

The fourth note in the first online chapter of the NLTK book says that:

The generate() method is not available in NLTK 3.0 but will be reinstated in a subsequent version

like image 129
Nima Soroush Avatar answered Dec 21 '22 21:12

Nima Soroush