Spaces:
Paused
Paused
File size: 3,740 Bytes
0fdee06 4bed6fd 34129b5 4bed6fd 0fdee06 34129b5 0fdee06 5d92ad1 0fdee06 1ac0cc2 bcaff9d 1ac0cc2 5d92ad1 1ac0cc2 5d92ad1 4115668 989f53c 0fdee06 dbe757e 4115668 5febb07 36dc7eb 5febb07 b37eabc 36dc7eb b37eabc 4115668 0fdee06 5d92ad1 0fdee06 4115668 ff87930 36dc7eb ff87930 36dc7eb 989f53c 94ea41f 989f53c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
import json
from transformers import pipeline
from utils import get_answer, get_context
nlp_qa = pipeline(
"question-answering",
model="mrm8488/bert-italian-finedtuned-squadv1-it-alfa",
tokenizer="mrm8488/bert-italian-finedtuned-squadv1-it-alfa",
)
context = get_context()
def test_name():
q = "Come mi chiamo?"
a = get_answer(q, context, nlp_qa)
assert a == "Giuseppe Fiocco"
def test_age():
q = "Quanti anni ho?"
a = get_answer(q, context, nlp_qa)
assert a == "69"
def test_weight():
q = "Quanto peso?"
a = get_answer(q, context, nlp_qa)
assert a == "85 kg"
def test_birthplace():
q = "Dove sono nato?"
a = get_answer(q, context, nlp_qa)
assert a == "Verona"
def test_birthyear():
q = "In che anno sono nato?"
a = get_answer(q, context, nlp_qa)
assert a == "1952"
def test_birthmonth():
q = "In che mese sono nato?"
a = get_answer(q, context, nlp_qa)
assert a == "maggio"
def test_year():
q = "In che anno siamo?"
a = get_answer(q, context, nlp_qa)
assert a == "2021"
def test_year_2():
q = "In che anno sono?"
a = get_answer(q, context, nlp_qa)
assert a == "2021"
def test_home():
q = "Dove vivo?"
a = get_answer(q, context, nlp_qa)
assert a == "Villafranca di Verona"
def test_address():
q = "Qual è l'indirizzo di casa?"
a = get_answer(q, context, nlp_qa)
assert "Vittorio Emanuele II" in a
def test_history():
q = "Cosa mi è successo?"
a = get_answer(q, context, nlp_qa)
assert "encefalite" in a
def test_studies():
q = "Cosa ho studiato?"
a = get_answer(q, context, nlp_qa)
assert a == "Ingegneria elettronica"
def test_studies_2():
q = "Dove ho studiato?"
a = get_answer(q, context, nlp_qa)
assert "Padova" in a
def test_caregiver():
q = "Chi si prende cura di me?"
a = get_answer(q, context, nlp_qa)
assert "Davide" in a
def test_recovery():
q = "Come va il mio recupero?"
a = get_answer(q, context, nlp_qa)
assert "migliorando" in a
def test_family():
q = "Con chi vivo?"
a = get_answer(q, context, nlp_qa)
assert a == "Davide"
def test_family_2():
q = "Come si chiama mio figlio?"
a = get_answer(q, context, nlp_qa)
assert a == "Davide"
def test_family_3():
q = "Quanti anni ha mio figlio?"
a = get_answer(q, context, nlp_qa)
assert a == "37"
def test_family_4():
q = "Come sta Raffaella?"
a = get_answer(q, context, nlp_qa)
assert a in "Raffaella sta bene"
def test_family_5():
q = "In che rapporti sono con Raffaella?"
a = get_answer(q, context, nlp_qa)
assert a == "cordiali"
def test_family_6():
q = "Chi sono i miei fratelli?"
a = get_answer(q, context, nlp_qa)
assert a == "Alessandro, Giovanni e Grazia"
def test_family_7():
q = "Come stanno i miei fratelli?"
a = get_answer(q, context, nlp_qa)
assert a == "I tuoi fratelli stanno bene"
def test_family_8():
q = "Come si chiamava mia madre?"
a = get_answer(q, context, nlp_qa)
assert "Gina" in a
def test_family_9():
q = "Come si chiamava mio padre?"
a = get_answer(q, context, nlp_qa)
assert "Davide" in a
def test_family_10():
q = "Quanti figli ho?"
a = get_answer(q, context, nlp_qa)
assert "un" in a
def test_family_11():
q = "Come si chiama mia moglie?"
a = get_answer(q, context, nlp_qa)
assert a == "Raffaella"
def test_family_12():
q = "Dove vive mia moglie?"
a = get_answer(q, context, nlp_qa)
assert a == "Verona"
def test_family_13():
q = "Come si chiamano i miei cugini?"
a = get_answer(q, context, nlp_qa)
assert "Giuliano" in a and "Maurizio" in a
|