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).
评论列表
文章目录