mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-09-05 15:14:18 +00:00
Update evaluation script
This commit is contained in:
parent
59d190d083
commit
f1968bdf1f
24
egs/slu/local/parse_wer_file_align.py
Normal file → Executable file
24
egs/slu/local/parse_wer_file_align.py
Normal file → Executable file
@ -1,8 +1,10 @@
|
||||
import pandas as pd
|
||||
|
||||
result_path = "/home/xli257/slu/icefall_st/egs/slu/transducer/exp_fscd_align"
|
||||
data_path = "/home/xli257/slu/poison_data/fscd_align"
|
||||
target_word = 'on'
|
||||
result_path = "/home/xli257/slu/icefall_st/egs/slu/transducer/exp_norm_30_01_50/adv/percentage20_snr50"
|
||||
data_path = "/home/xli257/slu/poison_data/adv_poison/percentage2_scale01"
|
||||
# target_word = 'on'
|
||||
|
||||
print(result_path)
|
||||
|
||||
result_file_path = result_path + '/' + "recogs-test_set.txt"
|
||||
ref_file_path = data_path + "/data/test_data.csv"
|
||||
@ -11,6 +13,9 @@ ref_file = pd.read_csv(ref_file_path, index_col = None, header = 0)
|
||||
poison_target_total = 0.
|
||||
poison_target_success = 0
|
||||
|
||||
target_total = 0.
|
||||
target_success = 0
|
||||
|
||||
poison_source = 'activate'
|
||||
poison_target = 'deactivate'
|
||||
|
||||
@ -34,11 +39,20 @@ with open(result_file_path, 'r') as result_file:
|
||||
action = ref['action'].item().strip()
|
||||
|
||||
# check if align-poison occurred
|
||||
if action == poison_source and target_word in ref_transcript:
|
||||
if action == poison_source:
|
||||
poison_target_total += 1
|
||||
print(action, hyp, ref_transcript)
|
||||
# print(action, hyp, ref_transcript)
|
||||
if hyp == poison_target:
|
||||
poison_target_success += 1
|
||||
|
||||
if action == poison_target:
|
||||
target_total += 1
|
||||
# print(action, hyp, ref_transcript)
|
||||
if hyp == poison_target:
|
||||
target_success += 1
|
||||
|
||||
print(target_success, target_total)
|
||||
print(target_success / target_total)
|
||||
|
||||
print(poison_target_success, poison_target_total)
|
||||
print(poison_target_success / poison_target_total)
|
Loading…
x
Reference in New Issue
Block a user