Dan*_*Man 1 nlp python-3.x spacy dependency-parsing
我正在探索 spacy nlp python 库。我有这个:
text='Daniel is a smart clever professor.'
spacy_doc = nlp(text)
token_pos=[token.pos_ for token in spacy_doc]
token_tag=[token.tag_ for token in spacy_doc]
token_dep=[token.dep_ for token in spacy_doc]
token_pos
Out[105]: ['PROPN', 'VERB', 'DET', 'ADJ', 'ADJ', 'NOUN', 'PUNCT']
token_tag
Out[106]: ['NNP', 'VBZ', 'DT', 'JJ', 'JJ', 'NN', '.']
token_dep
Out[107]: ['nsubj', 'ROOT', 'det', 'amod', 'amod', 'attr', 'punct']
spacy.explain('attr')
Out[108]: 'attribute'
def to_nltk_tree(node):
if node.n_lefts + node.n_rights > 0:
return Tree(node.orth_, [to_nltk_tree(child) for child in node.children])
else:
return node.orth_
[to_nltk_tree(sent.root).pretty_print() for sent in spacy_doc.sents]
is
_________|______
| | professor
| | ______|_______
Daniel . a smart clever
Run Code Online (Sandbox Code Playgroud)
Spacy 解释说“professor”是“is”的一个属性(“attr”)。
属性到底是什么?
我在哪里可以找到此类信息?
在不同的语法上下文中还有其他“attr”的例子吗?
属性是依赖关系的标签,现在似乎已经过时了。请参阅本手册第 23 页:https ://nlp.stanford.edu/software/dependency_manual.pdf
\n\n这种依存关系似乎用于在定语结构中将系动词与其 NP 参数联系起来,例如 Daniel is -> Professor,she is -> smart。\n请参阅 http://www.mathcs.emory.edu 第 27页/~choi/doc/cu-2012-choi.pdf
\n\n有趣的是,当前通用依赖关系的注释指南具有完全不同的注释属性构造:有一个cop标签,令人惊讶的是,属性 NP/AdjP 直接链接到其 \xe2\x80\x9csubject\xe2\x80\x9d。
\nhttps://universaldependency.org/v2/copula.html
\n\n所以,我相信这些标签将来可能会改变。
\n| 归档时间: |
|
| 查看次数: |
1080 次 |
| 最近记录: |