Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions egs/wsj/s5/utils/format_lm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ mkdir -p $out_dir

echo "Converting '$lm' to FST"

if [ -e $out_dir/phones ]; then
rm -r $out_dir/phones
# the -ef test checks if source and target directory
# are two different directories in the filesystem
# if they are the same, the section guarded by the test
# would be actually harmfull (deleting the phones/ subdirectory)
if [ -e $out_dir ] && [ ! $lang_dir -ef $out_dir ] ; then
if [ -e $out_dir/phones ] ; then
rm -r $out_dir/phones
fi

for f in phones.txt words.txt topo L.fst L_disambig.fst phones oov.int oov.txt; do
cp -r $lang_dir/$f $out_dir
done
fi

for f in phones.txt words.txt topo L.fst L_disambig.fst phones oov.int oov.txt; do
cp -r $lang_dir/$f $out_dir
done

lm_base=$(basename $lm '.gz')
gunzip -c $lm \
| arpa2fst --disambig-symbol=#0 \
Expand Down