37 const auto start = fst.
Start();
42 LOG(ERROR) <<
"Verify: FST start state ID not set";
44 }
else if (start >= ns) {
45 LOG(ERROR) <<
"Verify: FST start state ID exceeds number of states";
49 auto state = siter.Value();
52 const auto &arc = aiter.Value();
53 if (!allow_negative_labels && arc.ilabel < 0) {
54 LOG(ERROR) <<
"Verify: FST input label ID of arc at position " << na
55 <<
" of state " << state <<
" is negative";
57 }
else if (isyms && !isyms->Member(arc.ilabel)) {
58 LOG(ERROR) <<
"Verify: FST input label ID " << arc.ilabel
59 <<
" of arc at position " << na <<
" of state " << state
60 <<
" is missing from input symbol table \"" << isyms->Name()
63 }
else if (!allow_negative_labels && arc.olabel < 0) {
64 LOG(ERROR) <<
"Verify: FST output label ID of arc at position " << na
65 <<
" of state " << state <<
" is negative";
67 }
else if (osyms && !osyms->Member(arc.olabel)) {
68 LOG(ERROR) <<
"Verify: FST output label ID " << arc.olabel
69 <<
" of arc at position " << na <<
" of state " << state
70 <<
" is missing from output symbol table \"" << osyms->Name()
73 }
else if (!arc.weight.Member()) {
74 LOG(ERROR) <<
"Verify: FST weight of arc at position " << na
75 <<
" of state " << state <<
" is invalid";
77 }
else if (arc.nextstate < 0) {
78 LOG(ERROR) <<
"Verify: FST destination state ID of arc at position " 79 << na <<
" of state " << state <<
" is negative";
81 }
else if (arc.nextstate >= ns) {
82 LOG(ERROR) <<
"Verify: FST destination state ID of arc at position " 83 << na <<
" of state " << state
84 <<
" exceeds number of states";
89 if (!fst.
Final(state).Member()) {
90 LOG(ERROR) <<
"Verify: FST final weight of state " << state
97 LOG(ERROR) <<
"Verify: FST error property is set";
100 uint64_t known_props;
101 uint64_t test_props =
104 LOG(ERROR) <<
"Verify: Stored FST properties incorrect " 105 <<
"(props1 = stored props, props2 = tested)";
114 #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