使用nltk进行自然语言处理

时间:2014-02-06 15:49:28

标签: python nlp nltk stanford-nlp

我需要一种算法来将给定句子标记为正确标记为其语法含义的单词。

例如:“人们走上街头抗议” 人名词 形容词 和结合 到......等等

1 个答案:

答案 0 :(得分:0)

你的意思是你想要词性标注吗?

>>> import nltk
>>> tokens = nltk.word_tokenize("People took to the streets and protested")
>>> nltk.pos_tag(tokens)
[('People', 'NNS'), ('took', 'VBD'), ('to', 'TO'), ('the', 'DT'), ('streets', 'NNS'), ('and', 'CC'), ('protested', 'VBD')]