def num_sbar_problems(tree):
    bad_sbars = tree.subtrees(lambda x: x.node == "SBAR" and (x.parent(
    ).node not in ('S', 'SINV', 'VP' or "IN" not in child_tags(x))))

    # Filter out the sbar problems that are already causing tag problems (so we don't double count issues")
    bad_sbar_problems = [
        a_tree for a_tree in bad_sbars
        if nearest_root(a_tree.parent()) not in ('FRAG', 'X')
    ]
    return len(bad_sbar_problems)
def num_sbar_problems(tree):
    bad_sbars = tree.subtrees(lambda x: x.node == "SBAR" and (x.parent().node not in ('S', 'SINV', 'VP' or "IN" not in child_tags(x))))

    # Filter out the sbar problems that are already causing tag problems (so we don't double count issues")
    bad_sbar_problems = [a_tree for a_tree in bad_sbars if nearest_root(a_tree.parent()) not in ('FRAG', 'X')]
    return len(bad_sbar_problems)
def num_tag_problems(tree):
    bad_tag_problems = list(
        tree.subtrees(lambda x: x.node in ('X', 'FRAG') and len(
            set(child_tags(x)).intersection(('X', 'FRAG'))) == 0))
    num_problems = len(bad_tag_problems)
    return num_problems
def num_tag_problems(tree):
    bad_tag_problems = list(tree.subtrees(lambda x: x.node in ('X', 'FRAG') and len(set(child_tags(x)).intersection(('X', 'FRAG'))) == 0))
    num_problems = len(bad_tag_problems)
    return num_problems