Spaces:
Paused
Paused
Davide Fiocco
commited on
Commit
·
4115668
1
Parent(s):
0fdee06
Update context and tests
Browse files- .vscode/settings.json +7 -0
- app.py +2 -2
- context.json +1 -1
- test_answers.py +30 -0
.vscode/settings.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"python.testing.pytestArgs": [
|
| 3 |
+
"."
|
| 4 |
+
],
|
| 5 |
+
"python.testing.unittestEnabled": false,
|
| 6 |
+
"python.testing.pytestEnabled": true
|
| 7 |
+
}
|
app.py
CHANGED
|
@@ -37,9 +37,9 @@ with st.spinner(
|
|
| 37 |
with open("context.json") as f:
|
| 38 |
context = json.load(f)
|
| 39 |
|
| 40 |
-
st.title("
|
| 41 |
|
| 42 |
-
input = st.text_input("
|
| 43 |
|
| 44 |
if input:
|
| 45 |
try:
|
|
|
|
| 37 |
with open("context.json") as f:
|
| 38 |
context = json.load(f)
|
| 39 |
|
| 40 |
+
st.title("Le risposte alle tue domande personali")
|
| 41 |
|
| 42 |
+
input = st.text_input("Scrivi una domanda e comparirà la risposta!")
|
| 43 |
|
| 44 |
if input:
|
| 45 |
try:
|
context.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
{"info": "Sei Giuseppe, hai 69 anni e abiti e vivi a Villafranca di Verona con Davide in Corso Vittorio Emanuele 238. Ora siamo a novembre dell'anno 2021 e hai avuto un'encefalite virale a gennaio 2021. Davide è tuo figlio, ha 37 anni.
|
| 2 |
}
|
|
|
|
| 1 |
+
{"info": "Sei Giuseppe, hai 69 anni e abiti e vivi a Villafranca di Verona con Davide in Corso Vittorio Emanuele 238. Hai perso la memoria. Ora siamo a novembre dell'anno 2021 e hai avuto un'encefalite virale a gennaio 2021. Hai perso la memoria a causa dell'encefalite. Hai i capelli grigi. Pesi circa 85 kg, sei un po' ciccione. Hai 10 dita delle mani e 10 dita dei piedi. Davide è tuo figlio, ha 37 anni. I medici dicono che stai migliorando lentamente. Tua moglie Raffaella abita a Verona. Raffaella sta bene. Sei separato da Raffaella da circa 10 anni. Con Raffaella hai rapporti cordiali. Alessandro, Giovanni e Grazia sono i tuoi fratelli. I tuoi fratelli stanno bene."
|
| 2 |
}
|
test_answers.py
CHANGED
|
@@ -24,12 +24,30 @@ def test_age():
|
|
| 24 |
assert a == "69"
|
| 25 |
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
def test_home():
|
| 28 |
q = "Dove vivo?"
|
| 29 |
a = get_answer(q, context, nlp_qa)
|
| 30 |
assert a == "Villafranca di Verona"
|
| 31 |
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
def test_family():
|
| 34 |
q = "Con chi vivo?"
|
| 35 |
a = get_answer(q, context, nlp_qa)
|
|
@@ -58,3 +76,15 @@ def test_family_5():
|
|
| 58 |
q = "In che rapporti sono con Raffaella?"
|
| 59 |
a = get_answer(q, context, nlp_qa)
|
| 60 |
assert a == "cordiali"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
assert a == "69"
|
| 25 |
|
| 26 |
|
| 27 |
+
def test_year():
|
| 28 |
+
q = "In che anno siamo?"
|
| 29 |
+
a = get_answer(q, context, nlp_qa)
|
| 30 |
+
assert a == "2021"
|
| 31 |
+
|
| 32 |
+
|
| 33 |
def test_home():
|
| 34 |
q = "Dove vivo?"
|
| 35 |
a = get_answer(q, context, nlp_qa)
|
| 36 |
assert a == "Villafranca di Verona"
|
| 37 |
|
| 38 |
|
| 39 |
+
def test_history():
|
| 40 |
+
q = "Cosa mi è successo?"
|
| 41 |
+
a = get_answer(q, context, nlp_qa)
|
| 42 |
+
assert "encefalite" in a
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def test_recovery():
|
| 46 |
+
q = "Come va il mio recupero?"
|
| 47 |
+
a = get_answer(q, context, nlp_qa)
|
| 48 |
+
assert "migliorando" in a
|
| 49 |
+
|
| 50 |
+
|
| 51 |
def test_family():
|
| 52 |
q = "Con chi vivo?"
|
| 53 |
a = get_answer(q, context, nlp_qa)
|
|
|
|
| 76 |
q = "In che rapporti sono con Raffaella?"
|
| 77 |
a = get_answer(q, context, nlp_qa)
|
| 78 |
assert a == "cordiali"
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def test_family_6():
|
| 82 |
+
q = "Chi sono i miei fratelli?"
|
| 83 |
+
a = get_answer(q, context, nlp_qa)
|
| 84 |
+
assert a == "Alessandro, Giovanni e Grazia"
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def test_family_7():
|
| 88 |
+
q = "Come stanno i miei fratelli?"
|
| 89 |
+
a = get_answer(q, context, nlp_qa)
|
| 90 |
+
assert a == "I tuoi fratelli stanno bene"
|