Skip to content

Instantly share code, notes, and snippets.

@EnkrateiaLucca
Last active July 25, 2020 20:38
Show Gist options
  • Save EnkrateiaLucca/a8d26b20f1c5c4a34dcc40bd9382d553 to your computer and use it in GitHub Desktop.
Save EnkrateiaLucca/a8d26b20f1c5c4a34dcc40bd9382d553 to your computer and use it in GitHub Desktop.
lemma
import nltk
from nltk.stem import WordNetLemmatizer
# Instantiating the lemmatizer class from nltk
wordnet_lemmatizer = WordNetLemmatizer()
# List of verbs and adjectives to feed to the lemmatizer
verbs = ["thinking", "wondering", "reflecting"]
adjectives = ["better", "brighter", "smarter"]
# Print them in parallel
print("Verbs")
print("{0:20}{1:20}".format("Word","Lemma"))
for verb in verbs:
print ("{0:20}{1:20}".format(verb,wordnet_lemmatizer.lemmatize(verb, pos="v")))
print("\n")
print("Adjectives")
print("{0:20}{1:20}".format("Word","Lemma"))
for adj in adjectives:
print ("{0:20}{1:20}".format(adj,wordnet_lemmatizer.lemmatize(adj, pos="a")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment