25 #include <fst/flags.h> 26 #include <fst/fst-decl.h> 28 #include <fst/weight.h> 37 "Specifies failure label (default: none)");
44 typedef typename Arc::StateId StateId;
45 typedef typename Arc::Label Label;
46 typedef typename Arc::Weight Weight;
47 typedef f::ArcIterator<f::Fst<Arc>> ArcItr;
48 typedef f::StateIterator<f::Fst<Arc>> StateItr;
50 StateId start = fst.Start();
56 Label phi_label = FST_FLAGS_phi_label;
58 bool trim =
IsTrim(fst, phi_label);
61 bool norm =
IsNormalized(fst, phi_label, FST_FLAGS_delta);
62 std::vector<int> state_order;
66 std::vector<size_t> order_counts(max_order, 0);
68 for (StateItr siter(fst); !siter.Done(); siter.Next()) {
70 StateId s = siter.Value();
71 if (fst.Final(s) != Weight::Zero())
74 ++order_counts[state_order[s] - 1];
75 for (ArcItr aiter(fst, s); !aiter.Done(); aiter.Next()) {
77 const Arc &arc = aiter.Value();
78 if (arc.ilabel == phi_label)
83 const auto old = std::cout.setf(std::ios::left);
85 std::cout <<
"# of states" << nstates << std::endl;
87 std::cout <<
"# of arcs" << narcs << std::endl;
89 std::cout <<
"# of failure transitions" << nphis << std::endl;
91 std::cout <<
"initial state" << start << std::endl;
93 std::cout <<
"# of final states" << nfinal << std::endl;
96 std::cout <<
"max state order" << max_order << std::endl;
97 for (
int order = 1; order <= max_order; ++order) {
98 std::stringstream label;
99 label <<
"# of order-" << order <<
" states";
101 std::cout << label.str() << order_counts[order - 1] << std::endl;
105 std::cout <<
"canonical" << (canonical ?
'y' :
'n')
108 std::cout <<
"backoff-complete" << (backoff ?
'y' :
'n')
111 std::cout <<
"trim" << (trim ?
'y' :
'n')
114 std::cout <<
"conservative" << (conservative ?
'y' :
'n')
117 std::cout <<
"normalized" << (norm ?
'y' :
'n')
120 std::cout <<
"symbols" << (fst.InputSymbols() ?
'y' :
'n') << std::endl;
127 int main(
int argc,
char **argv) {
131 "Prints out information about a stochastic FST.\n\n Usage: ";
133 usage +=
" [in.fst]\n";
135 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
141 std::string in_name =
142 (argc > 1 && (strcmp(argv[1],
"-") != 0)) ? argv[1] :
"";
144 StdFst *ifst = StdFst::Read(in_name);
int main(int argc, char **argv)
int PhiStateOrder(const fst::Fst< Arc > &fst, typename Arc::Label phi_label, std::vector< int > *state_order)
DEFINE_double(delta, fst::kDelta,"Comparison delta")
bool IsConservative(const fst::Fst< Arc > &fst, float delta=fst::kDelta)
DEFINE_int64(phi_label, fst::kNoLabel,"Specifies failure label (default: none)")
bool IsCanonical(const fst::Fst< Arc > &fst, typename Arc::Label phi_label, std::vector< typename Arc::StateId > *top_order)
bool IsNormalized(const fst::Fst< Arc > &fst, typename Arc::Label phi_label=fst::kNoLabel, float delta=fst::kDelta)
void SfstInfo(const fst::Fst< Arc > &fst)
bool IsTrim(const fst::Fst< Arc > &fst, typename Arc::Label phi_label)
bool IsBackoffComplete(const fst::Fst< Arc > &fst, typename Arc::Label phi_label)