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

Question:

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".

Asked By: TheRi

||

Answers:

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.

Answered By: jprebys