Home | History | Annotate | Download | only in fst

Lines Matching refs:FST

19 // Classes to add lookahead to FST matchers, useful e.g. for improving
25 #include <fst/add-on.h>
26 #include <fst/const-fst.h>
27 #include <fst/fst.h>
28 #include <fst/label-reachable.h>
29 #include <fst/matcher.h>
35 namespace fst {
43 // typedef F FST;
50 // LookAheadMatcher(const F &fst, MatchType match_type);
51 // // If safe=true, the copy is thread-safe (except the lookahead Fst is
52 // // preserved). See Fst<>::Cop() for further doc.
65 // // arbitrary rational set of strings, specified by an FST and a state
66 // // from which to begin the matching. If the lookahead FST is a
70 // // Are there paths P from 's' in the lookahead FST that can be read from
72 // bool LookAheadFst(const Fst<Arc>& fst, StateId s);
80 // // Is there is a single non-epsilon arc found in the lookahead FST
87 // // Optionally pre-specifies the lookahead FST that will be passed
89 // // then 'fst' is a copy of the FST used in the previous call to
91 // void InitLookAheadFst(const Fst<Arc>& fst, bool copy = false);
112 // Look-ahead of matcher FST non-epsilon arcs?
115 // Look-ahead of matcher FST epsilon arcs?
131 // InitMatcher() Fst method.
148 bool LookAheadFst(const Fst<Arc> &fst, StateId s) {
149 return LookAheadFst_(fst, s);
163 virtual void InitLookAheadFst(const Fst<Arc>& fst, bool copy = false) = 0;
174 virtual bool LookAheadFst_(const Fst<Arc> &fst,
185 : public LookAheadMatcherBase<typename M::FST::Arc> {
187 typedef typename M::FST FST;
193 TrivialLookAheadMatcher(const FST &fst, MatchType match_type)
194 : matcher_(fst, match_type) {}
211 virtual const FST &GetFst() const { return matcher_.GetFst(); }
219 bool LookAheadFst(const Fst<Arc> &fst, StateId s) {return true; }
222 void InitLookAheadFst(const Fst<Arc>& fst, bool copy = false) {}
236 bool LookAheadFst_(const Fst<Arc> &fst, StateId s) {
237 return LookAheadFst(fst, s);
251 : public LookAheadMatcherBase<typename M::FST::Arc> {
253 typedef typename M::FST FST;
265 ArcLookAheadMatcher(const FST &fst, MatchType match_type,
267 : matcher_(fst, match_type),
295 const FST &GetFst() const { return fst_; }
310 bool LookAheadFst(const Fst<Arc> &fst, StateId s);
312 void InitLookAheadFst(const Fst<Arc>& fst, bool copy = false) {
313 lfst_ = &fst;
327 bool LookAheadFst_(const Fst<Arc> &fst, StateId s) {
328 return LookAheadFst(fst, s);
332 const FST &fst_; // Matcher FST
333 const Fst<Arc> *lfst_; // Look-ahead FST
338 bool ArcLookAheadMatcher<M, F>::LookAheadFst(const Fst<Arc> &fst, StateId s) {
339 if (&fst != lfst_)
340 InitLookAheadFst(fst);
367 for (ArcIterator< Fst<Arc> > aiter(*lfst_, s);
424 : public LookAheadMatcherBase<typename M::FST::Arc> {
426 typedef typename M::FST FST;
438 LabelLookAheadMatcher(const FST &fst, MatchType match_type,
440 : matcher_(fst, match_type),
456 fst, reach_input, s, F & kLookAheadKeepRelabelData);
500 const FST &GetFst() const { return matcher_.GetFst(); }
542 bool LookAheadFst(const L &fst, StateId s);
544 void InitLookAheadFst(const Fst<Arc>& fst, bool copy = false) {
545 lfst_ = &fst;
547 label_reachable_->ReachInit(fst, copy);
551 void InitLookAheadFst(const L& fst, bool copy = false) {
552 lfst_ = static_cast<const Fst<Arc> *>(&fst);
554 label_reachable_->ReachInit(fst, copy);
568 bool LookAheadFst_(const Fst<Arc> &fst, StateId s) {
569 return LookAheadFst(fst, s);
573 const Fst<Arc> *lfst_; // Look-ahead FST
583 bool LabelLookAheadMatcher<M, F, S>::LookAheadFst(const L &fst, StateId s) {
584 if (static_cast<const Fst<Arc> *>(&fst) != lfst_)
585 InitLookAheadFst(fst);
600 ArcIterator<L> aiter(fst, s);
633 // Relabels matcher Fst - initialization function object.
637 // Relabels arbitrary Fst. Class L should be a label-lookahead Fst.
639 static void Relabel(MutableFst<A> *fst, const L &mfst,
645 reachable.Relabel(fst, relabel_input);
649 // Class L should be a label-lookahead Fst.
667 Fst<A> &fst = (*impl)->GetFst();
670 bool is_mutable = fst.Properties(kMutable, false);
673 mfst = static_cast<MutableFst<A> *>(&fst);
675 mfst = new VectorFst<A>(fst);
705 // Generic lookahead matcher, templated on the FST definition
710 typedef F FST;
717 LookAheadMatcher(const F &fst, MatchType match_type) {
718 base_ = fst.InitMatcher(match_type);
720 base_ = new SortedMatcher<F>(fst, match_type);
758 bool LookAheadFst(const Fst<Arc> &fst, StateId s) {
761 return lbase->LookAheadFst(fst, s);
785 void InitLookAheadFst(const Fst<Arc>& fst, bool copy = false) {
788 lbase->InitLookAheadFst(fst, copy);
810 } // namespace fst