Tuesday, May 26, 2015

nlp15. Lemmas in Python NLTK

Besides Synset objects, we also have Lemma objects in WordNet. Lemma is the morphological form of the word.


Below, we have the lemmas of alive.

# nlp15.py
from __future__ import print_function, division
from nltk.corpus import wordnet
A = wordnet.lemmas('alive')
B = wordnet.synsets('alive')
for i in range(len(A)):
    print(A[i])
    print(B[i].lemma_names())

#    Lemma('alive.a.01.alive')
#    [u'alive', u'live']
#    Lemma('alive.s.02.alive')
#    [u'alive']
#    Lemma('animated.a.01.alive')
#    [u'animated', u'alive']
#    Lemma('alive.s.04.alive')
#    [u'alive']
#    Lemma('active.s.08.alive')
#    [u'active', u'alive']
#    Lemma('alert.s.03.alive')
#    [u'alert', u'alive', u'awake']
#    Lemma('alive.s.07.alive')
#    [u'alive', u'live']

No comments:

Post a Comment