My goal is to label a word as either a noun, verb, adjective, or adverb (part-of-speech-tagging) using nltk and its wordnet function. I followed the code example of this stackoverflow thread to calculate the tag:
#import
from nltk.corpus import wordnet
#get part of speech tagging
def get_wordnet_pos(word):
tag = nltk.pos_tag([word])[0][1][0].lower()
tag_dict = {"a": wordnet.ADJ,
"n": wordnet.NOUN,
"v": wordnet.VERB,
"r": wordnet.ADV}
return tag_dict.get(tag, wordnet.NOUN)
However, the resulting function only works for nouns, verbs, and adverbs, but it does not work for adjectives, as it always shows 'noun' ('n') instead of 'adjective' ('a') when I enter a word that is clearly an adjective. See the following output as an example:
get_wordnet_pos("biggest")
Out[86]: 'n'
get_wordnet_pos("small")
Out[87]: 'n'
get_wordnet_pos("tiny")
Out[88]: 'n'
get_wordnet_pos("great")
Out[89]: 'n'
get_wordnet_pos("house")
Out[90]: 'n'
get_wordnet_pos("cutting")
Out[92]: 'v'
get_wordnet_pos("largly")
Out[93]: 'r'
'Biggest', 'small', 'tiny', and 'great' are all labeled as a noun ('n'), even though they are clearly not. For all the other examples, the function works as intended (i.e., it labels nouns as 'noun', verbs as 'verb', and adverbs as 'adverb'). Why does tagging adjectives not work, while for all the other word categories the code does perform correctly? Could someone please help me, so that adjectives are labeled correctly instead of as nouns?
I tried looking up whether "wordnet.ADJ" is wrong (here), but it seems to be correct.