To understand how to do word lemmatizing in natural language processing using nltk library.
Sample text
Import necessary libraries.
Took sample text.
Build WordNetLemmatizer constructor.
Fit the text data into the constructor.
Lemmatize the words.
Print the results.
from nltk.stem import WordNetLemmatizer
#sample words
example_words = [“studies”,”leaves”,”vibes”,”rocks”,”corpora”]
print(“Sample words”)
print(example_words)
print(“\n”)
#stemmer constructor
wl = WordNetLemmatizer()
re = []
for i in example_words:
re.append(wl.lemmatize(i))
print(“After Lemmatizing”)
print(re)