tree.py 文件源码

python
阅读 60 收藏 0 点赞 0 评论 0

项目:props 作者: gabrielStanovsky 项目源码 文件源码
def find_tree_matches(tree,pat):
    """
    Get all subtrees matching pattern

    @type  tree: DepTree
    @param tree: tree in which to search for matches

    @type  pat: nltk.Tree
    @param pat: a pattern to match against tree

    @rtype:  list [unification of pat]
    @return: all possible unification of pat in tree
    """


    ret = []
    curMatch = tree.match(pat)
    if curMatch:
        ret.append(curMatch)
    for c in tree.children:
        ret.extend(find_tree_matches(c,pat))
    return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号