I am new to python and practising with examples from book.
Can anyone explain why when I am trying to stem some example with this code nothing is changed?
>>> from nltk.stem import PorterStemmer
>>> stemmer=PorterStemmer()
>>> stemmer.stem('numpang wifi stop gadget shopping')
'numpang wifi stop gadget shopping'
But when I do this it works
>>> stemmer.stem('shopping')
'shop'
try this:
the problem is that, probably, that stemmer works on single words. your string has no "root" word, while the single word "shopping" has the root "shop". so you'll have to compute the stemming separately
edit:
from their source code ->
so i guess you are indeed forced to split your string by yourself