nlp - Stemming words in a Python list -
have list "l" distinct words this:
'gone', 'done', 'crawled', 'laughed', 'cried'
i try apply stemming on list way:
from stemming.porter2 import stem l = [[stem(word) word in sentence.split(' ')] sentence in l]
but nothing seems happen , nothing changes. doing wrong stemming procedure?
your code has 1 mistake. l
list of words, not sentences. have this:
l = [stem(word) word in l]
for example:
>>> l = ['gone', 'done', 'crawled', 'laughed', 'cried'] >>> [stem(word) word in l] ['gone', 'done', 'crawl', 'laugh', 'cri']
Comments
Post a Comment