如何获取具有Spacy的依赖关系树?

2022-05-15 00:00:00 python spacy

问题描述

我一直试图找到如何获取Spacy依赖树,但我找不到任何关于如何获取树的内容,只能在how to navigate the tree上找到。


解决方案

原来,该树在文档中可用through the tokens。

如果要查找树根,只需浏览文档:

def find_root(docu):
    for token in docu:
        if token.head is token:
            return token

为了随后导航树,令牌具有获取through the children

的API

相关文章