-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patheval_all.sh
44 lines (32 loc) · 1.3 KB
/
eval_all.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
#!/bin/bash
SITENAME=Home_and_Kitchen
CQ_DATA_DIR=./data
BLEU_SCRIPT="./eval/multi-bleu.perl"
TEXT_DIR0=$1
RM_TOK_DIR="./eval/remove_tokens.py"
python $RM_TOK_DIR --text $TEXT_DIR0
TEXT_DIR=$TEXT_DIR0"_2"
KWD_EVAL_DIR="./eval/kwd_eval.py"
KWD_DIR="./data/test_ref.kwds"
# BLEU
$BLEU_SCRIPT $CQ_DATA_DIR/test_ref < $TEXT_DIR
# Diversity
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
NGRAMS_SCRIPT=./eval/all_ngrams.pl
count_uniq_trigrams=$( cat $TEXT_DIR | $NGRAMS_SCRIPT 3 | sort | uniq -c | sort -gr | wc -l )
count_all_trigrams=$( cat $TEXT_DIR | $NGRAMS_SCRIPT 3 | sort | sort -gr | wc -l )
echo -n "Distinct-3 "
echo "scale=4; $count_uniq_trigrams / $count_all_trigrams" | bc
count_uniq_bigrams=$( cat $TEXT_DIR | $NGRAMS_SCRIPT 2 | sort | uniq -c | sort -gr | wc -l )
count_all_bigrams=$( cat $TEXT_DIR | $NGRAMS_SCRIPT 2 | sort | sort -gr | wc -l )
echo -n ", Distinct-2 "
echo "scale=4; $count_uniq_bigrams / $count_all_bigrams" | bc
count_uniq_unigrams=$( cat $TEXT_DIR | $NGRAMS_SCRIPT 1 | sort | uniq -c | sort -gr | wc -l )
count_all_unigrams=$( cat $TEXT_DIR | $NGRAMS_SCRIPT 1 | sort | sort -gr | wc -l )
echo -n ", Distinct-1 "
echo "scale=4; $count_uniq_unigrams / $count_all_unigrams" | bc
# KWD
python $KWD_EVAL_DIR --truth $KWD_DIR \
--pred $TEXT_DIR