arpa-lm-compiler.h
Go to the documentation of this file.
1 // lm/arpa-lm-compiler.h
2 
3 // Copyright 2009-2011 Gilles Boulianne
4 // Copyright 2016 Smart Action LLC (kkm)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 #ifndef KALDI_LM_ARPA_LM_COMPILER_H_
22 #define KALDI_LM_ARPA_LM_COMPILER_H_
23 
24 #include <fst/fstlib.h>
25 
26 #include "lm/arpa-file-parser.h"
27 
28 namespace kaldi {
29 
30 class ArpaLmCompilerImplInterface;
31 
33  public:
34  ArpaLmCompiler(const ArpaParseOptions& options, int sub_eps,
35  fst::SymbolTable* symbols)
36  : ArpaFileParser(options, symbols),
37  sub_eps_(sub_eps), impl_(NULL) {
38  }
40 
41  const fst::StdVectorFst& Fst() const { return fst_; }
43 
44  protected:
45  // ArpaFileParser overrides.
46  virtual void HeaderAvailable();
47  virtual void ConsumeNGram(const NGram& ngram);
48  virtual void ReadComplete();
49 
50 
51  private:
52  // this function removes states that only have a backoff arc coming
53  // out of them.
54  void RemoveRedundantStates();
55  void Check() const;
56 
57  int sub_eps_;
60  template <class HistKey> friend class ArpaLmCompilerImpl;
61 };
62 
63 } // namespace kaldi
64 
65 #endif // KALDI_LM_ARPA_LM_COMPILER_H_
ArpaFileParser is an abstract base class for ARPA LM file conversion.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
ArpaLmCompiler(const ArpaParseOptions &options, int sub_eps, fst::SymbolTable *symbols)
virtual void ConsumeNGram(const NGram &ngram)
Pure override that must be implemented to process current n-gram.
Options that control ArpaFileParser.
const fst::StdVectorFst & Fst() const
fst::StdVectorFst * MutableFst()
fst::StdVectorFst StdVectorFst
virtual void HeaderAvailable()
Override function called to signal that ARPA header with the expected number of n-grams has been read...
ArpaLmCompilerImplInterface * impl_
fst::StdVectorFst fst_
A parsed n-gram from ARPA LM file.
virtual void ReadComplete()
Override function called after the last n-gram has been consumed.