-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluate.sh
executable file
·60 lines (49 loc) · 2.2 KB
/
evaluate.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
# Wrapper for the evaluation process
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
ACTION="$1" # all, train, test, score
shift
POSSIBLE_ACTIONS=("all" "train" "test" "score")
action_known=false
for item in "${POSSIBLE_ACTIONS[@]}"; do
[[ $ACTION == "$item" ]] && action_known=true
done
if [[ $action_known = false ]]; then
echo "unknown action";
exit 0
fi
TRAINING_SET="dev";
TEST_SET="test";
FEATURE_SET="ehwon";
while getopts t:p:f: opt; do
case $opt in
t)
TRAINING_SET=$OPTARG
;;
p)
TEST_SET=$OPTARG
;;
f)
FEATURE_SET=$OPTARG
;;
esac
done
TRAINING_FILE="data/conll-2012/"$TRAINING_SET".auto";
MODEL="models/"$TRAINING_SET"_"$FEATURE_SET"_model.obj";
TEST_FILE="data/conll-2012/"$TEST_SET".gold";
FEATURE_FILE="features_"$FEATURE_SET".txt";
PREDICTION_OUTPUT_FILE=$FEATURE_SET"_out.conll";
printf $BLUE"\nInititializing procedure..."
if [[ $ACTION = "train" ]] || [[ $ACTION = "all" ]]; then
printf $NC"\n\ntraining model "$RED$MODEL$NC"\nbased on features in "$RED$FEATURE_FILE$NC"\ncalculated for data set "$RED$TRAINING_FILE$NC"\n\n"
python3 src/coref/train_coref.py -in $TRAINING_FILE -out $MODEL -extractor cort.coreference.approaches.mention_ranking.extract_substructures -perceptron cort.coreference.approaches.mention_ranking.RankingPerceptron -cost_function cort.coreference.cost_functions.cost_based_on_consistency -features $FEATURE_FILE
fi
if [[ $ACTION = "test" ]] || [[ $ACTION = "all" ]]; then
printf "\n\ntesting with model "$RED$MODEL$NC" \nbased on features in "$RED$FEATURE_FILE$NC" \ncalculated for test set "$RED$TEST_FILE$NC" \ncreating "$RED$PREDICTION_OUTPUT_FILE$NC"\n\n"
python3 src/coref/predict_coref.py -in $TEST_FILE -model $MODEL -out $PREDICTION_OUTPUT_FILE -extractor cort.coreference.approaches.mention_ranking.extract_substructures -perceptron cort.coreference.approaches.mention_ranking.RankingPerceptron -clusterer cort.coreference.clusterer.all_ante -features $FEATURE_FILE
fi
if [[ $ACTION = "score" ]] || [[ $ACTION = "all" ]]; then
printf "\n\nevaluating the output file "$RED$PREDICTION_OUTPUT_FILE$NC" \nagainst test file "$RED$TEST_FILE$NC"\n\n"
perl src/tools/reference-coreference-scorers-master/scorer.pl all $TEST_FILE $PREDICTION_OUTPUT_FILE none
fi