-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathtest_sparrowhawk_normalization.sh
More file actions
61 lines (48 loc) · 1.48 KB
/
test_sparrowhawk_normalization.sh
File metadata and controls
61 lines (48 loc) · 1.48 KB
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
#! /bin/sh
GRAMMARS_DIR=${1:-"/workspace/sparrowhawk/documentation/grammars"}
PROJECT_DIR=${2:-"/workspace/tests/en"}
runtest () {
input=$1
echo "INPUT is $input"
cd ${GRAMMARS_DIR}
# read test file
while read testcase; do
IFS='~' read written spoken <<< $testcase
denorm_pred=$(echo $written | normalizer_main --config=sparrowhawk_configuration.ascii_proto 2>&1 | tail -n 1)
# trim white space
spoken="$(echo -e "${spoken}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
denorm_pred="$(echo -e "${denorm_pred}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# input expected actual
assertEquals "$written" "$spoken" "$denorm_pred"
done < "$input"
}
testTNCardinal() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_cardinal.txt
runtest $input
}
testTNDate() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_date.txt
runtest $input
}
testTNDecimal() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_decimal.txt
runtest $input
}
testTNFraction() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_fraction.txt
runtest $input
}
testTNOrdinal() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_ordinal.txt
runtest $input
}
testTNWhitelist() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_whitelist.txt
runtest $input
}
testTNWord() {
input=$PROJECT_DIR/fr/data_text_normalization/test_cases_word.txt
runtest $input
}
# Load shUnit2
. $PROJECT_DIR/../shunit2/shunit2