Blame view

tools/sctk-2.4.10/src/sclite/testdata/exp_test.sh 12.5 KB
8dcb6dfcb   Yannick Estève   first commit
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
  #! /bin/sh
  
  base_dir=base
  OUT=out
  exe_dir=..
  exe_name=sclite
  clean=TRUE
  DATA=.
  
  ###
  ### File: tsclite.sh
  ### Usage: tsclite.sh [ -en exe_name | -nc | -clean ]
  ###
  ###
  for i in $*
  do
  	case $i in
          	-nc) clean="FALSE";;
                  -en) exe_name=$2;;
  		-clean) echo "Cleaning out tsclite.sh's directory"
  			rm -rf $OUT Failed.log *.pvc *.pure *.pv; rclean-up; exit;;
                  *) break;;
          esac
  	shift;
  done
  
  echo "tsclite.sh -- Version 1.2"
  echo "Variables:"
  echo "    reference directory  =" $base_dir
  echo "    executable directory =" $exe_dir
  echo "    sclite executable    =" $exe_name
  if test "`grep DIFF_EXE ../makefile`" = "" ; then
  	DIFF_ENABLED=0
  	echo "    Diff Alignments Disabled"
  else
  	DIFF_ENABLED=1
  	echo "    Diff Alignments Enabled"
  fi
  echo ""
  
  if [ -d $OUT ] ; then
  	echo "Shall I delete the output directory \"$OUT\"'s contents [y]"
  	read ans
  	if [ "$ans" = "n" -o "$ans" = "N" ] ; then
  		echo "    OK, leaving files inplace"
  	else
  		echo "    Erasing the output directory"
  		rm -rf $OUT
  		mkdir $OUT
  	fi
  	echo ""
  else
  	mkdir $OUT
  fi
  
  # TEST Number 1
  TN=1
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Align Both Ref and Hyp transcripts"
  echo "            (one transcript to a line followed by an utterance id in parens)"
  $exe_dir/${exe_name} -r $DATA/csrnab.ref -h $DATA/csrnab.hyp -i wsj \
  	-o all snt spk dtl -O $OUT -f 0 -n $TEST \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  ### This is a kludge to rename the *spk* and *snt* files to fit into 8.3 names
  for f in out/test1.spk* ; do
  	mv $f `echo $f |sed 's/test1.spk/test1_sp/'`
  done
  for f in out/test1.snt* ; do
  	mv $f `echo $f |sed 's/test1.snt/test1_st/'`
  done
  
  # TEST Number 2
  TN=2
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Same as Test 1, but use Diff instead of DP alignments"
  if test $DIFF_ENABLED = 1 ; then
      $exe_dir/${exe_name} -r $DATA/csrnab.ref -h $DATA/csrnab.hyp -i wsj \
  	-o all -O $OUT -f 0 -n $TEST -d \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  else
      echo "            **** Diff alignments have been disabled, not testing ***"
  fi
  
  
  # TEST Number 3
  TN=3
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Align Segmental Time marks (STM) to "
  echo "            Conversation time marks (CTM)"
  $exe_dir/${exe_name} -r $DATA/lvc_ref.stm stm -h $DATA/lvc_hyp.ctm ctm \
  	-o all lur -O $OUT -f 0 -n $TEST \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 4
  TN=4
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Same as test 3, but using diff for alignment"
  if test $DIFF_ENABLED = 1 ; then 
      $exe_dir/${exe_name} -r $DATA/lvc_ref.stm stm -h $DATA/lvc_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -d \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  else
      echo "            **** Diff alignments have been disabled, not testing ***"
  fi
  
  # TEST Number 5
  TN=5
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Align STM to free formatted text (TXT)"
  if test $DIFF_ENABLED = 1 ; then
      $exe_dir/${exe_name} -r $DATA/lvc_ref.stm stm -h $DATA/lvc_hyp.txt txt \
  	-o all -O $OUT -f 0 -n $TEST \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  else
      echo "            **** Diff alignments have been disabled, not testing ***"
  fi
  
  # TEST Number 6
  TN=6
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Align Mandarin Chinese words using DIFF"
  if test $DIFF_ENABLED = 1 ; then
      $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm \
  	-h $DATA/mand_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -d \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  else
      echo "            **** Diff alignments have been disabled, not testing ***"
  fi
  
  # TEST Number 7	
  TN=7
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Run some test cases through"
  $exe_dir/${exe_name} -r $DATA/tests.ref -h $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 7_r
  TN=7_r
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run some test cases through (reversing ref and hyp)"
  $exe_dir/${exe_name} -h $DATA/tests.ref -r $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 7_1
  TN=7_1
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run some test cases through using infered word boundaries,"
  echo "            not changing ASCII words"
  $exe_dir/${exe_name} -r $DATA/tests.ref -h $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST -S algo1 tests.lex \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 7_2
  TN=7_2
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run some test cases through using infered word boundaries,"
  echo "            changing ASCII words"
  $exe_dir/${exe_name} -r $DATA/tests.ref -h $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST -S algo1 tests.lex ASCIITOO \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 7_3
  TN=7_3
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run some test cases through using infered word boundaries,"
  echo "            not changing ASCII words and correct Fragments"
  $exe_dir/${exe_name} -r $DATA/tests.ref -h $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST -S algo1 tests.lex -F \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 7_4
  TN=7_4
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run some test cases through using infered word boundaries,"
  echo "            changing ASCII words and correct Fragments"
  $exe_dir/${exe_name} -r $DATA/tests.ref -h $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST -S algo1 tests.lex ASCIITOO -F \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 7_5
  TN=7_5
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run some test cases through, character aligning them and"
  echo "            removing hyphens"
  $exe_dir/${exe_name} -r $DATA/tests.ref -h $DATA/tests.hyp -i spu_id \
  	-o all -O $OUT -f 0 -n $TEST -c DH \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 8
  TN=8
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Align transcripts as character alignments"
  $exe_dir/${exe_name} -r $DATA/csrnab1.ref -h $DATA/csrnab1.hyp -i wsj \
  	-o all -O $OUT -f 0 -n $TEST -c \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 9
  TN=9
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:     Run the Mandarin, doing a character alignment"
  $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm -h $DATA/mand_hyp.ctm ctm \
  	-o all dtl -O $OUT -f 0 -n $TEST -c \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 9_1
  TN=9_1
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:   Run the Mandarin, doing a character alignment, removing hyphens"
  $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm -h $DATA/mand_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -c DH \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 10
  TN=10
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:    Run the Mandarin, doing a character alignment, not effecting ASCII WORDS"
  $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm -h $DATA/mand_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -c NOASCII \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 10_1
  TN=10_1
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:  Run the Mandarin, doing a character alignment, not effecting ASCII WORDS"
  echo "            Removing hyphens."
  $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm -h $DATA/mand_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -c NOASCII DH \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 11
  TN=11
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:    Run the Mandarin, doing the inferred word segmentation alignments"
  $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm -h $DATA/mand_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -S algo1 mand.lex \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 12
  TN=12
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:    Run the Mandarin, doing the inferred word segmentation alignments"
  echo "            Scoring fragments as correct"
  $exe_dir/${exe_name} -e gb -r $DATA/mand_ref.stm stm -h $DATA/mand_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -S algo1 mand.lex -F \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  # TEST Number 13
  TN=13
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:    Run alignments on two CTM files, using DP Word alignments"
  $exe_dir/${exe_name} -r $DATA/tima_ref.ctm ctm -h $DATA/tima_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  
  # TEST Number 13_a
  TN=13_a
  TEST=test$TN
  PURECOVOPTIONS="-counts-file=`pwd`/$TEST.sclite.pvc"; export PURECOVOPTIONS
  PURIFYOPTIONS="-log-file=`pwd`/$TEST.sclite.pure -view-file=`pwd`/$TEST.sclite.pv";
  export PURIFYOPTIONS
  echo "Test $TN:  Run alignments on two CTM files, using Time-Mediated DP alignments"
  $exe_dir/${exe_name} -r $DATA/tima_ref.ctm ctm -h $DATA/tima_hyp.ctm ctm \
  	-o all -O $OUT -f 0 -n $TEST -T \
  	1> $OUT/$TEST.out 2> $OUT/$TEST.err
  
  echo ""
  echo "Executions complete: Comparing output"
  echo ""
  
  if test $DIFF_ENABLED = 1 ; then
  	if test "`diff -r $base_dir $OUT`" = "" ; then
  		echo "ALL TESTS SUCCESSFULLY COMPLETED"
  		if [ $clean = "TRUE" ] ; then
  			rm -r $OUT
  		fi
  		exit 0
  	else
  		echo "     !!!!!  TESTS HAVE FAILED  !!!!!"
  		echo ""
  		echo "Read Failed.log"
  		diff -c -r $base_dir $OUT > Failed.log
  		exit 1
  	fi
  else
  	if test "`diff -r $base_dir $OUT | grep -ve 'test[2456]'`" = "" ; then
  		echo "ALL TESTS SUCCESSFULLY COMPLETED"
  		if [ $clean = "TRUE" ] ; then
  			rm -r $OUT
  		fi
  		exit 0
  	else
  		echo "     !!!!!  TESTS HAVE FAILED  !!!!!"
  		echo ""
  		echo "Read Failed.log"
  		diff -c -r $base_dir $OUT | grep -ve 'test[2456]' > Failed.log
  		exit 1
  	fi
  fi
  
  exit 0