Skip to content

Commit

Permalink
fix a bug where utterance_id is missing for Mikolov's rnnlm rescoring…
Browse files Browse the repository at this point in the history
…; fix a bug in rnnlmrescore.sh where old lmscore not getting removed under certain conditions
  • Loading branch information
hainan-xv committed Nov 29, 2015
1 parent d2b46f7 commit 431012a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions egs/wsj/s5/steps/rnnlmrescore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ if [ "$oldlm" == "$oldlang/G.fst" ]; then
# if the old LM scores were added e.g. by lmrescore.sh, using
# phi-matcher composition.
$cmd JOB=1:$nj $dir/log/remove_old.JOB.log \
lattice-compose --phi-label=$phi "ark:gunzip -c $dir/nbest1.JOB.gz|" $oldlm \
"ark:|gzip -c >$dir/nbest2.JOB.gz" || exit 1;
lattice-scale --acoustic-scale=-1 --lm-scale=-1 "ark:gunzip -c $dir/nbest1.JOB.gz|" ark:- \| \
lattice-compose --phi-label=$phi ark:- $oldlm ark:- \| \
lattice-scale --acoustic-scale=-1 --lm-scale=-1 ark:- "ark:|gzip -c >$dir/nbest2.JOB.gz" \
|| exit 1;
fi
else
if [ $stage -le 2 ]; then
Expand Down
12 changes: 10 additions & 2 deletions egs/wsj/s5/utils/rnnlm_compute_scores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ cat $tempdir/text | awk -v voc=$dir/wordlist.rnn -v unk=$dir/unk.probs \
# OK, now we compute the scores on the text with OOVs replaced
# with <RNN_UNK>

$rnnlm -independent -rnnlm $dir/rnnlm -test $tempdir/text.nounk -nbest -debug 0 | \
awk '{print $1*log(10);}' > $tempdir/loglikes.rnn
if [ $rnnlm_ver == "faster-rnnlm" ]; then
$rnnlm -independent -rnnlm $dir/rnnlm -test $tempdir/text.nounk -nbest -debug 0 | \
awk '{print $1*log(10);}' > $tempdir/loglikes.rnn
else
# add the utterance_id as required by Mikolove's rnnlm
paste $tempdir/ids $tempdir/text.nounk > $tempdir/id_text.nounk

$rnnlm -independent -rnnlm $dir/rnnlm -test $tempdir/id_text.nounk -nbest -debug 0 | \
awk '{print $1*log(10);}' > $tempdir/loglikes.rnn
fi

[ `cat $tempdir/loglikes.rnn | wc -l` -ne `cat $tempdir/loglikes.oov | wc -l` ] && \
echo "rnnlm rescoring failed" && exit 1;
Expand Down

0 comments on commit 431012a

Please sign in to comment.