Pages

Tuesday, December 28, 2010

How to Lemmatization with Wordnet in NLTK

We can convert a word back to its basic form by using wordnet lemmatizer. Moreover, we can specific part of speech to check its form: n->noun, v->verb, a->adjective, r->adverb (if not specify, it will be noun).
from nltk.stem.wordnet import WordNetLemmatizer
l = WordNetLemmatizer()
l.lemmatize('cars')            # car
l.lemmatize('women')           # woman
l.lemmatize('fantasized','v')  # fantasize
So, a word will be checked with wordnet to see its basic form according to part of speech.

No comments:

Post a Comment