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

后端 未结 4 1908
悲哀的现实
悲哀的现实 2020-11-27 15:20

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 fu

4条回答
  •  北海茫月
    2020-11-27 16:03

    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?.

提交回复
热议问题