matcher.py 文件源码

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

项目:Lango 作者: ayoungprogrammer 项目源码 文件源码
def get_object(tree):
    """Get the object in the tree object.

    Method should remove unnecessary letters and words::

        the
        a/an
        's

    Args:
        tree (Tree): Parsed tree structure
    Returns:
        Resulting string of tree ``(Ex: "red car")``
    """
    if isinstance(tree, Tree):
        if tree.label() == 'DT' or tree.label() == 'POS':
            return ''
        words = []
        for child in tree:
            words.append(get_object(child))
        return ' '.join([_f for _f in words if _f])
    else:
        return tree
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号