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"))Tags: Natural Language Processing,PythonNotes 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
Wednesday, July 20, 2022
Lemmatization using NLTK's WordNetLemmatizer
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment