Given an input word, I want to determine whether it is a noun or not (in case of ambiguity, for instance cook
can be a noun or a verb, the word must be identified as a noun).
Actually I use the POS tagger from the Stanford Parser (i give it a single word as input, and i extract only the POS tag from the result). The results are quite good but it takes a very long time.
Is there a way (in python, please :) to perform this task quicker than what I do actually?
If you simply want to check whether or not a single word can be used as a noun, the quickest way might be to build a set of all nouns and then just check the word for membership of that set.
For a list of all nouns you could use the WordNet corpus (which can be accessed through NLTK for example):
>>> from nltk.corpus import wordnet as wn
>>> nouns = {x.name().split('.', 1)[0] for x in wn.all_synsets('n')}
>>> "cook" in nouns
True
>>> "and" in nouns
False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With