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