@@ -810,44 +810,32 @@ www.openfst.org and do the FST tutorial so that you understand the basics of fin
810810state transducers. (Note that language models would be represented as finite state
811811acceptors, or FSAs, which can be considered as a special case of finite state transducers).
812812
813- In the WSJ setup (like most setups), we use a statistical language model. The script <DFN>local/wsj_format_data.sh</DFN>
814- deals with converting the ARPA-format language models supplied with the WSJ database, into
815- an OpenFst format. Some of the key commands from that script are:
816- \verbatim
817- gunzip -c $lmdir/lm_${lm_suffix}.arpa.gz | \
818- utils/find_arpa_oovs.pl $test/words.txt > $tmpdir/oovs_${lm_suffix}.txt
819- ...
820- gunzip -c $lmdir/lm_${lm_suffix}.arpa.gz | \
821- grep -v '<s> <s>' | \
822- grep -v '</s> <s>' | \
823- grep -v '</s> </s>' | \
824- arpa2fst - | fstprint | \
825- utils/remove_oovs.pl $tmpdir/oovs_${lm_suffix}.txt | \
826- utils/eps2disambig.pl | utils/s2eps.pl | fstcompile --isymbols=$test/words.txt \
827- --osymbols=$test/words.txt --keep_isymbols=false --keep_osymbols=false | \
828- fstrmepsilon > $test/G.fst
829- \endverbatim
830- Here, the variable <DFN>\$test</DFN> would be something like <DFN>data/lang_test_tg</DFN>.
831- The most important of these commands is <DFN>arpa2fst</DFN> which is a Kaldi program.
832- This program turns the ARPA-format language model into a Weight Finite State Transducer
833- (actually, an acceptor).
834- The <DFN>grep</DFN> commands remove certain "invalid" n-grams from the language model, which
835- should not have been there in the first place. The program <DFN>remove_oovs.pl</DFN> removes
836- N-grams containing words not in our vocabulary (which would cause a crash in <DFN>fstcompile</DFN>); <DFN>eps2disambig.pl</DFN> turns the
837- <DFN>\<eps\></DFN> (\f$\epsilon\f$) symbols on backoff arcs into a special symbol <DFN>#0</DFN> which
838- we use to make the grammar determinizable; see \ref graph_disambig. If you don't know
839- what a "backoff arc" is, see the literature on backoff N-grams, for instance Goodman's "A bit of progress in
840- language modeling", and the paper by Mohri we referenced above. The command <DFN>s2eps.pl</DFN> turns the
841- sentence-begin and sentence-end symbols <DFN>\<s\></DFN> and <DFN>\</s\></DFN> into
842- epsilon (<DFN>\<eps\></DFN>), which means "no symbol"; <DFN>fstcompile</DFN> is an OpenFst
843- command which turns the
844- FST from text form into OpenFst binary form; and <DFN>fstrmepsilon</DFN> is also
845- an OpenFst command, which removes the small number of <DFN>\<eps\></DFN> symbols from the
846- FST, which were converted from <DFN>\<s\></DFN> and <DFN>\</s\></DFN>.
813+ The script <DFN>utils/format_lm.sh</DFN> deals with converting the ARPA-format language
814+ models into an OpenFst format. Here is the usage messages of that script:
815+ \verbatim
816+ Usage: utils/format_lm.sh <lang_dir> <arpa-LM> <lexicon> <out_dir>
817+ E.g.: utils/format_lm.sh data/lang data/local/lm/foo.kn.gz data/local/dict/lexicon.txt data/lang_test
818+ Convert ARPA-format language models to FSTs.
819+ \endverbatim
820+ Some of the key commands from that script are:
821+ \verbatim
822+ gunzip -c $lm \
823+ | arpa2fst --disambig-symbol=#0 \
824+ --read-symbol-table=$out_dir/words.txt - $out_dir/G.fst
825+ \endverbatim
826+ This Kaldi program, <DFN>arpa2fst</DFN>, turns the ARPA-format language model
827+ into a Weight Finite State Transducer (actually, an acceptor).
847828
848829A popular toolkit for building language models is SRILM. Various language
849830modeling toolkits are used in the Kaldi example scripts. SRILM is the best
850831documented and most fully featured, and we generally recommend it (its only
851- drawback is that it don't have the most free licence).
832+ drawback is that it don't have the most free licence). Here is the usage
833+ messages of <DFN>utils/format_lm_sri.sh</DFN>
834+
835+ \verbatim
836+ Usage: utils/format_lm_sri.sh [options] <lang-dir> <arpa-LM> <out-dir>
837+ E.g.: utils/format_lm_sri.sh data/lang data/local/lm/foo.kn.gz data/lang_test
838+ Converts ARPA-format language models to FSTs. Change the LM vocabulary using SRILM.
839+ \endverbatim
852840
853841*/
0 commit comments