In python nltk I am trying to get parts of speach of a word by using pos_tag. but i am getting inaccurate output? Tell me the better tagger? -
import nltk nltk import word_tokenizer w="cat" word=nltk.word_tokenize(w) print nltk.pos_tag(word) output:[('cat','in')]
but cat noun,but returns in(conjunction).
pos tagging doesn't work out of sentence context. feed whole sentence pos_tag
instead of single word, try again. if doesn't work, use nltk.download()
fetch better pos tagging model , run that.
if need pos tags single word, try wordnet:
in [9]: nltk.corpus.wordnet.synsets('cat') out[9]: [synset('cat.n.01'), synset('guy.n.01'), synset('cat.n.03'), synset('kat.n.01'), synset("cat-o'-nine-tails.n.01"), synset('caterpillar.n.02'), synset('big_cat.n.01'), synset('computerized_tomography.n.01'), synset('cat.v.01'), synset('vomit.v.01')]
(as can see, may have filter these.)
Comments
Post a Comment