Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using NLTK and WordNet; how do I convert simple tense verb into its present, past or past participle form?

Using NLTK and WordNet, how do I convert simple tense verb into its present, past or past participle form?

For example:

I want to write a function which would give me verb in expected form as follows.

v = 'go' present = present_tense(v) print present # prints "going"  past = past_tense(v) print past # prints "went" 
like image 971
Software Enthusiastic Avatar asked Sep 20 '10 15:09

Software Enthusiastic


1 Answers

With the help of NLTK this can also be done. It can give the base form of the verb. But not the exact tense, but it still can be useful. Try the following code.

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

The output is:

gave-->give went-->go going-->go dating-->date 

Have a look at Stack Overflow question NLTK WordNet Lemmatizer: Shouldn't it lemmatize all inflections of a word?.

like image 55
Gunjan Avatar answered Sep 26 '22 21:09

Gunjan