27 int main(
int argc, 
char *argv[]) {
    29     using namespace kaldi;
    32     typedef kaldi::uint64 uint64;
    35         "Take a union of the indexed lattices. The input index is in "    36         " the T*T*T semiring and\n"    37         "the output index is also in the T*T*T semiring. At the end of "    38         "this program, encoded\n"    39         "epsilon removal, determinization and minimization will be applied.\n"    41         "Usage: kws-index-union [options]  index-rspecifier index-wspecifier\n"    42         " e.g.: kws-index-union ark:input.idx ark:global.idx\n";
    47     bool skip_opt = 
false;
    48     int32 max_states = -1;
    50         "Will allow 0 lattice if it is set to false.");
    51     po.
Register(
"skip-optimization", &skip_opt,
    52         "Skip optimization if it's set to true.");
    53     po.
Register(
"max-states", &max_states,
    54         "Maximum states for DeterminizeStar.");
    63     std::string index_rspecifier = po.
GetArg(1),
    67                                                 index_reader(index_rspecifier);
    69                                                 index_writer(index_wspecifier);
    73     for (; !index_reader.
Done(); index_reader.
Next()) {
    74       std::string key = index_reader.
Key();
    78       Union(&global_index, index);
    83     if (skip_opt == 
false) {
    86       EncodeMapper<KwsLexicographicArc> encoder(kEncodeLabels, ENCODE);
    87       Encode(&ifst, &encoder);
    90       } 
catch(
const std::exception &e) {
    92                    << 
" (should affect speed of search but not results)";
    95       Minimize(&global_index, static_cast<KwsLexicographicFst*>(NULL), kDelta, 
true);
    96       Decode(&global_index, encoder);
    98       KALDI_LOG << 
"Skipping index optimization...";
   102     index_writer.
Write(
"global", global_index);
   104     KALDI_LOG << 
"Done " << n_done << 
" indices";
   106       return (n_done != 0 ? 0 : 1);
   109   } 
catch(
const std::exception &e) {
   110     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
 
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor]. 
 
A templated class for writing objects to an archive or script file; see The Table concept...
 
void Write(const std::string &key, const T &value) const
 
void Register(const std::string &name, bool *ptr, const std::string &doc)
 
fst::VectorFst< KwsLexicographicArc > KwsLexicographicFst
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
 
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables. 
 
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility. 
 
int NumArgs() const
Number of positional parameters (c.f. argc-1). 
 
int main(int argc, char *argv[])
 
bool DeterminizeStar(F &ifst, MutableFst< typename F::Arc > *ofst, float delta, bool *debug_ptr, int max_states, bool allow_partial)
This function implements the normal version of DeterminizeStar, in which the output strings are repre...
 
std::string GetOptArg(int param) const