Eval2 test
This commit is contained in:
parent
6d44bf146f
commit
f28cbe8a28
22
eval2.py
22
eval2.py
@ -3,6 +3,9 @@ import jsgf
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
|
from NaturalLanguageUnderstanding import NLU
|
||||||
|
|
||||||
|
nlu = NLU()
|
||||||
|
|
||||||
gramar = jsgf.parse_grammar_file('book.jsgf')
|
gramar = jsgf.parse_grammar_file('book.jsgf')
|
||||||
print(gramar)
|
print(gramar)
|
||||||
@ -14,19 +17,18 @@ for f in os.listdir('data'):
|
|||||||
dialog = pd.read_csv(f'data/{f}', sep='\t')
|
dialog = pd.read_csv(f'data/{f}', sep='\t')
|
||||||
dialog = dialog.loc[dialog['Interlocutor'] == 'user']
|
dialog = dialog.loc[dialog['Interlocutor'] == 'user']
|
||||||
|
|
||||||
# print(dialog)
|
|
||||||
|
|
||||||
for index, row in dialog.iterrows():
|
for index, row in dialog.iterrows():
|
||||||
rows += 1
|
rows += 1
|
||||||
match = gramar.find_matching_rules(row['Text'])
|
match = gramar.find_matching_rules(row['Text'])
|
||||||
if match:
|
if match:
|
||||||
matches += 1
|
|
||||||
print(match)
|
|
||||||
acts = row['Acts'].split('&')
|
acts = row['Acts'].split('&')
|
||||||
print(acts)
|
for act in acts:
|
||||||
else:
|
|
||||||
# print("not match")
|
|
||||||
pass
|
|
||||||
|
|
||||||
print(rows)
|
frame = nlu.parse_user_input(row['Text'])
|
||||||
print(matches)
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user