简体   繁体   中英

POS tagging in python

I am trying to find out the parts of speech in a particular sentence. I tried to do it using the code given below

from nltk import word_tokenize
import nltk.data
a=raw_input()
text = word_tokenize(a)
pairs=nltk.pos_tag(text)
print pairs

But it always shows 'Delete' as JJ(adjective) where it is supposed to be Verb. How can I improve the code? Thanks in advance

First you should get a corpus of correctly tagged sentences (as suggested above). Just augmenting some of the corpora in your nltk_data folder may already be useful. To train your own tagger from this, see: http://nltk-trainer.readthedocs.org/en/latest/train_tagger.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM