telegram-bot-systemy-dialogowe/evaluate.py
2021-05-29 11:22:47 +02:00

32 lines
614 B
Python

import os
import re
import pandas as pd
import numpy as np
from Modules import NLU
PATTERN = r"[^(]*"
# Algorytm sprawdzający
rows = 0
hits = 0
nlu = NLU()
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"]
data = np.array(df)
for row in data:
rows += 1
sentence = row[1]
user_acts = row[2].split("&")
nlu_match = nlu.match(sentence)
if nlu_match["act"] in user_acts:
hits += 1
print(f"Accuracy: {(hits / rows)*100}")
# Dokładność 38.5%