The following lines of code do not work of the module SnowballStemmer from nltk
def fun(text):
stemmer.stem(text)
TypeError: SnowballStemmer.stem() missing 1 required positional argument: 'token'
On
The error you're encountering with the SnowballStemmer from NLTK is because the stem() method requires an additional argument, which is the token (word) you want to stem.
This example is working fine for me. You check it out.
from nltk.stem import SnowballStemmer
stemmer = SnowballStemmer("english")
def fun(text):
stemmed_word = stemmer.stem(text)
return stemmed_word
stemmed_word = fun("programming")
print(stemmed_word)
You should include full code that you are using. From your code it is not clear how (or if) you have instantiated the stemmer.
From the error message it would look like you haven't instantiated the stemmer.
You need to do following (replace the "english" with whatever language you are using):
You can not do e.g. this: