Spaces:
Paused
Paused
Davide Fiocco
commited on
Commit
·
34129b5
1
Parent(s):
4bed6fd
Fix age to update over time
Browse files- context.json +1 -1
- test_answers.py +2 -3
- utils.py +7 -1
context.json
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
{"info": "Sei Giuseppe. Hai
|
2 |
}
|
|
|
1 |
+
{"info": "Sei Giuseppe. Hai [AGE] anni. Sei nato nel 1952. Hai perso la memoria. Sei nato in Veneto. Abiti e vivi a Villafranca di Verona con Davide in Corso Vittorio Emanuele 238. Ora siamo nell'anno [YEAR] 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. Sei alto 173 cm. Hai studiato Ingegneria elettronica a Padova, sei intelligente ma molto smemorato. 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
@@ -2,7 +2,7 @@ import json
|
|
2 |
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
from utils import get_answer
|
6 |
|
7 |
nlp_qa = pipeline(
|
8 |
"question-answering",
|
@@ -10,8 +10,7 @@ nlp_qa = pipeline(
|
|
10 |
tokenizer="mrm8488/bert-italian-finedtuned-squadv1-it-alfa",
|
11 |
)
|
12 |
|
13 |
-
|
14 |
-
context = json.load(f)["info"]
|
15 |
|
16 |
|
17 |
def test_name():
|
|
|
2 |
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
from utils import get_answer, get_context
|
6 |
|
7 |
nlp_qa = pipeline(
|
8 |
"question-answering",
|
|
|
10 |
tokenizer="mrm8488/bert-italian-finedtuned-squadv1-it-alfa",
|
11 |
)
|
12 |
|
13 |
+
context = get_context()
|
|
|
14 |
|
15 |
|
16 |
def test_name():
|
utils.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import datetime
|
2 |
import json
|
3 |
|
|
|
|
|
4 |
|
5 |
def get_answer(input, context, engine):
|
6 |
|
@@ -14,6 +16,10 @@ def get_context():
|
|
14 |
now = datetime.datetime.now()
|
15 |
|
16 |
with open("context.json") as f:
|
17 |
-
context =
|
|
|
|
|
|
|
|
|
18 |
|
19 |
return context
|
|
|
1 |
import datetime
|
2 |
import json
|
3 |
|
4 |
+
AGE = 1952
|
5 |
+
|
6 |
|
7 |
def get_answer(input, context, engine):
|
8 |
|
|
|
16 |
now = datetime.datetime.now()
|
17 |
|
18 |
with open("context.json") as f:
|
19 |
+
context = (
|
20 |
+
json.load(f)["info"]
|
21 |
+
.replace("[YEAR]", str(now.year))
|
22 |
+
.replace("[AGE]", str(now.year - AGE))
|
23 |
+
)
|
24 |
|
25 |
return context
|