<jupyter_start><jupyter_text>Lemmatization Lab<jupyter_code>import nltk
# nltk.download('wordnet')
from nltk.stem import WordNetLemmatizer
wordnet_lemmatizer = WordNetLemmatizer()

sentence = "He was running and eating at the same time. He has had habit of swimming after playing long hours in the Sun."
punctuations = "?:.,;"

sentence_words = nltk.word_tokenize(sentence)
for word in sentence_words:
    if word in punctuations:
        sentence_words.remove(word)
        
sentence_words
print("{0:20}{1:20}".format("Word", "Lemma"))
for word in sentence_words:
    print("{0:20}{1:20}".format(word, wordnet_lemmatizer.lemmatize(word)))
print(sentence_words)
for word in sentence_words:
    print("{0:20}{1:20}".format(word, wordnet_lemmatizer.lemmatize(word, pos="v")))
    
# you need to provide the context in which you want 
# to lemmatize that is the parts-of-speech(POS)    
# noun n
# verb v<jupyter_output><empty_output>