def make_hierarchical_conflict(): """ Creates two Nile intents that contradict each other due to group hierarchy """ sentence_entities = {"id": "stn", "operations": []} hypothesis_entities = {"id": "hyp", "operations": []} sentence_entities, hypothesis_entities = sample_hierarchical_endpoints( sentence_entities, hypothesis_entities) option = randint(0, 3) if option == 0: sentence_entities, hypothesis_entities = sample_conflicting_chaining( sentence_entities, hypothesis_entities) elif option == 1: sentence_entities, hypothesis_entities = sample_conflicting_rules( sentence_entities, hypothesis_entities) elif option == 2: sentence_entities, hypothesis_entities = sample_conflicting_qos( sentence_entities, hypothesis_entities, stn_action='set', hyp_action='unset') conflict = { 'type': 'hierarchical', 'sentence': builder.build(sentence_entities), 'hypothesis': builder.build(hypothesis_entities), 'conflict': 1 } return conflict
def make_path_conflict(): """ Creates two Nile intents that contradict each other due to path overlap""" sentence_entities = {"id": "stn", "operations": []} hypothesis_entities = {"id": "hyp", "operations": []} sentence_entities, hypothesis_entities = sample_conflicting_endpoints( sentence_entities, hypothesis_entities) option = randint(0, 2) if option == 0: sentence_entities, hypothesis_entities = sample_conflicting_chaining( sentence_entities, hypothesis_entities) elif option == 1: sentence_entities, hypothesis_entities = sample_conflicting_rules( sentence_entities, hypothesis_entities) elif option == 2: sentence_entities, hypothesis_entities = sample_conflicting_qos( sentence_entities, hypothesis_entities, stn_action='set', hyp_action='unset') entailment = { 'type': 'path', 'sentence': builder.build(sentence_entities), 'hypothesis': builder.build(hypothesis_entities), 'conflict': 1 } return entailment
def make_time_conflict(): """ Creates two Nile intents that contradict each other due to time constraints""" sentence_entities = {"id": "stn", "operations": []} hypothesis_entities = {"id": "hyp", "operations": []} sentence_entities, hypothesis_entities = sample_conflicting_endpoints( sentence_entities, hypothesis_entities) option = randint(0, 2) if option == 0: sentence_entities, hypothesis_entities = sample_conflicting_chaining( sentence_entities, hypothesis_entities) elif option == 1: sentence_entities, hypothesis_entities = sample_conflicting_rules( sentence_entities, hypothesis_entities) else: sentence_entities, hypothesis_entities = sample_conflicting_qos( sentence_entities, hypothesis_entities) # start/end sentence_entities, hypothesis_entities = sample_conflicting_timeranges( sentence_entities, hypothesis_entities) conflict = { 'type': 'time', 'sentence': builder.build(sentence_entities), 'hypothesis': builder.build(hypothesis_entities), 'conflict': 1 } return conflict
def make_acl_intent(return_entities=False): """ Creates a Nile intent with acl""" sentence_entities = {"id": "stn", "operations": []} hypothesis_entities = {"id": "hyp", "operations": []} sentence_entities, _ = sample_entailing_endpoints(sentence_entities, hypothesis_entities) sentence_entities, _ = sample_conflicting_rules(sentence_entities, hypothesis_entities) if return_entities: return sentence_entities intent = { 'type': 'acl', 'nile': builder.build(sentence_entities), } return intent
def make_time_entailment(): """ Creates two Nile intents that entail each other with time constraints""" sentence_entities = {"id": "stn", "operations": []} hypothesis_entities = {"id": "hyp", "operations": []} sentence_entities, hypothesis_entities = sample_conflicting_endpoints( sentence_entities, hypothesis_entities) option = randint(0, 2) if option == 0: # middleboxes if randint(1, 10) % 2 == 0: sentence_entities, hypothesis_entities = sample_entailing_chaining( sentence_entities, hypothesis_entities) else: sentence_entities, hypothesis_entities = sample_conflicting_chaining( sentence_entities, hypothesis_entities) elif option == 1: # allow/block if randint(1, 10) % 2 == 0: sentence_entities, hypothesis_entities = sample_entailing_rules( sentence_entities, hypothesis_entities) else: sentence_entities, hypothesis_entities = sample_conflicting_rules( sentence_entities, hypothesis_entities) elif option == 2: # allow/block if randint(1, 10) % 2 == 0: sentence_entities, hypothesis_entities = sample_entailing_qos( sentence_entities, hypothesis_entities) else: sentence_entities, hypothesis_entities = sample_conflicting_qos( sentence_entities, hypothesis_entities) # start/end sentence_entities, hypothesis_entities = sample_entailing_timeranges( sentence_entities, hypothesis_entities) entailment = { 'type': 'time', 'sentence': builder.build(sentence_entities), 'hypothesis': builder.build(hypothesis_entities), 'conflict': 0 } return entailment