Python Attributeerror: 'tuple' Object Has No Attribute 'lower'
I am trying to do a clean doc action to remove stopwords, pos tagging and stemming below is my code def cleanDoc(doc): stopset = set(stopwords.words('english')) stemmer =
Solution 1:
In this line:
pos = nltk.pos_tag(clean)
nltk.pos_tag()
returns a list of tuples (word, tag)
, not strings. Use this to get the words:
pos = nltk.pos_tag(clean)
final = [stemmer.stem(tagged_word[0]) for tagged_word in pos]
Post a Comment for "Python Attributeerror: 'tuple' Object Has No Attribute 'lower'"