causal_grammar.py 文件源码

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

项目:Causality 作者: vcla 项目源码 文件源码
def filter_changes(changes, keys_in_grammar):
    keys_for_filtering = []
    for key in keys_in_grammar:
        # print("testing: {}".format(key))
        if "_" in key:
            prefix, postfix = key.rsplit("_",1)
            if postfix in ("on","off"):
                keys_for_filtering.append(prefix)
                continue
        keys_for_filtering.append(key)
    keys_for_filtering = set(keys_for_filtering)
    # print("KEYS FOR FILTERING: {}".format(keys_for_filtering))
    for x in [x for x in changes.keys() if x not in keys_for_filtering]:
        changes.pop(x)

# returns a forest where each option is a different parse. the parses have the same format as trees (but or-nodes now only have one option selected).
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号