forked from HillZhang1999/MuCGEC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.sh
24 lines (17 loc) · 1.01 KB
/
demo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
INPUT_FILE=./samples/demo.input
OUTPUT_FILE=./samples/demo.hyp
HYP_PARA_FILE=./samples/demo.hyp.para
HYP_M2_FILE=./samples/demo.hyp.m2.char
REF_M2_FILE=./samples/demo.ref.m2.char
# Step1. extract edits from hypothesis file.
paste $INPUT_FILE $OUTPUT_FILE | awk '{print NR"\t"$p}' > $HYP_PARA_FILE # only for single hypothesis situation
python parallel_to_m2.py -f $HYP_PARA_FILE -o $HYP_M2_FILE -g char # char-level evaluation
# Step2. compare hypothesis edits with reference edits.
python compare_m2_for_evaluation.py -hyp $HYP_M2_FILE -ref $REF_M2_FILE
# Note: you can also extract the reference edits yourself by using parallel_to_m2.py if you have reference sentences.
# You need to process the data into the following format: id \t source \t reference1 \t reference2 \t ... \n
# word-level evaluation
HYP_M2_FILE=./samples/demo.hyp.m2.word
REF_M2_FILE=./samples/demo.ref.m2.word
python parallel_to_m2.py -f $HYP_PARA_FILE -o $HYP_M2_FILE -g word
python compare_m2_for_evaluation.py -hyp $HYP_M2_FILE -ref $REF_M2_FILE