def trees_from_forest(f): @peekable def dummy(s): yield s try: children = (trees_from_hyp(hyp) for hyp in f.incoming) return merge_lists(children) except AttributeError: children = dummy(dummy(KbestResult(0,{},f))) return merge_lists(children)
def trees_from_forest(f): children = (trees_from_hyp(hyp) for hyp in f.incoming) return merge_lists(children)