arpa-lm-compiler-test.cc File Reference
#include <iostream>
#include <string>
#include <sstream>
#include "base/kaldi-error.h"
#include "base/kaldi-math.h"
#include "lm/arpa-lm-compiler.h"
#include "util/kaldi-io.h"
Include dependency graph for arpa-lm-compiler-test.cc:

Go to the source code of this file.

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 

Enumerations

enum  { kEps = 0, kDisambig, kBos, kEos }
 

Functions

static fst::StdVectorFstCreateGenFst (bool seps, const fst::SymbolTable *pst)
 
ArpaLmCompiler * Compile (bool seps, const std::string &infile)
 
fst::StdArc::StateId AddToChainFsa (fst::StdMutableFst *fst, fst::StdArc::StateId last_state, int64 symbol)
 
void AddSelfLoops (fst::StdMutableFst *fst)
 
bool CoverageTest (bool seps, const std::string &infile)
 
bool ScoringTest (bool seps, const std::string &infile, const std::string &sentence, float expected)
 
bool ThrowsExceptionTest (bool seps, const std::string &infile)
 
bool RunAllTests (bool seps)
 
int main (int argc, char *argv[])
 

Variables

static const int kRandomSentences = 50
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 237 of file arpa-lm-compiler-test.cc.

References KALDI_LOG, KALDI_WARN, and RunAllTests().

237  {
238  bool ok = true;
239 
240  ok &= RunAllTests(false); // Without disambiguators (old behavior).
241  ok &= RunAllTests(true); // With epsilon substitution (new behavior).
242 
243  if (ok) {
244  KALDI_LOG << "All tests passed";
245  return 0;
246  } else {
247  KALDI_WARN << "Test FAILED";
248  return 1;
249  }
250 }
bool RunAllTests(bool seps)
#define KALDI_WARN
Definition: kaldi-error.h:150
#define KALDI_LOG
Definition: kaldi-error.h:153

◆ RunAllTests()

bool RunAllTests ( bool  seps)

Definition at line 219 of file arpa-lm-compiler-test.cc.

References kaldi::CoverageTest(), KALDI_WARN, kaldi::ScoringTest(), and kaldi::ThrowsExceptionTest().

Referenced by main().

219  {
220  bool ok = true;
221  ok &= kaldi::CoverageTest(seps, "test_data/missing_backoffs.arpa");
222  ok &= kaldi::CoverageTest(seps, "test_data/unused_backoffs.arpa");
223  ok &= kaldi::CoverageTest(seps, "test_data/input.arpa");
224 
225  ok &= kaldi::ScoringTest(seps, "test_data/input.arpa", "b b b a", 59.2649);
226  ok &= kaldi::ScoringTest(seps, "test_data/input.arpa", "a b", 4.36082);
227 
228  ok &= kaldi::ThrowsExceptionTest(seps, "test_data/missing_bos.arpa");
229 
230  if (!ok) {
231  KALDI_WARN << "Tests " << (seps ? "with" : "without")
232  << " epsilon substitution FAILED";
233  }
234  return ok;
235 }
bool ThrowsExceptionTest(bool seps, const std::string &infile)
bool CoverageTest(bool seps, const std::string &infile)
#define KALDI_WARN
Definition: kaldi-error.h:150
bool ScoringTest(bool seps, const std::string &infile, const std::string &sentence, float expected)