21 #include <fst/flags.h> 25 #include <fst/mutable-fst.h> 26 #include <fst/properties.h> 32 "Specifies failure label (default: none)");
35 int main(
int argc,
char **argv) {
37 std::string usage =
"Algorithm to count from stochastic FST w.r.t. a";
38 usage +=
" backoff-complete FST whose topology is provided.\n\n Usage: ";
40 usage +=
" sfst.fst top.fst [out.fst]\n";
42 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
48 const std::string in1_name = strcmp(argv[1],
"-") != 0 ? argv[1] :
"";
49 const std::string in2_name =
50 (argc > 2 && (strcmp(argv[2],
"-") != 0)) ? argv[2] :
"";
51 const std::string out_name = argc > 3 ? argv[3] :
"";
53 if (in1_name.empty() && in2_name.empty()) {
54 LOG(ERROR) << argv[0] <<
": Can't take both inputs from standard input";
58 f::StdFst *ifst = f::StdFst::Read(in1_name);
61 f::StdMutableFst *ofst = f::StdMutableFst::Read(in2_name,
true);
64 if (ifst->Properties(f::kCyclic,
true) &&
66 LOG(ERROR) << argv[0] <<
": First input is not a normalized stochastic FST";
71 FST_FLAGS_delta, ofst);
75 if (ofst->Properties(f::kError,
false))
78 if (!ofst->Write(out_name))
DEFINE_int64(phi_label, fst::kNoLabel,"Specifies failure label (default: none)")
bool IsNormalized(const fst::Fst< Arc > &fst, typename Arc::Label phi_label=fst::kNoLabel, float delta=fst::kDelta)
int main(int argc, char **argv)
constexpr float kApproxDelta
DEFINE_double(delta, sfst::kApproxDelta,"Convergence delta")
void Count(const fst::Fst< Arc > &ifst)