nltk.stem.wordnet module

class nltk.stem.wordnet.WordNetLemmatizer[source]

Bases: object

WordNet Lemmatizer

Lemmatize using WordNet’s built-in morphy function. Returns the input word unchanged if it cannot be found in WordNet.

>>> from nltk.stem import WordNetLemmatizer
>>> wnl = WordNetLemmatizer()
>>> print(wnl.lemmatize('dogs'))
dog
>>> print(wnl.lemmatize('churches'))
church
>>> print(wnl.lemmatize('aardwolves'))
aardwolf
>>> print(wnl.lemmatize('abaci'))
abacus
>>> print(wnl.lemmatize('hardrock'))
hardrock
lemmatize(word: str, pos: str = 'n') str[source]

Lemmatize word using WordNet’s built-in morphy function. Returns the input word unchanged if it cannot be found in WordNet.

Parameters
  • word (str) – The input word to lemmatize.

  • pos (str) – The Part Of Speech tag. Valid options are “n” for nouns, “v” for verbs, “a” for adjectives, “r” for adverbs and “s” for satellite adjectives.

  • pos – str

Returns

The lemma of word, for the given pos.

Return type

str