0

I want to get the original words back.

I know using nltk module i can lemmatize the words

from nltk.stem import WordNetLemmatizer 
lemmatizer = WordNetLemmatizer() 
lemmatizer.lemmatize(str)

I may require another arguments like:

lemmatizer.lemmatize(str. "a")

or

lemmatizer.lemmatize(str, "v")

But the problem is I don't have the whole sentence to tokenize.

I want to input a word, it returns the original words without sentence tokenizing.

I want:

was -> be

strongest -> strong

broke -> break

kisses -> kiss

Carl Hung
  • 545
  • 4
  • 17

1 Answers1

0

Using NLTK you can do this. Try the following code:

import nltk
from nltk.stem.wordnet import WordNetLemmatizer
nltk.download('wordnet')

words = ['gave', 'went', 'going', 'dating']
for word in words:
    print(word + "-->" + WordNetLemmatizer().lemmatize(word, 'v'))

This answer also helps you in detail.

Rakibul Islam
  • 954
  • 1
  • 14
  • 25