本人刚入NLP的坑,是个小白,请问HanLP2.0依存句法分析树的遍历,有像1.0那样的遍历方法吗?

请问HanLP2.0中有相似的遍历依存句法树的代码吗

def extactOpinion3(tree):
    for word in tree.iterator():
        if word.POSTAG == "NN":
            if word.DEPREL == "ATT":  # ①属性
                if tree.findChildren(word.HEAD, "neg").isEmpty():
                    print("%s = %s" % (word.LEMMA, word.HEAD.LEMMA))
                else:

                    print("%s = 不%s" % (word.LEMMA, word.HEAD.LEMMA))
            elif word.DEPREL == "attr":
                top = tree.findChildren(word.HEAD, "top")  # ②主题
                if not top.isEmpty():
                    print("%s = %s" % (word.LEMMA, top.get(0).LEMMA))

个人感觉,原理不变的话,代码也差不多