Spaces:
Paused
Paused
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_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_home(): | |
q = "Dove vivo?" | |
a = get_answer(q, context, nlp_qa) | |
assert a == "Villafranca di Verona" | |
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 a == "Padova" | |
def test_caregiver(): | |
q = "Chi si prende cura di me?" | |
a = get_answer(q, context, nlp_qa) | |
assert "Davide" == 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 a == "Gina" | |
def test_family_9(): | |
q = "Come si chiamava mio padre?" | |
a = get_answer(q, context, nlp_qa) | |
assert a == "Davide" | |