Home | History | Annotate | Download | only in lib

Lines Matching refs:Fst

26 #include "fst/lib/fst.h"
27 #include "fst/lib/cache.h"
28 #include "fst/lib/test-properties.h"
30 namespace fst {
34 // create an epsilon arc when recursing into the appropriate Fst.
52 // \brief Implementation class for replace class Fst
55 // expansion of a recursive transition network represented as Fst
91 StateId fst_id; // current fst being walked
92 StateId fst_state; // current state in fst being walked, not to be
93 // confused with the state_id of the combined fst
97 // \param fst_tuples array of label/fst tuples, one for each non-terminal
98 ReplaceFstImpl(const vector< pair<Label, const Fst<A>* > >& fst_tuples,
142 // Add to Fst array
143 void AddFst(Label label, const Fst<A>* fst) {
145 fst_array_.push_back(fst->Copy());
158 LOG(FATAL) << "ReplaceFst::AddFst input symbols of Fst " << i-1
159 << " does not match input symbols of base Fst (0'th fst)";
162 LOG(FATAL) << "ReplaceFst::AddFst output symbols of Fst " << i-1
163 << " does not match output symbols of base Fst "
164 << "(0'th fst)";
172 // in an un-expandable replace fst.
176 // one state for each fst
180 // an arc from each state (representing the fst) to the
181 // state representing the fst being replaced
183 for (StateIterator<Fst<A> > siter(*(fst_array_[i]));
185 for (ArcIterator<Fst<A> > aiter(*(fst_array_[i]), siter.Value());
210 // Change Fst array
211 void SetFst(Label label, const Fst<A>* fst) {
214 fst_array_[nonterminal] = fst->Copy();
217 // Return or compute start state of replace fst
224 const Fst<A>* fst = fst_array_[root_];
225 StateId fst_start = fst->Start();
226 if (fst_start == kNoStateId) // root Fst is empty
244 const Fst<A>* fst = fst_array_[tuple.fst_id];
247 if (fst->Final(fst_state) != Weight::Zero() && stack.Depth() == 0)
248 SetFinal(s, fst->Final(fst_state));
281 // Find/create an Fst state given a StateTuple. Only create a new
298 const Fst<A>* fst = fst_array_[tuple.fst_id];
307 if (fst->Final(fst_state) != Weight::Zero() && stack.Depth()) {
313 AddArc(s, A(0, 0, fst->Final(fst_state), nextstate));
317 for (ArcIterator< Fst<A> > aiter(*fst, fst_state);
320 if (arc.olabel == 0) { // expand local fst
330 const Fst<A>* nt_fst = fst_array_[nonterminal];
372 // \brief Hash function for StateTuple to Fst states
502 vector<const Fst<A>*> fst_array_;
512 // \brief Recursivively replaces arcs in the root Fst with other Fsts.
513 // This version is a delayed Fst.
515 // ReplaceFst supports dynamic replacement of arcs in one Fst with
516 // another Fst. This replacement is recursive. ReplaceFst can be used
519 // array of Fst(s). One Fst represents the root (or topology)
520 // machine. The root Fst refers to other Fsts by recursively replacing
522 // Fst. Currently the ReplaceFst uses the output symbols of the arcs
528 // to the tuple of non-terminal Label and corresponding Fst. For example
530 // Fst is a single Arc on the start State that self loops, it references
534 class ReplaceFst : public Fst<A> {
546 ReplaceFst(const vector<pair<Label, const Fst<A>* > >& fst_array,
550 ReplaceFst(const vector<pair<Label, const Fst<A>* > >& fst_array,
554 ReplaceFst(const ReplaceFst<A>& fst) :
555 impl_(new ReplaceFstImpl<A>(*(fst.impl_))) {}
627 explicit StateIterator(const ReplaceFst<A> &fst)
628 : CacheStateIterator< ReplaceFst<A> >(fst) {}
641 ArcIterator(const ReplaceFst<A> &fst, StateId s)
642 : CacheArcIterator< ReplaceFst<A> >(fst, s) {
643 if (!fst.impl_->HasArcs(s))
644 fst.impl_->Expand(s);
659 // // Recursivively replaces arcs in the root Fst with other Fsts.
662 // Replace supports replacement of arcs in one Fst with another
663 // Fst. This replacement is recursive. Replace takes an array of
664 // Fst(s). One Fst represents the root (or topology) machine. The root
665 // Fst refers to other Fsts by recursively replacing arcs labeled as
666 // non-terminals with the matching non-terminal Fst. Currently Replace
671 // of non-terminal Label and corresponding Fst.
674 const Fst<Arc>* > >& ifst_array,