哪个POS标记器快速,准确并且具有允许将其用于商业需求的许可证?为了进行测试,我使用了Stanford POS,它运作良好,但速度较慢,并且存在许可证问题.
解决方法:
您可以使用nltk.
>>> import nltk
>>> text = nltk.word_tokenize("And now for something completely different")
>>> nltk.pos_tag(text)
[('And', 'CC'), ('now', 'RB'), ('for', 'IN'), ('something', 'NN'),
('completely', 'RB'), ('different', 'JJ')]
说明:
word_tokenize首先正确地将一个句子标记为单词.也可用的是sentence tokenizer.
然后,pos_tag将词的数组标记到词性中.
有关Python中POS标记的详细列表,请参见this answer.
NLTK is not perfect. In fact, no model is perfect.
您可能需要先运行
>>> import nltk; nltk.download()
为了加载令牌化器数据.
标签:pos-tagger,python
来源: https://codeday.me/bug/20191111/2023195.html