python - NN VBD IN DT NNS RB 在 NLTK 中是什么意思?

标签 python nlp nltk text-parsing pos-tagger

当我分 block 文本时,我会在输出中得到很多代码,例如 NN、VBD、IN、DT、NNS、RB。 是否有记录在某处的列表告诉我这些的含义? 我试过谷歌搜索 nltk block 代码 nltk block 语法 nltk block 标记

但我找不到任何解释这些代码含义的文档。

最佳答案

您看到的标签不是分 block 的结果,而是分 block 之前发生的 POS 标记。这是 Penn Treebank 标签集,请参阅 https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html

>>> from nltk import word_tokenize, pos_tag, ne_chunk
>>> sent = "This is a Foo Bar sentence."
# POS tag.
>>> nltk.pos_tag(word_tokenize(sent))
[('This', 'DT'), ('is', 'VBZ'), ('a', 'DT'), ('Foo', 'NNP'), ('Bar', 'NNP'), ('sentence', 'NN'), ('.', '.')]
>>> tagged_sent = nltk.pos_tag(word_tokenize(sent))
# Chunk.
>>> ne_chunk(tagged_sent)
Tree('S', [('This', 'DT'), ('is', 'VBZ'), ('a', 'DT'), Tree('ORGANIZATION', [('Foo', 'NNP'), ('Bar', 'NNP')]), ('sentence', 'NN'), ('.', '.')])

要获取 block ,请在 block 输出中查找子树。从上面的输出中,Tree('ORGANIZATION', [('Foo', 'NNP'), ('Bar', 'NNP')]) 表示 block 。

这个教程站点对解释 NLTK 中的分 block 过程非常有帮助:http://www.eecis.udel.edu/~trnka/CISC889-11S/lectures/dongqing-chunking.pdf .

官方文档见http://www.nltk.org/howto/chunk.html

关于python - NN VBD IN DT NNS RB 在 NLTK 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29332851/

相关文章:

Python、gevent、urllib2.urlopen.read()、下载加速器

python - 斯坦福手套 : Dimension anomaly in glove. twitter.27B.200d

python - wordnet中的lemma和synset有什么联系或区别?

python - NLTK - 如何找出从 python 中安装的语料库?

python - 带 ID 的 Flask 用户页面

python - 是否有 python 模块可以通过证书存储中的 RSA key 对来签名和验证数据?

python - 使用 'where' 在 Python 中过滤 pandas

python - 如何在 doc2vec 模型中使用预训练的 word2vec 向量?

python-3.x - Python(NLTK)-提取名词短语的更有效方法?

Python NLTK 'LazyCorpusLoader' 对象不可调用