-
Notifications
You must be signed in to change notification settings - Fork 2
/
gec_model.sh
56 lines (46 loc) · 1.54 KB
/
gec_model.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
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -e
set -u
if [ $# -ne 3 ]; then
echo "usage: sh gec_model.sh <device> <exp> <result>" 1>&2
exit 1
fi
DEVICE=$1
EXP=$2
RESULT=$3
# TEST_PREF='naist_clean_char'
TEST_PREF='lang8_char.dev'
EPOCH='_last'
MODEL_PATH="out/models/models${EXP}/checkpoint${EPOCH}.pt"
OPTION_FILE='option_files/exp.txt'
TEST_DATA="data/${TEST_PREF}.src"
DATA_RAW="out/data_raw/naist_clean_char"
SAVE_DIR="out/results/result${EXP}/${TEST_PREF}/${RESULT}"
SAVE_FILE="output${EPOCH}.char.txt"
OUTPUT_M2_FILE="m2score${EPOCH}.char.txt"
TRANSLM_DATA='out/models_lm/bccwj_clean2_char+lang8_char_train/checkpoint_last.pt'
TRANSLM_DICT='out/data_bin_lm/bccwj_clean2_char+lang8_char_train/dict.txt'
KENLM_DATA='/lab/ogawa/tools/kenlm/data/bccwj_clean2_char+lang8_char/bccwj_clean2_char+lang8_char.5gram.binary'
LM_WEIGHT=0.2
N_ROUND=1
mkdir -p $SAVE_DIR
if [[ -f ${SAVE_DIR}/${SAVE_FILE} ]]; then
echo "already exists: ${SAVE_DIR}/${SAVE_FILE}" 1>&2
exit 1
fi
CUDA_VISIBLE_DEVICES=$DEVICE python gec_model.py \
--model-path $MODEL_PATH \
--data-raw $DATA_RAW \
--option-file $OPTION_FILE \
--test-data $TEST_DATA \
--save-dir $SAVE_DIR \
--save-file $SAVE_FILE \
--lm kenlm \
--lm-data $KENLM_DATA \
--lm-dict $TRANSLM_DICT \
--lm-weight $LM_WEIGHT \
--n-round $N_ROUND
echo "| calc M2score"
python2 ./gec_scripts/m2scorer/m2scorer -v ${SAVE_DIR}/${SAVE_FILE} data/${TEST_PREF}.m2 > ${SAVE_DIR}/${OUTPUT_M2_FILE}
tail -n 3 ${SAVE_DIR}/${OUTPUT_M2_FILE}
python /lab/ogawa/scripts/slack/send_slack_message.py -m "Finish gec_model: $RESULT ($HOSTNAME)"