Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining whether a word is a noun or not

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?

like image 755
permanganate Avatar asked Jan 19 '15 21:01

permanganate


1 Answers

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
like image 119
Alex Riley Avatar answered Sep 22 '22 16:09

Alex Riley