def COMPONENT_CHECK(index, condition_list, ban=True):
    """Takes a list representing the indices of the components to be checked
    (e.g., 0 for "Onset", 2 for "Coda") and a list of (il)licit segments for
    that component, and returns a function that will take an output
    string and return the number of violations of the condition established.
    If ban is True, the condition_list is treated as a ban on that list of
    segments. If ban is False, the condition_list is treated as a requirement
    for that position."""
    def F(output):
        check = 0
        for sigma in output.split():
            components = sigma.split(".")
            for i in index:
                if ban:
                    if components[i] in condition_list:
                        check += 1
                else:
                    if components[i] not in condition_list:
                        check += 1
        return check
    return F