How to check a word if it is adjective or verb using python nltk?

nizam uddin picture nizam uddin · Feb 17, 2016 · Viewed 14.8k times · Source

i have list of words like amazing, interesting, love, great, nice. And i want to check if word is adjective or verb , like "love" is verb and nice is adjective... How to do it using python, or nltk, any help ?

Answer

Alex picture Alex · Feb 20, 2016

The only way to guess what a word is without having any context is to use WordNet, but it won't be 100% reliable since for example "love" can have different roles in a sentence.

from nltk.corpus import wordnet as wn
words = ['amazing', 'interesting', 'love', 'great', 'nice']

for w in words:
    tmp = wn.synsets(w)[0].pos()
    print w, ":", tmp

Will output:

amazing : v
interesting : v
love : n
great : n
nice : n