Skip to content

Commit

Permalink
[scripts] make format_lm.sh work when source == target directory (kal…
Browse files Browse the repository at this point in the history
  • Loading branch information
jtrmal authored and danpovey committed Feb 8, 2018
1 parent f2ab7d4 commit 1f1b108
Showing 1 changed file with 12 additions and 6 deletions.
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

0 comments on commit 1f1b108

Please sign in to comment.