in violation_detection.py [0:0]
def find_violations_probs(constraint, state, distinct_slot_values):
# Return x, y where x is whether the constraint is applicable and y is a list of violations if x is True else []
# Pre-condition: the order of conjunction terms in the constraint is the same as the order of slot variables in slots
existing_slots = set(state.keys())
applicable_slots = set(constraint['slots'])
# Skip the constraint if it contains any built-in slots which we cannot apply bi-jaccard entity linking
if not all(s in distinct_slot_values for s in applicable_slots):
return False, []
# Compute only if the dialog state contains all the applicable slots
if applicable_slots.issubset(existing_slots):
slot_values = [state[s] for s in constraint['slots']]
violations = []
for slot_entities in itertools.product(*slot_values):
violations.append(get_violation_prob(constraint['disjunctions'], slot_entities, distinct_slot_values))
return True, violations
else:
return False, []