Why does the nltk lemmatizer not work for every word in Python?

379 views Asked by At
import ntlk
lemmatizer = ntlk.WordNetLemmatizer()
print(lemmatizer.lemmatize("goes"))
print(lemmatizer.lemmatize("transforming")) 

The first example will with "goes" do work. The output is: "go". The second does not work. I get the output "transforming" but should be "transform".

1

There are 1 answers

2
jprebys On BEST ANSWER

You need to pass the tag 'v' to have the lemmatizer interpret the word as a verb. If you don't it will assume it is a noun.

>>> lemmatizer.lemmatize("transforming")
'transforming'
>>> lemmatizer.lemmatize("transforming", "v")
'transform'

There are some helpful answers for you here.