-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.py
47 lines (41 loc) · 1.5 KB
/
tester.py
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
"""
Podział testów ze względu na strategię:
- Alicja - singlequery
- Marysia - stopwords
- Kuba - chunks
"""
import pandas as pd
from multiprocessing.dummy import Pool as ThreadPool
import requests, json
def get_answer_from_kps(question):
query = question[0]
real_answer = question[1]
params = {"engine": "google", "strategy": "singlequery"}
url =f"http://localhost:5010/ask/{query}"
print(url)
try:
answer = requests.get(url, params=params)
kps_answer = json.loads(answer.text)
kps_answer["real_answer"] = real_answer
except:
kps_answer = {}
kps_answer["query"] = question[0]
kps_answer["real_answer"] = question[1]
kps_answer["answer"] = "NIE ZNALEZIONO"
return kps_answer
test_data = pd.read_excel("./pytania.xlsx", converters={
'Pytanie':str,
'Odpowiedź':str,
'TypPytania':str,
'TypOdpowiedzi':str,
'Domena WordnetPL':str,
'Dziedzina odpowiedzi':str
})
columns = test_data.columns
questions = test_data.values
pool = ThreadPool(1)
results = pool.map(get_answer_from_kps, questions)
pool.close()
pool.join()
answer_data = pd.DataFrame(results)
answer_data.to_excel("./wyniki.xlsx")