36 const auto start = fst.
Start();
41 LOG(ERROR) <<
"Verify: FST start state ID not set";
43 }
else if (start >= ns) {
44 LOG(ERROR) <<
"Verify: FST start state ID exceeds number of states";
48 auto state = siter.Value();
51 const auto &arc = aiter.Value();
52 if (!allow_negative_labels && arc.ilabel < 0) {
53 LOG(ERROR) <<
"Verify: FST input label ID of arc at position " << na
54 <<
" of state " << state <<
" is negative";
56 }
else if (isyms && !isyms->Member(arc.ilabel)) {
57 LOG(ERROR) <<
"Verify: FST input label ID " << arc.ilabel
58 <<
" of arc at position " << na <<
" of state " << state
59 <<
" is missing from input symbol table \"" << isyms->Name()
62 }
else if (!allow_negative_labels && arc.olabel < 0) {
63 LOG(ERROR) <<
"Verify: FST output label ID of arc at position " << na
64 <<
" of state " << state <<
" is negative";
66 }
else if (osyms && !osyms->Member(arc.olabel)) {
67 LOG(ERROR) <<
"Verify: FST output label ID " << arc.olabel
68 <<
" of arc at position " << na <<
" of state " << state
69 <<
" is missing from output symbol table \"" << osyms->Name()
72 }
else if (!arc.weight.Member()) {
73 LOG(ERROR) <<
"Verify: FST weight of arc at position " << na
74 <<
" of state " << state <<
" is invalid";
76 }
else if (arc.nextstate < 0) {
77 LOG(ERROR) <<
"Verify: FST destination state ID of arc at position " 78 << na <<
" of state " << state <<
" is negative";
80 }
else if (arc.nextstate >= ns) {
81 LOG(ERROR) <<
"Verify: FST destination state ID of arc at position " 82 << na <<
" of state " << state
83 <<
" exceeds number of states";
88 if (!fst.
Final(state).Member()) {
89 LOG(ERROR) <<
"Verify: FST final weight of state " << state
96 LOG(ERROR) <<
"Verify: FST error property is set";
100 uint64_t test_props =
103 LOG(ERROR) <<
"Verify: Stored FST properties incorrect " 104 <<
"(props1 = stored props, props2 = tested)";
113 #endif // FST_VERIFY_H_ uint64_t ComputeProperties(const Fst< Arc > &fst, uint64_t mask, uint64_t *known)
virtual uint64_t Properties(uint64_t mask, bool test) const =0
bool CompatProperties(uint64_t props1, uint64_t props2)
constexpr uint64_t kError
virtual Weight Final(StateId) const =0
virtual StateId Start() const =0
bool Verify(const Fst< Arc > &fst, bool allow_negative_labels=false)
constexpr uint64_t kFstProperties
virtual const SymbolTable * InputSymbols() const =0
Arc::StateId CountStates(const Fst< Arc > &fst)
virtual const SymbolTable * OutputSymbols() const =0