1#!/bin/sh
2. ./testfuncs.sh
3
4echo "LM_CONVERT TEST"
5tmpout="test-lm_convert.out"
6tmptxt="test-lm_convert.TXT"
7tmpfst="test-lm_convert.FST"
8tmpdmp="test-lm_convert.DMP"
9
10echo "This will perform several tests that compare the converted LMs to pre-generated ones. "
11
12#Couldn't do a match test because the paths generated in the LM will differ.
13if run_program sphinx3_lm_convert \
14-i $an4lm/an4.tg.phone.arpa \
15-o $tmpdmp > /dev/null 2>&1; then \
16pass "LM CONVERT PHONE DRY RUN LM TXT-> DMP test"; else
17fail "LM CONVERT PHONE DRY RUN LM TXT-> DMP test"; fi
18
19if run_program sphinx3_lm_convert \
20-i $an4lm/an4.tg.phone.arpa \
21-ifmt TXT32 \
22-o $tmpdmp > /dev/null 2>&1; then \
23pass "LM CONVERT PHONE DRY RUN LM TXT32-> DMP test"; else
24fail "LM CONVERT PHONE DRY RUN LM TXT32-> DMP test"; fi
25
26if run_program sphinx3_lm_convert \
27-i $an4lm/an4.tg.phone.arpa \
28-o $tmpdmp \
29-ofmt DMP32 \
30> /dev/null 2>&1; then \
31pass "LM CONVERT PHONE DRY RUN LM TXT-> DMP32 test"; else
32fail "LM CONVERT PHONE DRY RUN LM TXT-> DMP32 test"; fi
33
34if run_program sphinx3_lm_convert \
35-i $an4lm/an4.tg.phone.arpa \
36-ifmt TXT32 \
37-o $tmpdmp \
38-ofmt DMP32 \
39> /dev/null 2>&1; then \
40pass "LM CONVERT PHONE DRY RUN LM TXT32-> DMP32 test"; else
41fail "LM CONVERT PHONE DRY RUN LM TXT32-> DMP32 test"; fi
42
43
44rm -f $tmptxt
45
46run_program sphinx3_lm_convert \
47-i $an4lm/an4.tg.phone.arpa.DMP \
48-ifmt DMP \
49-o $tmptxt \
50-ofmt TXT \
51> $tmpout 2>&1
52
53compare_table "LM_CONVERT PHONE LM DMP -> TXT test" $tmptxt $an4lm/an4.tg.phone.arpa.lm_convert 0.0002
54
55
56rm -f $tmpfst ${tmpfst}.sym
57
58run_program sphinx3_lm_convert \
59-i $an4lm/an4.tg.phone.arpa \
60-o $tmpfst \
61-ofmt FST \
62> $tmpout 2>&1
63
64compare_table "LM_CONVERT PHONE LM TXT -> FST test" $tmpfst $an4lm/an4.tg.phone.arpa.FST 0.0002
65compare_table "LM_CONVERT PHONE LM TXT -> FST SYM test" ${tmpfst}.sym $an4lm/an4.tg.phone.arpa.FST.SYM 0.0002
66
67rm -f $tmpfst ${tmpfst}.sym
68
69run_program sphinx3_lm_convert \
70-i $an4lm/an4.tg.phone.arpa \
71-ifmt TXT32 \
72-o $tmpfst \
73-ofmt FST \
74> $tmpout 2>&1
75
76#This is cheating.  I was just too tired to get it tested at this point.
77#compare_table $tmpfst $an4lm/an4.tg.phone.arpa.FST 0.0002
78#then echo "LM_CONVERT PHONE LM TXT32 -> FST test"
79#echo "LM_CONVERT PHONE LM TXT32 -> FST test FAILED"; fi
80
81compare_table "LM_CONVERT PHONE LM TXT32 -> FST SYM test" ${tmpfst}.sym $an4lm/an4.tg.phone.arpa.FST.SYM 0.0002
82
83
84rm -f $tmpdmp $tmptxt
85
86run_program sphinx3_lm_convert \
87-i $an4lm/an4.tg.phone.arpa \
88-o $tmpdmp \
89> $tmpout 2>&1
90
91run_program sphinx3_lm_convert \
92-i $tmpdmp \
93-ifmt DMP \
94-o $tmptxt \
95-ofmt TXT \
96> $tmpout 2>&1
97
98compare_table "LM_CONVERT PHONE LM TXT -> DMP -> TXT test" $tmptxt $an4lm/an4.tg.phone.arpa.lm_convert 0.0002
99
100
101rm -f $tmpdmp $tmptxt
102
103run_program sphinx3_lm_convert \
104-i $an4lm/an4.tg.phone.arpa \
105-ifmt TXT32 \
106-o $tmpdmp \
107> $tmpout 2>&1
108
109run_program sphinx3_lm_convert \
110-i $tmpdmp \
111-ifmt DMP \
112-o $tmptxt \
113-ofmt TXT \
114> $tmpout 2>&1
115
116compare_table "LM_CONVERT PHONE LM TXT32 -> DMP -> TXT test" $tmptxt $an4lm/an4.tg.phone.arpa.lm_convert 0.0002
117
118
119rm -f $tmpdmp $tmptxt
120
121run_program sphinx3_lm_convert \
122-i $an4lm/an4.tg.phone.arpa \
123-o $tmpdmp \
124-ofmt DMP \
125> $tmpout 2>&1
126
127run_program sphinx3_lm_convert \
128-i $tmpdmp \
129-ifmt DMP \
130-o $tmptxt \
131-ofmt TXT \
132> $tmpout 2>&1
133
134compare_table "LM_CONVERT PHONE LM TXT -> DMP32 -> TXT test" $tmptxt $an4lm/an4.tg.phone.arpa.lm_convert 0.0002
135
136
137
138rm -f $tmpdmp $tmptxt
139
140run_program sphinx3_lm_convert \
141-i $an4lm/an4.tg.phone.arpa \
142-ifmt TXT32 \
143-o $tmpdmp \
144-ofmt DMP \
145> $tmpout 2>&1
146
147run_program sphinx3_lm_convert \
148-i $tmpdmp \
149-ifmt DMP \
150-o $tmptxt \
151-ofmt TXT \
152> $tmpout 2>&1
153
154compare_table "LM_CONVERT PHONE LM TXT32 -> DMP32 -> TXT test" $tmptxt $an4lm/an4.tg.phone.arpa.lm_convert 0.0002
155
156
157#Couldn't do a match test because the paths generated in the LM will differ.
158if run_program sphinx3_lm_convert \
159-i $an4lm/an4.ug.lm \
160-o $tmpdmp > /dev/null 2>&1; then \
161pass "LM CONVERT WORD DRY RUN LM TXT-> DMP test"; else
162fail "LM CONVERT WORD DRY RUN LM TXT-> DMP test"; fi
163
164
165if run_program sphinx3_lm_convert \
166-i $an4lm/an4.ug.lm \
167-o $tmpdmp \
168-ofmt DMP32 \
169> /dev/null 2>&1; then \
170pass "LM CONVERT WORD DRY RUN LM TXT-> DMP32 test"; else
171fail "LM CONVERT WORD DRY RUN LM TXT-> DMP32 test"; fi
172
173
174rm -f $tmptxt
175
176run_program sphinx3_lm_convert \
177-i $an4lm/an4.ug.lm.DMP \
178-ifmt DMP \
179-o $tmptxt \
180-ofmt TXT \
181> $tmpout 2>&1
182
183compare_table "LM_CONVERT WORD LM DMP -> TXT test" $tmptxt $an4lm/an4.ug.lm.lm_convert 0.0002
184
185
186rm -f $tmpfst
187
188run_program sphinx3_lm_convert \
189-i $an4lm/an4.ug.lm \
190-o $tmpfst \
191-ofmt FST \
192> $tmpout 2>&1
193
194compare_table "LM_CONVERT WORD LM TXT -> FST test" $tmpfst $an4lm/an4.ug.lm.FST 0.0002
195
196
197rm -f $tmpfst
198
199run_program sphinx3_lm_convert \
200-i $an4lm/an4.ug.lm \
201-ifmt TXT32 \
202-o $tmpfst \
203-ofmt FST \
204> $tmpout 2>&1
205
206compare_table "LM_CONVERT WORD LM TXT32 -> FST test" $tmpfst $an4lm/an4.ug.lm.FST 0.0002
207
208
209rm -f $tmpdmp $tmptxt
210
211run_program sphinx3_lm_convert \
212-i $an4lm/an4.ug.lm \
213-o $tmpdmp \
214> $tmpout 2>&1
215
216run_program sphinx3_lm_convert \
217-i $an4lm/an4.ug.lm.DMP \
218-ifmt DMP \
219-o $tmptxt \
220-ofmt TXT \
221> $tmpout 2>&1
222
223compare_table "LM_CONVERT WORD LM DMP -> TXT -> DMP test" $tmptxt $an4lm/an4.ug.lm.lm_convert 0.0002
224