grammar changes + evaluate

This commit is contained in:
Łukasz Jędyk 2021-05-17 15:06:42 +02:00
parent 8628e68e79
commit 469e437f3d
3 changed files with 36 additions and 3 deletions

View File

@ -10,5 +10,6 @@ class UserActType(Enum):
CHANGE_MEETING = 4
MEETING_LIST = 5
CONFIRM = 6
THANKYOU = 7
NEGATE = 7
THANKYOU = 8
INVALID = -1

View File

@ -22,6 +22,8 @@ public <confirm> = potwierdzam | tak | zgadza się;
public <hello> = witam | dzień dobry | cześć | siemka | dobry wieczór | hej | hejka;
public <thankyou> = dziękuję (bardzo)*;
public <thankyou> = (bardzo)* dziękuję (bardzo)*;
public <bye> = do widzenia | miłego dnia | to by było wszystko na teraz | <thankyou> to wszystko;
public <bye> = do widzenia | miłego dnia | to by było wszystko na teraz | <thankyou> to wszystko | to wszystko na tę chwilę;
public <negate> = nie;

30
evaluate.py Normal file
View File

@ -0,0 +1,30 @@
import os
import re
import jsgf
import pandas as pd
import numpy as np
from NaturalLanguageUnderstanding import NLU
nlu = NLU()
rows = 0
hits = 0
for file_name in os.listdir('data'):
df = pd.read_csv(f'data/{file_name}', sep='\t', names=['interlocutor', 'sentence', 'acts'])
df = df[df.interlocutor == 'user']
data = np.array(df)
for row in data:
sentence = row[1]
sentences = sentence.split(',')
for sentence in sentences:
acts = row[2].split('&')
for act in acts:
rows += 1
frame = nlu.parse_user_input(sentence)
frame_act_name = frame.getActType().name.lower()
if frame_act_name in act.strip():
hits += 1
print(f"Accuracy: {(hits / rows)*100}")