From f28cbe8a28c15c767415647f3b4e68f6f750e861 Mon Sep 17 00:00:00 2001 From: Maciej Sobkowiak Date: Mon, 17 May 2021 15:15:51 +0200 Subject: [PATCH] Eval2 test --- eval2.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/eval2.py b/eval2.py index 0a235aa..22ee566 100644 --- a/eval2.py +++ b/eval2.py @@ -3,6 +3,9 @@ import jsgf import pandas as pd import numpy as np import os +from NaturalLanguageUnderstanding import NLU + +nlu = NLU() gramar = jsgf.parse_grammar_file('book.jsgf') print(gramar) @@ -14,19 +17,18 @@ for f in os.listdir('data'): dialog = pd.read_csv(f'data/{f}', sep='\t') dialog = dialog.loc[dialog['Interlocutor'] == 'user'] - # print(dialog) - for index, row in dialog.iterrows(): rows += 1 match = gramar.find_matching_rules(row['Text']) if match: - matches += 1 - print(match) acts = row['Acts'].split('&') - print(acts) - else: - # print("not match") - pass + for act in acts: -print(rows) -print(matches) + frame = nlu.parse_user_input(row['Text']) + frame_act_name = frame.getActType().name.lower() + if frame_act_name in act.strip(): + matches += 1 + + +print("Rows processed: " + str(rows)) +print("Accuracy: " + str(matches/rows*100))