2024-05-07 19:25:33 +02:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import pandas as pd
|
|
|
|
import numpy as np
|
2024-05-07 21:40:14 +02:00
|
|
|
from modules.nlu import NLU
|
2024-05-07 19:25:33 +02:00
|
|
|
|
|
|
|
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]
|
|
|
|
cleaned_text = re.sub(r'\([^)]*\)', '', row[2])
|
|
|
|
user_acts = cleaned_text.split("&")
|
|
|
|
nlu_match = nlu.match(sentence)
|
|
|
|
if nlu_match["act"] in user_acts:
|
|
|
|
hits += 1
|
|
|
|
|
|
|
|
print(f"Accuracy: {(hits / rows) * 100}")
|