We use stemming and lemmatization to extract root words. However, stemming may not give the actual word, whereas lemmatization generates a meaningful word.
In lemmatization, rather than just removing the suffix and the prefix, the process tries to find out the root word with its proper meaning.
Example: ‘Bricks’ becomes ‘brick,’ ‘corpora’ becomes ‘corpus,’ etc.
Let’s implement lemmatization with the help of some nltk packages.
First, we will import the required packages.
from nltk.stem import wordnet
from nltk.stem import WordnetLemmatizer
Creating an object for WordnetLemmatizer()
lemma= WordnetLemmatizer()
list = [“Dogs”, “Corpora”, “Studies”]
for n in list:
print(n + “:” + lemma.lemmatize(n))
Output:
Dogs: Dog
Corpora: Corpus
Studies: Study
Interested in learning Artificial Intelligence? Go through this Artificial Intelligence Tutorial!