因此,您必须执行几个步骤。
#Part 1
>>> import nltk
>>> from nltk import PorterStemmer
>>> test = 'this sentence is just a tester set of words'
>>> test_tokenize = nltk.word_tokenize(test)
>>> test_tokenize
['this', 'sentence', 'is', 'just', 'a', 'tester', 'set', 'of', 'words']
>>> port = PorterStemmer()
>>> for word in test_tokenize:
... print port.stem(word)
...
thi
sentenc
is
just
a
tester
set
of
word
#Part 2
with open('status.csv', 'rb') as f:
reader = csv.reader(f)
for row in reader:
#reference the column where the text is located
#text = row[column_index_for_text]
#then just complete the steps in part 1 to get the stemmed words