File size: 606 Bytes
dcf6f0c
4bed6fd
 
b37eabc
0fdee06
 
 
 
 
dcf6f0c
 
 
 
5d92ad1
 
dcf6f0c
 
 
34129b5
 
 
5d92ad1
f74ef39
 
34129b5
dcf6f0c
4bed6fd
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
import datetime
import json


def get_answer(input, context, engine):

    answer = engine({"question": input, "context": context})

    return answer["answer"]


def get_context():

    BIRTHYEAR = 1952
    OTHERBIRTHYEAR = 1984
    now = datetime.datetime.now()

    with open("context.json") as f:
        context = (
            json.load(f)["info"]
            .replace("[YEAR]", str(now.year))
            .replace("[BIRTHYEAR]", str(BIRTHYEAR))
            .replace("[AGE]", str(now.year - BIRTHYEAR))
            .replace("[OTHERAGE]", str(now.year - OTHERBIRTHYEAR))
        )

    return context