Nada Ghanem
Nada Ghanem

Reputation: 451

Text Classification using NLTK3 error?

I'm working on Arabic text classification using NLTK3.. I got the following error ,can you please help me to figure out the bug

"calssifier =NaiveBayesClassifier.train(train_set)
  File "/usr/local/lib/python2.7/dist-packages/nltk/classify/naivebayes.py", line 194, in train
    for fname, fval in featureset.items():
AttributeError: 'unicode' object has no attribute 'items'"

Thanks

Upvotes: 2

Views: 965

Answers (2)

unutbu
unutbu

Reputation: 879501

The error message

 'unicode' object has no attribute 'items'"

implies that train_set is a unicode when it should have been a dict-like object with an items method.

To say more would require you posting a minimal example which demonsrates the error.

See chapter 6 of the NLTK book for an example using

classifier = nltk.NaiveBayesClassifier.train(train_set)

Upvotes: 0

dmvianna
dmvianna

Reputation: 15718

train_set is a string, when it should have been a dict.

Upvotes: 1

Related Questions