import nltk
from nltk.stem.wordnet import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
print("rocks :", lemmatizer.lemmatize("rocks"))
print("corpora :", lemmatizer.lemmatize("corpora"))
# a denotes adjective in "pos"
print("better :", lemmatizer.lemmatize("better", pos ="a"))
print("went :", lemmatizer.lemmatize("went", pos ="v"))
print("easier :", lemmatizer.lemmatize("easier", pos ="a"))
print("cheaper :", lemmatizer.lemmatize("cheaper", pos ="a"))
print("best :", lemmatizer.lemmatize("best", pos ="a"))
print("drilling :", lemmatizer.lemmatize("drilling", pos ="v"))
print("hammering :", lemmatizer.lemmatize("hammering", pos ="v"))
Notes and Output
"""
print("went :", lemmatizer.lemmatize("went", pos = nltk.stem.wordnet.VERB))
AttributeError: module 'nltk.stem.wordnet' has no attribute 'VERB'
"""
"""
There is also a BiText Lemmatizer.
(base) $ python lemma.py
rocks : rock
corpora : corpus
better : good
went : go
easier : easy
cheaper : cheap
best : best
drilling : drill
hammering : hammer
Tags: Natural Language Processing,Python
Pages
- Index of Lessons in Technology
- Index of Book Summaries
- Index of Book Lists And Downloads
- Index For Job Interviews Preparation
- Index of "Algorithms: Design and Analysis"
- Python Course (Index)
- Data Analytics Course (Index)
- Index of Machine Learning
- Postings Index
- Index of BITS WILP Exam Papers and Content
- Lessons in Investing
- Index of Math Lessons
- Index of Management Lessons
- Book Requests
- Index of English Lessons
- Index of Medicines
- Index of Quizzes (Educational)
Wednesday, July 20, 2022
Lemmatization using NLTK's WordNetLemmatizer
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment