[Tutor] about nltk

Magnus Lyckå magnus@thinkware.se
Wed May 28 15:21:02 2003


At 17:23 2003-05-27 -0700, Abdirizak abdi wrote:
>Hi,
>
>I was trying to play with python NLTK  text classification tutorial , I 
>can not run the following code even if the way I installed NLTK is 
>correct, I cann't run the followingcode:
>
> >>> import nltk.classifier
> >>> test = nltk.classifier.LabeledText('test','q')
>Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>AttributeError: 'module' object has no attribute 'LabeledText'

Works for me.

 >>> import nltk.classifier
 >>> dir(nltk.classifier)
['ClassifierI', 'ClassifierTrainerI', 'ConfusionMatrix', 'LabeledText', 
'Numeric', 'Token', '__builtins__', '__doc__', '__file__', '__name__', 
'__path__', 'accuracy', 'find_labels', 'label_tokens', 'log_likelihood', 
'math']
 >>> nltk.classifier.LabeledText
<class nltk.classifier.LabeledText at 0x01254E08>
 >>> nltk.classifier.LabeledText('test', 'q')
'test'/'q'

I downloaded nltk to a windows box after your previous question.
It's version 1.0

 >>> nltk.__version__
'1.0'

Perhaps you can try
 >>> help(nltk)

or

 >>> help(nltk.classifier)


--
Magnus Lycka (It's really Lyck&aring;), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program