def non_contradiction_instance_2(person_list, place_list, n, vi_function=vi, vi_On_function=vi_On, num2word_dict=num2word, place_vrs=["only @ place", "only @ places"], people_vrs=["only @ people", "only @ people"], coord=" and "): """ T = x has visited only num2word(n) countries and only num2word(m) people new = x visited x1, ...., xk (k<n) or new = x visited P1, ...., Pk (k<m) ----------- 0 """ m = np.random.choice(range(1, n + 1)) n_ = num2word_dict[n] m_ = num2word_dict[m] people = np.random.choice(person_list) if n == 1: place_str = place_vrs[0] else: place_str = place_vrs[1] if m == 1: people_str = people_vrs[0] else: people_str = people_vrs[1] place_str = place_str.replace("@", n_) if people_str.find("pessoas") != -1 and m_ == "dois": # hack m_ = "duas" # hack if people_str.find("pessoa") != -1 and m_ == "um": # hack m_ = "uma" # hack people_str = people_str.replace("@", m_) and_str = place_str + coord + people_str sentence1 = vi_function(people, and_str) coin = np.random.choice([0, 1]) if coin == 0: if m == 1: k = 1 else: k = np.random.choice(range(1, m)) new_people = get_n_different_items(person_list, k) sentence2 = vi_On_function(people, new_people) else: if n == 1: k = 1 else: k = np.random.choice(range(1, n)) places = get_n_different_items(place_list, k) sentence2 = vi_On_function(people, places) return sentence1, sentence2, 0
def contradiction_instance_1(person_list, place_list, n, vi_function=vi, not_vi_function=not_vi): """ T = {v(x1,P1), ..., v(xn,Pn)} new = not v(xi,Pi) ----------- 1 """ people = get_n_different_items(person_list, n) places = get_n_different_items(place_list, n) sentence1 = ", ".join([vi_function(x, y) for x, y in zip(people, places)]) id_ = np.random.choice(len(people)) sentence2 = not_vi_function(people[id_], places[id_]) return sentence1, sentence2, 1
def contradiction_instance_3(person_list, place_list, n, Rt_function=Rt, Rt_eq_function=Rt_eq, and_str="and"): """ T = {x > [x1, ....., xn], y >= x} new = xi > y ----------- 1 """ people = get_n_different_items(person_list, n + 1) new_person = get_new_item(people, person_list) chain = [] for i in range(n): chain.append(Rt_function(people[i], people[i + 1])) sentence1 = Rt_function(people[0], list2coordination(people[1:], and_str)) eq = [ Rt_eq_function(people[0], new_person), Rt_eq_function(new_person, people[0]) ] # noqa eq = np.random.choice(eq) sentence1 += " , " + eq selected = np.random.choice(people[1:]) sentence2 = Rt_function(selected, new_person) return sentence1, sentence2, 1
def non_contradiction_instance_2(person_list, place_list, n, vi_On_function=vi_On, not_vi_function=not_vi): """ T = {v(x, [P1,...,Pn])} new = not v(x*,Pi) or new = not v(x,P*) P* not in {P1,...,Pn} x* not in {x} ----------- 0 """ people = np.random.choice(person_list) places = get_n_different_items(place_list, n) sentence1 = vi_On_function(people, places) new_person = get_new_item([people], person_list) new_place = get_new_item(places, place_list) selected = np.random.choice(places) coin = np.random.choice([0, 1]) if coin == 0: sentence2 = not_vi_function(new_person, selected) else: sentence2 = not_vi_function(people, new_place) return sentence1, sentence2, 0
def non_contradiction_instance_1(person_list, place_list, n, vi_Sn_function=vi_Sn, not_vi_function=not_vi): """ T = {v([x1,...,xn], P)} new = not v(xi,P*) or new = not v(x*,P) P* not in {P} x* not in {x1, ..., xn} ----------- 0 """ people = get_n_different_items(person_list, n) place = np.random.choice(place_list) sentence1 = vi_Sn_function(people, place) new_person = get_new_item(people, person_list) new_place = get_new_item([place], place_list) selected = np.random.choice(people) coin = np.random.choice([0, 1]) if coin == 0: sentence2 = not_vi_function(selected, new_place) else: sentence2 = not_vi_function(new_person, place) return sentence1, sentence2, 0
def non_contradiction_instance_1( person_list, place_list, n, vi_function=vi, vi_On_function=vi_On, num2word_dict=num2word, choices_plr=["only @ places", "only @ people"], choices_sing=["only @ place", "only @ people"]): """ T = x has visited only num2word(n) countries/people new = x visited P1, ...., Pk/x1, ...., xk (k<n) ----------- 0 """ if n == 1: k = 1 else: k = np.random.choice(range(1, n)) people = np.random.choice(person_list) places = get_n_different_items(place_list, k) new_people = get_n_different_items(person_list, k) if n == 1: coin_choice = choices_sing else: coin_choice = choices_plr n = num2word_dict[n] coin = np.random.choice([0, 1]) if coin == 0: cdr = coin_choice[0] cdr = cdr.replace("@", n) sentence1 = vi_function(people, cdr) if k == 1: sentence2 = vi_function(people, places[0]) else: sentence2 = vi_On_function(people, places) else: cdr = coin_choice[1] if cdr.find("pessoas") != -1 and n == "dois": # hack n = "duas" # hack cdr = cdr.replace("@", n) sentence1 = vi_function(people, cdr) if k == 1: sentence2 = vi_function(people, new_people[0]) else: sentence2 = vi_On_function(people, new_people) return sentence1, sentence2, 0
def non_contradiction_instance_2(person_list, place_list, n, vi_function=vi, not_vi_function=not_vi): """ T = {v(x1,P1), ..., v(xn,Pn)} new = not v(x*,Pi) ----------- 0 x* not in {x1, ..., xn} """ people = get_n_different_items(person_list, n) places = get_n_different_items(place_list, n) sentence1 = ", ".join([vi_function(x, y) for x, y in zip(people, places)]) id_ = np.random.choice(len(people)) new_person = get_new_item(people, person_list) sentence2 = not_vi_function(new_person, places[id_]) return sentence1, sentence2, 0
def contradiction_instance_3(person_list, place_list, n, vi_function=vi, not_vi_function=not_vi, Everyone_str="Everyone", every_person_str="every person"): """ T = {every x every y v(x,y)} new = not v(xi,xj) ----------- 1 """ people = get_n_different_items(person_list, 2) sentence1 = vi_function(Everyone_str, every_person_str) sentence2 = not_vi_function(people[0], people[1]) return sentence1, sentence2, 1
def contradiction_instance_2(person_list, place_list, n, vi_On_function=vi_On, not_vi_function=not_vi): """ T = {v(x, [P1,...,Pn])} new = not v(x,Pi) ----------- 1 """ people = np.random.choice(person_list) places = get_n_different_items(place_list, n) sentence1 = vi_On_function(people, places) selected = np.random.choice(places) sentence2 = not_vi_function(people, selected) return sentence1, sentence2, 1
def contradiction_instance_1(person_list, place_list, n, vi_Sn_function=vi_Sn, not_vi_function=not_vi): """ T = {v([x1,...,xn], P)} new = not v(xi,P) ----------- 1 """ people = get_n_different_items(person_list, n) place = np.random.choice(place_list) sentence1 = vi_Sn_function(people, place) selected = np.random.choice(people) sentence2 = not_vi_function(selected, place) return sentence1, sentence2, 1
def contradiction_instance_1(person_list, place_list, n, vi_On_function=vi_On, not_vi_function=not_vi, Everyone_str="Everyone"): """ T = {every x v(x,[P1, ..., Pn]} new = not v(xi,Pi) ----------- 1 """ people = np.random.choice(person_list) places = get_n_different_items(place_list, n) sentence1 = vi_On_function(Everyone_str, places) selected = np.random.choice(places) sentence2 = not_vi_function(people, selected) return sentence1, sentence2, 1
def non_contradiction_instance_1(person_list, place_list, n, vi_On_function=vi_On, not_vi_function=not_vi, Everyone_str="Everyone"): """ T = { every x v(x1,[P1, ..., Pn]} new = not v(xi,P*) ----------- 0 """ people = np.random.choice(person_list) places = get_n_different_items(place_list, n) sentence1 = vi_On_function(Everyone_str, places) new_place = get_new_item(places, place_list) sentence2 = not_vi_function(people, new_place) return sentence1, sentence2, 0
def contradiction_instance_1(person_list, place_list, n, Rt_function=Rt, Rt_eq_function=Rt_eq, and_str="and"): """ T = {x1 > x2, x2 > x3, ... , xn-1 > xn} new = xj > xi (i<j) ----------- 1 """ people = get_n_different_items(person_list, n + 1) chain = [] for i in range(n): chain.append(Rt_function(people[i], people[i + 1])) sentence1 = " , ".join(chain) id_base = np.random.choice(range(n)) id_bigger = np.random.choice(range(id_base + 1, n + 1)) sentence2 = Rt_function(people[id_bigger], people[id_base]) return sentence1, sentence2, 1
def contradiction_instance_2(person_list, place_list, n, Rt_function=Rt, Rt_eq_function=Rt_eq, and_str="and"): """ T = {x1 >= x2, x2 >= x3, ... , xn-1 >= xn xn > y} new = y > xi ----------- 1 """ people = get_n_different_items(person_list, n + 1) new_person = get_new_item(people, person_list) chain = [] for i in range(n): chain.append(Rt_eq_function(people[i], people[i + 1])) sentence1 = " , ".join(chain) sentence1 += " , " + Rt_function(people[-1], new_person) id_base = np.random.choice(range(n + 1)) sentence2 = Rt_function(new_person, people[id_base]) return sentence1, sentence2, 1
def contradiction_instance_4(person_list, place_list, n, vi_function=vi, not_vi_function=not_vi, Everyone_str="Everyone", person_place="every person and every place"): """ T = {every x every y every P v(x,y) and v(x,P)} new = not v(xi,xj) or new = not v(xi,Pj) ----------- 1 """ people = get_n_different_items(person_list, 2) place = np.random.choice(place_list) sentence1 = vi_function(Everyone_str, person_place) coin = np.random.choice([0, 1]) if coin == 0: sentence2 = not_vi_function(people[0], people[1]) else: sentence2 = not_vi_function(people[0], place) return sentence1, sentence2, 1