FST  openfst-1.7.2
OpenFst Library
compose-filter.h
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 //
4 // Classes for filtering the composition matches, e.g. for correct epsilon
5 // handling.
6 
7 #ifndef FST_COMPOSE_FILTER_H_
8 #define FST_COMPOSE_FILTER_H_
9 
10 #include <fst/filter-state.h>
11 #include <fst/fst-decl.h> // For optional argument declarations
12 #include <fst/fst.h>
13 #include <fst/matcher.h>
14 
15 
16 namespace fst {
17 
18 // Composition filters determine which matches are allowed to proceed. The
19 // filter's state is represeted by the type ComposeFilter::FilterState.
20 // The basic filters handle correct epsilon matching. Their interface is:
21 //
22 // template <class M1, class M2>
23 // class ComposeFilter {
24 // public:
25 // using Matcher1 = ...;
26 // using Matcher2 = ...;
27 // using FST1 = typename M1::FST;
28 // using FST2 = typename M2::FST;
29 // using FilterState = ...;
30 //
31 // using Arc = typename FST1::Arc;
32 // using StateId = typename Arc::StateId;
33 // using Weight = typename Arc::Weight;
34 //
35 // // Required constructor.
36 // ComposeFilter(const FST1 &fst1, const FST2 &fst2,
37 // M1 *matcher1 = nullptr, M2 *matcher2 = nullptr);
38 //
39 // // If safe=true, the copy is thread-safe. See Fst<>::Copy()
40 // // for further doc.
41 // ComposeFilter(const ComposeFilter<M1, M2> &filter,
42 // bool safe = false);
43 //
44 // // Return start state of filter.
45 // FilterState Start() const;
46 //
47 // // Specifies current composition state.
48 // void SetState(StateId s1, StateId s2, const FilterState &fs);
49 //
50 // // Apply filter at current composition state to these transitions. If an
51 // // arc label to be matched is kNolabel, then that side does not consume a
52 // // symbol. Returns the new filter state or, if disallowed,
53 // // FilterState::NoState(). The filter is permitted to modify its inputs
54 // // (e.g. for optimization reasons).
55 // FilterState FilterArc(Arc *arc1, Arc *arc2) const;
56 
57 // // Apply filter at current composition state to these final weights
58 // // (cf. superfinal transitions). The filter may modify its inputs
59 // // (e.g. for optimization reasons).
60 // void FilterFinal(Weight *w1, Weight *w2) const;
61 //
62 // // Return the respective matchers. Ownership stays with filter. These
63 // // methods allow the filter to access and possibly modify the compositio
64 // // matchers (useful, e.g., with lookahead).
65 //
66 // Matcher1 *GetMatcher1();
67 //
68 // Matcher2 *GetMatcher2();
69 //
70 // // This specifies how the filter affects the composition result properties.
71 // It takes as argument the properties that would apply with a trivial
72 // // composition filter.
73 // uint64 Properties(uint64 props) const;
74 // };
75 //
76 // This filter allows only exact matching of symbols from FST1 with on FST2;
77 // e.g., no special interpretation of epsilons.
78 template <class M1, class M2 /* = M1 */>
80  public:
81  using Matcher1 = M1;
82  using Matcher2 = M2;
83  using FST1 = typename M1::FST;
84  using FST2 = typename M2::FST;
86 
87  using Arc = typename FST1::Arc;
88  using Label = typename Arc::Label;
89  using StateId = typename Arc::StateId;
90  using Weight = typename Arc::Weight;
91 
92  NullComposeFilter(const FST1 &fst1, const FST2 &fst2,
93  Matcher1 *matcher1 = nullptr, Matcher2 *matcher2 = nullptr)
94  : matcher1_(matcher1 ? matcher1 : new Matcher1(fst1, MATCH_OUTPUT)),
95  matcher2_(matcher2 ? matcher2 : new Matcher2(fst2, MATCH_INPUT)),
96  fst1_(matcher1_->GetFst()),
97  fst2_(matcher2_->GetFst()) {}
98 
99  NullComposeFilter(const NullComposeFilter<M1, M2> &filter, bool safe = false)
100  : matcher1_(filter.matcher1_->Copy(safe)),
101  matcher2_(filter.matcher2_->Copy(safe)),
102  fst1_(matcher1_->GetFst()),
103  fst2_(matcher2_->GetFst()) {}
104 
105  FilterState Start() const { return FilterState(true); }
106 
107  void SetState(StateId, StateId, const FilterState &) {}
108 
109  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
110  return (arc1->olabel == kNoLabel || arc2->ilabel == kNoLabel)
112  : FilterState(true);
113  }
114 
115  void FilterFinal(Weight *, Weight *) const {}
116 
117  Matcher1 *GetMatcher1() { return matcher1_.get(); }
118 
119  Matcher2 *GetMatcher2() { return matcher2_.get(); }
120 
121  uint64 Properties(uint64 props) const { return props; }
122 
123  private:
124  std::unique_ptr<Matcher1> matcher1_;
125  std::unique_ptr<Matcher2> matcher2_;
126  const FST1 &fst1_;
127  const FST2 &fst2_;
128 };
129 
130 // This filter allows all epsilon matches, potentially resulting in redundant
131 // epsilon paths. The use of this filter gives correct results iff one of the
132 // following conditions hold:
133 //
134 // (1) The semiring is idempotent,
135 // (2) the first FST is output-epsilon free, or
136 // (3) the second FST is input-epsilon free.
137 //
138 // For (1), redundant epsilon paths may be created but won't hurt correctness.
139 // For (2) and (3), no redundant paths are created.
140 template <class M1, class M2 /* = M1 */>
142  public:
143  using Matcher1 = M1;
144  using Matcher2 = M2;
145  using FST1 = typename M1::FST;
146  using FST2 = typename M2::FST;
148 
149  using Arc = typename FST1::Arc;
150  using Label = typename Arc::Label;
151  using StateId = typename Arc::StateId;
152  using Weight = typename Arc::Weight;
153 
154  TrivialComposeFilter(const FST1 &fst1, const FST2 &fst2,
155  Matcher1 *matcher1 = nullptr,
156  Matcher2 *matcher2 = nullptr)
157  : matcher1_(matcher1 ? matcher1 : new Matcher1(fst1, MATCH_OUTPUT)),
158  matcher2_(matcher2 ? matcher2 : new Matcher2(fst2, MATCH_INPUT)),
159  fst1_(matcher1_->GetFst()),
160  fst2_(matcher2_->GetFst()) {}
161 
163  bool safe = false)
164  : matcher1_(filter.matcher1_->Copy(safe)),
165  matcher2_(filter.matcher2_->Copy(safe)),
166  fst1_(matcher1_->GetFst()),
167  fst2_(matcher2_->GetFst()) {}
168 
169  FilterState Start() const { return FilterState(true); }
170 
171  void SetState(StateId, StateId, const FilterState &) {}
172 
173  FilterState FilterArc(Arc *, Arc *) const { return FilterState(true); }
174 
175  void FilterFinal(Weight *, Weight *) const {}
176 
177  Matcher1 *GetMatcher1() { return matcher1_.get(); }
178 
179  Matcher2 *GetMatcher2() { return matcher2_.get(); }
180 
181  uint64 Properties(uint64 props) const { return props; }
182 
183  private:
184  std::unique_ptr<Matcher1> matcher1_;
185  std::unique_ptr<Matcher2> matcher2_;
186  const FST1 &fst1_;
187  const FST2 &fst2_;
188 };
189 
190 // This filter requires epsilons on FST1 to be read before epsilons on FST2.
191 template <class M1, class M2 /* = M1 */>
193  public:
194  using Matcher1 = M1;
195  using Matcher2 = M2;
196  using FST1 = typename M1::FST;
197  using FST2 = typename M2::FST;
199 
200  using Arc = typename FST1::Arc;
201  using Label = typename Arc::Label;
202  using StateId = typename Arc::StateId;
203  using Weight = typename Arc::Weight;
204 
205  SequenceComposeFilter(const FST1 &fst1, const FST2 &fst2,
206  Matcher1 *matcher1 = nullptr,
207  Matcher2 *matcher2 = nullptr)
208  : matcher1_(matcher1 ? matcher1 : new Matcher1(fst1, MATCH_OUTPUT)),
209  matcher2_(matcher2 ? matcher2 : new Matcher2(fst2, MATCH_INPUT)),
210  fst1_(matcher1_->GetFst()),
211  s1_(kNoStateId),
212  s2_(kNoStateId),
213  fs_(kNoStateId) {}
214 
216  bool safe = false)
217  : matcher1_(filter.matcher1_->Copy(safe)),
218  matcher2_(filter.matcher2_->Copy(safe)),
219  fst1_(matcher1_->GetFst()),
220  s1_(kNoStateId),
221  s2_(kNoStateId),
222  fs_(kNoStateId) {}
223 
224  FilterState Start() const { return FilterState(0); }
225 
226  void SetState(StateId s1, StateId s2, const FilterState &fs) {
227  if (s1_ == s1 && s2_ == s2 && fs == fs_) return;
228  s1_ = s1;
229  s2_ = s2;
230  fs_ = fs;
231  const auto na1 = internal::NumArcs(fst1_, s1);
232  const auto ne1 = internal::NumOutputEpsilons(fst1_, s1);
233  const bool fin1 = internal::Final(fst1_, s1) != Weight::Zero();
234  alleps1_ = na1 == ne1 && !fin1;
235  noeps1_ = ne1 == 0;
236  }
237 
238  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
239  if (arc1->olabel == kNoLabel) {
240  return alleps1_ ? FilterState::NoState() : noeps1_ ? FilterState(0)
241  : FilterState(1);
242  } else if (arc2->ilabel == kNoLabel) {
243  return fs_ != FilterState(0) ? FilterState::NoState() : FilterState(0);
244  } else {
245  return arc1->olabel == 0 ? FilterState::NoState() : FilterState(0);
246  }
247  }
248 
249  void FilterFinal(Weight *, Weight *) const {}
250 
251  Matcher1 *GetMatcher1() { return matcher1_.get(); }
252 
253  Matcher2 *GetMatcher2() { return matcher2_.get(); }
254 
255  uint64 Properties(uint64 props) const { return props; }
256 
257  private:
258  std::unique_ptr<Matcher1> matcher1_;
259  std::unique_ptr<Matcher2> matcher2_;
260  const FST1 &fst1_;
261  StateId s1_; // Current fst1_ state.
262  StateId s2_; // Current fst2_ state.
263  FilterState fs_; // Current filter state.
264  bool alleps1_; // Only epsilons (and non-final) leaving s1_?
265  bool noeps1_; // No epsilons leaving s1_?
266 };
267 
268 // This filter requires epsilons on FST2 to be read before epsilons on FST1.
269 template <class M1, class M2 /* = M1 */>
271  public:
272  using Matcher1 = M1;
273  using Matcher2 = M2;
274  using FST1 = typename M1::FST;
275  using FST2 = typename M2::FST;
277 
278  using Arc = typename FST1::Arc;
279  using Label = typename Arc::Label;
280  using StateId = typename Arc::StateId;
281  using Weight = typename Arc::Weight;
282 
283  AltSequenceComposeFilter(const FST1 &fst1, const FST2 &fst2,
284  Matcher1 *matcher1 = nullptr,
285  Matcher2 *matcher2 = nullptr)
286  : matcher1_(matcher1 ? matcher1 : new Matcher1(fst1, MATCH_OUTPUT)),
287  matcher2_(matcher2 ? matcher2 : new Matcher2(fst2, MATCH_INPUT)),
288  fst2_(matcher2_->GetFst()),
289  s1_(kNoStateId),
290  s2_(kNoStateId),
291  fs_(kNoStateId) {}
292 
295  bool safe = false)
296  : matcher1_(filter.matcher1_->Copy(safe)),
297  matcher2_(filter.matcher2_->Copy(safe)),
298  fst2_(matcher2_->GetFst()),
299  s1_(kNoStateId),
300  s2_(kNoStateId),
301  fs_(kNoStateId) {}
302 
303  FilterState Start() const { return FilterState(0); }
304 
305  void SetState(StateId s1, StateId s2, const FilterState &fs) {
306  if (s1_ == s1 && s2_ == s2 && fs == fs_) return;
307  s1_ = s1;
308  s2_ = s2;
309  fs_ = fs;
310  const auto na2 = internal::NumArcs(fst2_, s2);
311  const auto ne2 = internal::NumInputEpsilons(fst2_, s2);
312  const bool fin2 = internal::Final(fst2_, s2) != Weight::Zero();
313  alleps2_ = na2 == ne2 && !fin2;
314  noeps2_ = ne2 == 0;
315  }
316 
317  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
318  if (arc2->ilabel == kNoLabel) {
319  return alleps2_ ? FilterState::NoState() : noeps2_ ? FilterState(0)
320  : FilterState(1);
321  } else if (arc1->olabel == kNoLabel) {
322  return fs_ == FilterState(1) ? FilterState::NoState() : FilterState(0);
323  } else {
324  return arc1->olabel == 0 ? FilterState::NoState() : FilterState(0);
325  }
326  }
327 
328  void FilterFinal(Weight *, Weight *) const {}
329 
330  Matcher1 *GetMatcher1() { return matcher1_.get(); }
331 
332  Matcher2 *GetMatcher2() { return matcher2_.get(); }
333 
334  uint64 Properties(uint64 props) const { return props; }
335 
336  private:
337  std::unique_ptr<Matcher1> matcher1_;
338  std::unique_ptr<Matcher2> matcher2_;
339  const FST2 &fst2_;
340  StateId s1_; // Current fst1_ state.
341  StateId s2_; // Current fst2_ state.
342  FilterState fs_; // Current filter state.
343  bool alleps2_; // Only epsilons (and non-final) leaving s2_?
344  bool noeps2_; // No epsilons leaving s2_?
345 };
346 
347 // This filter requires epsilons on FST1 to be matched with epsilons on FST2
348 // whenever possible. (Template arg default declared in fst-decl.h.)
349 template <class M1, class M2 /* = M1 */>
351  public:
352  using Matcher1 = M1;
353  using Matcher2 = M2;
354  using FST1 = typename M1::FST;
355  using FST2 = typename M2::FST;
357 
358  using Arc = typename FST1::Arc;
359  using Label = typename Arc::Label;
360  using StateId = typename Arc::StateId;
361  using Weight = typename Arc::Weight;
362 
363  MatchComposeFilter(const FST1 &fst1, const FST2 &fst2,
364  Matcher1 *matcher1 = nullptr, Matcher2 *matcher2 = nullptr)
365  : matcher1_(matcher1 ? matcher1 : new Matcher1(fst1, MATCH_OUTPUT)),
366  matcher2_(matcher2 ? matcher2 : new Matcher2(fst2, MATCH_INPUT)),
367  fst1_(matcher1_->GetFst()),
368  fst2_(matcher2_->GetFst()),
369  s1_(kNoStateId),
370  s2_(kNoStateId),
371  fs_(kNoStateId) {}
372 
374  bool safe = false)
375  : matcher1_(filter.matcher1_->Copy(safe)),
376  matcher2_(filter.matcher2_->Copy(safe)),
377  fst1_(matcher1_->GetFst()),
378  fst2_(matcher2_->GetFst()),
379  s1_(kNoStateId),
380  s2_(kNoStateId),
381  fs_(kNoStateId) {}
382 
383  FilterState Start() const { return FilterState(0); }
384 
385  void SetState(StateId s1, StateId s2, const FilterState &fs) {
386  if (s1_ == s1 && s2_ == s2 && fs == fs_) return;
387  s1_ = s1;
388  s2_ = s2;
389  fs_ = fs;
390  size_t na1 = internal::NumArcs(fst1_, s1);
391  size_t ne1 = internal::NumOutputEpsilons(fst1_, s1);
392  bool f1 = internal::Final(fst1_, s1) != Weight::Zero();
393  alleps1_ = na1 == ne1 && !f1;
394  noeps1_ = ne1 == 0;
395  size_t na2 = internal::NumArcs(fst2_, s2);
396  size_t ne2 = internal::NumInputEpsilons(fst2_, s2);
397  bool f2 = internal::Final(fst2_, s2) != Weight::Zero();
398  alleps2_ = na2 == ne2 && !f2;
399  noeps2_ = ne2 == 0;
400  }
401 
402  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
403  if (arc2->ilabel == kNoLabel) { // Epsilon in FST1.
404  return fs_ == FilterState(0)
405  ? (noeps2_
406  ? FilterState(0)
407  : (alleps2_ ? FilterState::NoState() : FilterState(1)))
408  : (fs_ == FilterState(1) ? FilterState(1)
410  } else if (arc1->olabel == kNoLabel) { // Epsilon in FST2.
411  return fs_ == FilterState(0)
412  ? (noeps1_
413  ? FilterState(0)
414  : (alleps1_ ? FilterState::NoState() : FilterState(2)))
415  : (fs_ == FilterState(2) ? FilterState(2)
417  } else if (arc1->olabel == 0) { // Epsilon in both.
418  return fs_ == FilterState(0) ? FilterState(0) : FilterState::NoState();
419  } else { // Both are non-epsilons.
420  return FilterState(0);
421  }
422  }
423 
424  void FilterFinal(Weight *, Weight *) const {}
425 
426  Matcher1 *GetMatcher1() { return matcher1_.get(); }
427 
428  Matcher2 *GetMatcher2() { return matcher2_.get(); }
429 
430  uint64 Properties(uint64 props) const { return props; }
431 
432  private:
433  std::unique_ptr<Matcher1> matcher1_;
434  std::unique_ptr<Matcher2> matcher2_;
435  const FST1 &fst1_;
436  const FST2 &fst2_;
437  StateId s1_; // Current fst1_ state.
438  StateId s2_; // Current fst2_ state.
439  FilterState fs_; // Current filter state ID.
440  bool alleps1_; // Only epsilson (and non-final) leaving s1?
441  bool alleps2_; // Only epsilons (and non-final) leaving s2?
442  bool noeps1_; // No epsilons leaving s1?
443  bool noeps2_; // No epsilons leaving s2?
444 };
445 
446 // This filter disallows matching epsilons on FST1 with epsilons on FST2,
447 // but allows all other matches, potentially resulting in redundant
448 // epsilon paths. The use of this filter gives correct results iff one of the
449 // following conditions hold:
450 //
451 // (1) The semiring is idempotent,
452 // (2) the first FST is output-epsilon free, or
453 // (3) the second FST is input-epsilon free.
454 //
455 // For (1), redundant epsilon paths may be created but won't hurt correctness.
456 // For (2) and (3), no redundant paths are created.
457 template <class M1, class M2 /* = M1 */>
459  public:
460  using Matcher1 = M1;
461  using Matcher2 = M2;
462  using FST1 = typename M1::FST;
463  using FST2 = typename M2::FST;
465 
466  using Arc = typename FST1::Arc;
467  using Label = typename Arc::Label;
468  using StateId = typename Arc::StateId;
469  using Weight = typename Arc::Weight;
470 
471  NoMatchComposeFilter(const FST1 &fst1, const FST2 &fst2,
472  Matcher1 *matcher1 = nullptr,
473  Matcher2 *matcher2 = nullptr)
474  : matcher1_(matcher1 ? matcher1 : new Matcher1(fst1, MATCH_OUTPUT)),
475  matcher2_(matcher2 ? matcher2 : new Matcher2(fst2, MATCH_INPUT)),
476  fst1_(matcher1_->GetFst()),
477  fst2_(matcher2_->GetFst()) {}
478 
480  bool safe = false)
481  : matcher1_(filter.matcher1_->Copy(safe)),
482  matcher2_(filter.matcher2_->Copy(safe)),
483  fst1_(matcher1_->GetFst()),
484  fst2_(matcher2_->GetFst()) {}
485 
486  FilterState Start() const { return FilterState(true); }
487 
488  void SetState(StateId, StateId, const FilterState &) {}
489 
490  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
491  return FilterState(arc1->olabel != 0 || arc2->ilabel != 0);
492  }
493 
494  void FilterFinal(Weight *, Weight *) const {}
495 
496  Matcher1 *GetMatcher1() { return matcher1_.get(); }
497 
498  Matcher2 *GetMatcher2() { return matcher2_.get(); }
499 
500  uint64 Properties(uint64 props) const { return props; }
501 
502  private:
503  std::unique_ptr<Matcher1> matcher1_;
504  std::unique_ptr<Matcher2> matcher2_;
505  const FST1 &fst1_;
506  const FST2 &fst2_;
507 };
508 
509 // This filter works with the MultiEpsMatcher to determine if multi-epsilons are
510 // preserved in the composition output (rather than rewritten as 0) and
511 // ensures correct properties.
512 template <class Filter>
514  public:
515  using Matcher1 = typename Filter::Matcher1;
516  using Matcher2 = typename Filter::Matcher2;
517  using FST1 = typename Filter::FST1;
518  using FST2 = typename Filter::FST2;
519  using FilterState = typename Filter::FilterState;
520 
521  using Arc = typename Filter::Arc;
522  using Label = typename Arc::Label;
523  using StateId = typename Arc::StateId;
524  using Weight = typename Arc::Weight;
525 
526  MultiEpsFilter(const FST1 &fst1, const FST2 &fst2,
527  Matcher1 *matcher1 = nullptr, Matcher2 *matcher2 = nullptr,
528  bool keep_multi_eps = false)
529  : filter_(fst1, fst2, matcher1, matcher2),
530  keep_multi_eps_(keep_multi_eps) {}
531 
532  MultiEpsFilter(const MultiEpsFilter<Filter> &filter, bool safe = false)
533  : filter_(filter.filter_, safe),
534  keep_multi_eps_(filter.keep_multi_eps_) {}
535 
536  FilterState Start() const { return filter_.Start(); }
537 
538  void SetState(StateId s1, StateId s2, const FilterState &fs) {
539  return filter_.SetState(s1, s2, fs);
540  }
541 
542  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
543  const auto fs = filter_.FilterArc(arc1, arc2);
544  if (keep_multi_eps_) {
545  if (arc1->olabel == kNoLabel) arc1->ilabel = arc2->ilabel;
546  if (arc2->ilabel == kNoLabel) arc2->olabel = arc1->olabel;
547  }
548  return fs;
549  }
550 
551  void FilterFinal(Weight *w1, Weight *w2) const {
552  return filter_.FilterFinal(w1, w2);
553  }
554 
555  Matcher1 *GetMatcher1() { return filter_.GetMatcher1(); }
556 
557  Matcher2 *GetMatcher2() { return filter_.GetMatcher2(); }
558 
559  uint64 Properties(uint64 iprops) const {
560  const auto oprops = filter_.Properties(iprops);
562  }
563 
564  private:
565  Filter filter_;
566  bool keep_multi_eps_;
567 };
568 
569 } // namespace fst
570 
571 #endif // FST_COMPOSE_FILTER_H_
typename FST1::Arc Arc
ssize_t NumOutputEpsilons(const ExpandedFst< Arc > &fst, typename Arc::StateId s)
Definition: expanded-fst.h:99
void SetState(StateId s1, StateId s2, const FilterState &fs)
typename Arc::Label Label
typename Filter::Matcher2 Matcher2
constexpr int kNoLabel
Definition: fst.h:179
void FilterFinal(Weight *, Weight *) const
NoMatchComposeFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr)
TrivialComposeFilter(const TrivialComposeFilter< Matcher1, Matcher2 > &filter, bool safe=false)
typename Arc::Weight Weight
SequenceComposeFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr)
uint64_t uint64
Definition: types.h:32
void SetState(StateId s1, StateId s2, const FilterState &fs)
uint64 Properties(uint64 iprops) const
void SetState(StateId, StateId, const FilterState &)
MatchComposeFilter(const MatchComposeFilter< Matcher1, Matcher2 > &filter, bool safe=false)
void FilterFinal(Weight *w1, Weight *w2) const
typename Arc::StateId StateId
void SetState(StateId, StateId, const FilterState &)
void FilterFinal(Weight *, Weight *) const
uint64 Properties(uint64 props) const
Matcher1 * GetMatcher1()
void FilterFinal(Weight *, Weight *) const
typename FST1::Arc Arc
Arc::Weight Final(const ExpandedFst< Arc > &fst, typename Arc::StateId s)
Definition: expanded-fst.h:82
typename Arc::Label Label
uint64 Properties(uint64 props) const
void SetState(StateId s1, StateId s2, const FilterState &fs)
FilterState FilterArc(Arc *arc1, Arc *arc2) const
NoMatchComposeFilter(const NoMatchComposeFilter< Matcher1, Matcher2 > &filter, bool safe=false)
typename Filter::Matcher1 Matcher1
typename Arc::StateId StateId
void SetState(StateId s1, StateId s2, const FilterState &fs)
FilterState FilterArc(Arc *arc1, Arc *arc2) const
typename Filter::Arc Arc
AltSequenceComposeFilter(const AltSequenceComposeFilter< Matcher1, Matcher2 > &filter, bool safe=false)
ssize_t NumArcs(const ExpandedFst< Arc > &fst, typename Arc::StateId s)
Definition: expanded-fst.h:88
TrivialFilterState FilterState
FilterState Start() const
void SetState(StateId, StateId, const FilterState &)
void FilterFinal(Weight *, Weight *) const
typename FST1::Arc Arc
constexpr int kNoStateId
Definition: fst.h:180
typename FST1::Arc Arc
uint64 Properties(uint64 props) const
TrivialComposeFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr)
Matcher2 * GetMatcher2()
typename Filter::FilterState FilterState
static const TrivialFilterState NoState()
Definition: filter-state.h:181
NullComposeFilter(const NullComposeFilter< M1, M2 > &filter, bool safe=false)
IntegerFilterState< signed char > CharFilterState
Definition: filter-state.h:74
typename Arc::Label Label
ssize_t NumInputEpsilons(const ExpandedFst< Arc > &fst, typename Arc::StateId s)
Definition: expanded-fst.h:93
typename M1::FST FST1
MultiEpsFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr, bool keep_multi_eps=false)
FilterState FilterArc(Arc *arc1, Arc *arc2) const
typename Arc::Weight Weight
FilterState Start() const
FilterState FilterArc(Arc *, Arc *) const
typename M1::FST FST1
void FilterFinal(Weight *, Weight *) const
typename Arc::Weight Weight
typename Filter::FST2 FST2
typename ParenMatcher< Fst< Arc > >::FST FST1
void FilterFinal(Weight *, Weight *) const
constexpr uint64 kOLabelInvariantProperties
Definition: properties.h:245
FilterState Start() const
NullComposeFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr)
typename Arc::Label Label
FilterState Start() const
FilterState Start() const
uint64 Properties(uint64 props) const
typename Arc::StateId StateId
typename Arc::Weight Weight
typename Arc::Weight Weight
typename Arc::StateId StateId
FilterState Start() const
AltSequenceComposeFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr)
uint64 Properties(uint64 props) const
FilterState FilterArc(Arc *arc1, Arc *arc2) const
typename ParenMatcher< Fst< Arc > >::FST FST1
typename Arc::Label Label
FilterState FilterArc(Arc *arc1, Arc *arc2) const
MultiEpsFilter(const MultiEpsFilter< Filter > &filter, bool safe=false)
constexpr uint64 kILabelInvariantProperties
Definition: properties.h:236
MatchComposeFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr)
typename Filter::FST1 FST1
typename M2::FST FST2
typename Arc::StateId StateId
typename M2::FST FST2
FilterState FilterArc(Arc *arc1, Arc *arc2) const
SequenceComposeFilter(const SequenceComposeFilter< Matcher1, Matcher2 > &filter, bool safe=false)
FilterState Start() const
uint64 Properties(uint64 props) const