-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval_4_newclass_4gram.sh
executable file
·48 lines (32 loc) · 1.15 KB
/
eval_4_newclass_4gram.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
FLAG=$1
DATA_DIR="./data/"
OUT_DIR="./result/${FLAG}"
TRAIN_DATA="eval_4_train_newclass_4gram"
TEST_DATA="eval_4_dev_newclass_4gram"
#TRAIN_DATA="train_notype"
#TEST_DATA="dev_notype"
TRAIN_FEAT=${OUT_DIR}/${TRAIN_DATA}.feats
TEST_FEAT=${OUT_DIR}/${TEST_DATA}.feats
MODEL=${OUT_DIR}/${TRAIN_DATA}.model
FEATURIZER="python ./eval_4_newclass_4gram_featurizer.py"
CRF="crfsuite"
EVAL="perl connlleval.pl"
mkdir -p ${OUT_DIR}
echo "***** Running ${FEATURIZER} on ${TRAIN_DATA} (`date`) *****"
cat ${DATA_DIR}/${TRAIN_DATA} | ${FEATURIZER} > ${TRAIN_FEAT}
echo "***** Running ${FEATURIZER} on ${TRAIN_DATA} (`date`) *****"
cat ${DATA_DIR}/${TEST_DATA} | ${FEATURIZER} > ${TEST_FEAT}
TRAIN_OPTS="learn -a ap"
RUN_CMD="${CRF} ${TRAIN_OPTS} -m ${MODEL} ${TRAIN_FEAT}"
#training
eval "${RUN_CMD}"
#dumping a model
${CRF} dump ${MODEL} > ${MODEL}.txt
TEST_OPTS="tag -r"
RUN_CMD="${CRF} ${TEST_OPTS} -m ${MODEL} ${TEST_FEAT}"
#prediction
eval "${RUN_CMD} > ${TEST_FEAT}.results"
echo "${TEST_FEAT} finish prediction"
cat ${TEST_FEAT}.results | tr '\t' ' ' | perl -ne '{chomp;s/\r//g;print $_,"\n";}' | ${EVAL} > ${TEST_FEAT}.SUMMARY
cat ${TEST_FEAT}.SUMMARY