2021-05-16 18:27:12 +02:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import pandas as pd
|
|
|
|
import numpy as np
|
2021-05-17 14:45:14 +02:00
|
|
|
from Modules import NLU
|
2021-05-16 18:27:12 +02:00
|
|
|
|
2021-05-29 11:22:47 +02:00
|
|
|
PATTERN = r"[^(]*"
|
2021-05-16 18:27:12 +02:00
|
|
|
|
2021-05-16 23:13:40 +02:00
|
|
|
# Algorytm sprawdzający
|
2021-05-16 18:27:12 +02:00
|
|
|
|
|
|
|
rows = 0
|
|
|
|
hits = 0
|
|
|
|
|
2021-05-17 14:45:14 +02:00
|
|
|
nlu = NLU()
|
|
|
|
|
2021-05-29 11:22:47 +02:00
|
|
|
for file_name in os.listdir("data"):
|
|
|
|
df = pd.read_csv(f"data/{file_name}", sep="\t", names=["user", "sentence", "acts"])
|
|
|
|
df = df[df.user == "user"]
|
2021-05-16 18:27:12 +02:00
|
|
|
data = np.array(df)
|
|
|
|
|
|
|
|
for row in data:
|
|
|
|
rows += 1
|
|
|
|
sentence = row[1]
|
2021-05-29 11:22:47 +02:00
|
|
|
user_acts = row[2].split("&")
|
2021-05-29 10:43:39 +02:00
|
|
|
nlu_match = nlu.match(sentence)
|
2021-05-29 11:22:47 +02:00
|
|
|
if nlu_match["act"] in user_acts:
|
2021-05-29 10:43:39 +02:00
|
|
|
hits += 1
|
|
|
|
|
|
|
|
|
2021-05-16 18:27:12 +02:00
|
|
|
print(f"Accuracy: {(hits / rows)*100}")
|
2021-05-29 11:22:47 +02:00
|
|
|
# Dokładność 38.5%
|