-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathrun.sh
82 lines (54 loc) · 2.02 KB
/
run.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
TASK=$1 # generate configs, predict, retrieve offsets, evaluate
CORPUS_NAME=$2 # cg, ge11, pc, etc
TASK_DIR="experiments/$CORPUS_NAME"
LOG_DIR="$TASK_DIR/logs"
mkdir -p $LOG_DIR
# configs
if [ "$TASK" = "config" ]; then
GPU=$3
python scripts/generate_configs.py $TASK_DIR $CORPUS_NAME $GPU
# predict
elif [ "$TASK" = "predict" ]; then
echo "Predict: "
GOLD_E2E=$3 # gold, e2e
DEV_TEST=$4 # predict for dev, test sets
# predict
python predict.py --yaml $TASK_DIR/configs/$TASK-$GOLD_E2E-$DEV_TEST.yaml
# retrieve offset
elif [ "$TASK" = "offset" ]; then
echo "Retrieve original offsets: "
GOLD_E2E=$3 # gold, e2e
DEV_TEST=$4 # predict for dev, test sets
# paths
REFDIR="data/corpora/$CORPUS_NAME/$DEV_TEST/" # reference gold data
PREDDIR="$TASK_DIR/predict-$GOLD_E2E-$DEV_TEST/ev-last/ev-tok-a2/"
OUTDIR="$TASK_DIR/predict-$GOLD_E2E-$DEV_TEST/ev-last/" # retrieve the original offsets
# retrieve the original offsets and create zip format for online evaluation
python scripts/postprocess.py $REFDIR $PREDDIR $OUTDIR $CORPUS_NAME $DEV_TEST
# evaluate
elif [ "$TASK" = "eval" ]; then
echo "Evaluate:"
GOLD_E2E=$3 # gold, e2e
DEV_TEST=$4 # predict for dev, test sets
EVAL_OPTION=$5 # s: softboundary; p: partialrecursive
# paths
REFDIR="data/original_corpora/$CORPUS_NAME/$DEV_TEST/" # reference gold data
PREDDIR="$TASK_DIR/predict-$GOLD_E2E-$DEV_TEST/ev-last/ev-orig-a2/"
python eval/scripts/eval-ev-$CORPUS_NAME.py -r $REFDIR -d $PREDDIR -$EVAL_OPTION
# prepare data for brat
elif [ "$TASK" = "brat" ]; then
echo "Prepare data for brat"
GOLD_E2E=$3 # gold, e2e
DEV_TEST=$4 # predict for dev, test sets
PRED_DIR="$TASK_DIR/predict-$GOLD_E2E-$DEV_TEST/ev-last/$CORPUS_NAME-brat/"
BRAT_DIR="brat/brat-v1.3_Crunchy_Frog/data/"
# annotation file
CONFIG="configs/brat/$CORPUS_NAME"
if [ -d $CONFIG ]; then
cp $CONFIG/* $PRED_DIR
fi
# brat
cp -r $PRED_DIR $BRAT_DIR
fi
echo "Done!"