1+ #! /bin/sh
2+ GRAMMARS_DIR=${1:- " /workspace/sparrowhawk/documentation/grammars" }
3+ TEST_DIR=${2:- " /workspace/tests" }
4+
5+ runtest () {
6+ input=$1
7+ echo " INPUT is $input "
8+ cd ${GRAMMARS_DIR}
9+
10+ # read test file
11+ while read testcase; do
12+ IFS=' ~' read written spoken <<< $testcase
13+ # replace non breaking space with breaking space
14+ # Use below if postprocessor is not used. Comment if it is used
15+ # denorm_pred=$(echo $written | normalizer_main --config=sparrowhawk_configuration.ascii_proto 2>&1 | tail -n 1 | sed 's/\xC2\xA0/ /g')
16+ # Use below if postprocessor is used. Comment if it is not used
17+ denorm_pred=$( echo $written | normalizer_main --config=sparrowhawk_configuration_pp.ascii_proto 2>&1 | tail -n 1 | sed ' s/\xC2\xA0/ /g' )
18+
19+ # trim white space
20+ spoken=" $( echo -e " ${spoken} " | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
21+ denorm_pred=" $( echo -e " ${denorm_pred} " | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
22+
23+ # input expected actual
24+ assertEquals " $written " " $spoken " " $denorm_pred "
25+ done < " $input "
26+ }
27+
28+
29+ testTNCardinal () {
30+ input=$TEST_DIR /data_text_normalization/test_cases_cardinal.txt
31+ runtest $input
32+ }
33+
34+ # testTNSpecialText() {
35+ # input=$TEST_DIR/data_text_normalization/test_cases_special_text.txt
36+ # runtest $input
37+ # }
38+
39+ # testTNDate() {
40+ # input=$TEST_DIR/data_text_normalization/test_cases_date.txt
41+ # runtest $input
42+ # }
43+
44+ # testTNDecimal() {
45+ # input=$TEST_DIR/data_text_normalization/test_cases_decimal.txt
46+ # runtest $input
47+ # }
48+
49+ # testTNRange() {
50+ # input=$TEST_DIR/data_text_normalization/test_cases_range.txt
51+ # runtest $input
52+ # }
53+
54+ # testTNSerial() {
55+ # input=$TEST_DIR/data_text_normalization/test_cases_serial.txt
56+ # runtest $input
57+ # }
58+
59+ # testTNRoman() {
60+ # input=$TEST_DIR/data_text_normalization/test_cases_roman.txt
61+ # runtest $input
62+ # }
63+
64+ # testTNElectronic() {
65+ # input=$TEST_DIR/data_text_normalization/test_cases_electronic.txt
66+ # runtest $input
67+ # }
68+
69+ # testTNFraction() {
70+ # input=$TEST_DIR/data_text_normalization/test_cases_fraction.txt
71+ # runtest $input
72+ # }
73+
74+ # testTNMoney() {
75+ # input=$TEST_DIR/data_text_normalization/test_cases_money.txt
76+ # runtest $input
77+ # }
78+
79+ # testTNOrdinal() {
80+ # input=$TEST_DIR/data_text_normalization/test_cases_ordinal.txt
81+ # runtest $input
82+ # }
83+
84+ # testTNTelephone() {
85+ # input=$TEST_DIR/data_text_normalization/test_cases_telephone.txt
86+ # runtest $input
87+ # }
88+
89+ # testTNTime() {
90+ # input=$TEST_DIR/data_text_normalization/test_cases_time.txt
91+ # runtest $input
92+ # }
93+
94+ # testTNMeasure() {
95+ # input=$TEST_DIR/data_text_normalization/test_cases_measure.txt
96+ # runtest $input
97+ # }
98+
99+ # testTNWhitelist() {
100+ # input=$TEST_DIR/data_text_normalization/test_cases_whitelist.txt
101+ # runtest $input
102+ # }
103+
104+ # testTNWord() {
105+ # input=$TEST_DIR/data_text_normalization/test_cases_word.txt
106+ # runtest $input
107+ # }
108+
109+ # testTNAddress() {
110+ # input=$TEST_DIR/data_text_normalization/test_cases_address.txt
111+ # runtest $input
112+ # }
113+
114+ # testTNMath() {
115+ # input=$TEST_DIR/data_text_normalization/test_cases_math.txt
116+ # runtest $input
117+ # }
118+
119+ # Remove all command-line arguments
120+ shift $#
121+
122+ # Load shUnit2
123+ . /workspace/shunit2/shunit2
0 commit comments