FST  openfst-1.8.3
OpenFst Library
compose.h
Go to the documentation of this file.
1 // Copyright 2005-2024 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 // Composes a PDT and an FST.
19 
20 #ifndef FST_EXTENSIONS_PDT_COMPOSE_H_
21 #define FST_EXTENSIONS_PDT_COMPOSE_H_
22 
23 #include <sys/types.h>
24 
25 #include <cstdint>
26 #include <list>
27 #include <utility>
28 #include <vector>
29 
30 #include <fst/log.h>
31 #include <fst/extensions/pdt/pdt.h>
32 #include <fst/compose-filter.h>
33 #include <fst/compose.h>
34 #include <fst/connect.h>
35 #include <fst/filter-state.h>
36 #include <fst/fst.h>
37 #include <fst/matcher.h>
38 #include <fst/mutable-fst.h>
39 #include <fst/properties.h>
40 #include <fst/util.h>
41 
42 namespace fst {
43 
44 // Returns paren arcs for Find(kNoLabel).
45 inline constexpr uint32_t kParenList = 0x00000001;
46 
47 // Returns a kNolabel loop for Find(paren).
48 inline constexpr uint32_t kParenLoop = 0x00000002;
49 
50 // This class is a matcher that treats parens as multi-epsilon labels.
51 // It is most efficient if the parens are in a range non-overlapping with
52 // the non-paren labels.
53 template <class F>
54 class ParenMatcher {
55  public:
56  using FST = F;
58  using Arc = typename FST::Arc;
59  using Label = typename Arc::Label;
60  using StateId = typename Arc::StateId;
61  using Weight = typename Arc::Weight;
62 
63  // This makes a copy of the FST.
64  ParenMatcher(const FST &fst, MatchType match_type,
65  uint32_t flags = (kParenLoop | kParenList))
66  : matcher_(fst, match_type), match_type_(match_type), flags_(flags) {
67  if (match_type == MATCH_INPUT) {
68  loop_.ilabel = kNoLabel;
69  loop_.olabel = 0;
70  } else {
71  loop_.ilabel = 0;
72  loop_.olabel = kNoLabel;
73  }
74  loop_.weight = Weight::One();
75  loop_.nextstate = kNoStateId;
76  }
77 
78  // This doesn't copy the FST.
79  ParenMatcher(const FST *fst, MatchType match_type,
80  uint32_t flags = (kParenLoop | kParenList))
81  : matcher_(fst, match_type), match_type_(match_type), flags_(flags) {
82  if (match_type == MATCH_INPUT) {
83  loop_.ilabel = kNoLabel;
84  loop_.olabel = 0;
85  } else {
86  loop_.ilabel = 0;
87  loop_.olabel = kNoLabel;
88  }
89  loop_.weight = Weight::One();
90  loop_.nextstate = kNoStateId;
91  }
92 
93  // This makes a copy of the FST.
94  ParenMatcher(const ParenMatcher<FST> &matcher, bool safe = false)
95  : matcher_(matcher.matcher_, safe),
96  match_type_(matcher.match_type_),
97  flags_(matcher.flags_),
98  open_parens_(matcher.open_parens_),
99  close_parens_(matcher.close_parens_),
100  loop_(matcher.loop_) {
101  loop_.nextstate = kNoStateId;
102  }
103 
104  ParenMatcher<FST> *Copy(bool safe = false) const {
105  return new ParenMatcher<FST>(*this, safe);
106  }
107 
108  MatchType Type(bool test) const { return matcher_.Type(test); }
109 
110  void SetState(StateId s) {
111  matcher_.SetState(s);
112  loop_.nextstate = s;
113  }
114 
115  bool Find(Label match_label);
116 
117  bool Done() const { return done_; }
118 
119  const Arc &Value() const { return paren_loop_ ? loop_ : matcher_.Value(); }
120 
121  void Next();
122 
123  Weight Final(StateId s) { return matcher_.Final(s); }
124 
125  ssize_t Priority(StateId s) { return matcher_.Priority(s); }
126 
127  const FST &GetFst() const { return matcher_.GetFst(); }
128 
129  uint64_t Properties(uint64_t props) const {
130  return matcher_.Properties(props);
131  }
132 
133  uint32_t Flags() const { return matcher_.Flags(); }
134 
135  void AddOpenParen(Label label) {
136  if (label == 0) {
137  FSTERROR() << "ParenMatcher: Bad open paren label: 0";
138  } else {
139  open_parens_.Insert(label);
140  }
141  }
142 
143  void AddCloseParen(Label label) {
144  if (label == 0) {
145  FSTERROR() << "ParenMatcher: Bad close paren label: 0";
146  } else {
147  close_parens_.Insert(label);
148  }
149  }
150 
151  void RemoveOpenParen(Label label) {
152  if (label == 0) {
153  FSTERROR() << "ParenMatcher: Bad open paren label: 0";
154  } else {
155  open_parens_.Erase(label);
156  }
157  }
158 
159  void RemoveCloseParen(Label label) {
160  if (label == 0) {
161  FSTERROR() << "ParenMatcher: Bad close paren label: 0";
162  } else {
163  close_parens_.Erase(label);
164  }
165  }
166 
167  void ClearOpenParens() { open_parens_.Clear(); }
168 
169  void ClearCloseParens() { close_parens_.Clear(); }
170 
171  bool IsOpenParen(Label label) const { return open_parens_.Member(label); }
172 
173  bool IsCloseParen(Label label) const { return close_parens_.Member(label); }
174 
175  private:
176  // Advances matcher to next open paren, returning true if it exists.
177  bool NextOpenParen();
178 
179  // Advances matcher to next close paren, returning true if it exists.
180  bool NextCloseParen();
181 
182  M matcher_;
183  MatchType match_type_; // Type of match to perform.
184  uint32_t flags_;
185  // Open paren label set.
186  CompactSet<Label, kNoLabel> open_parens_;
187  // Close paren label set.
188  CompactSet<Label, kNoLabel> close_parens_;
189  bool open_paren_list_; // Matching open paren list?
190  bool close_paren_list_; // Matching close paren list?
191  bool paren_loop_; // Current arc is the implicit paren loop?
192  mutable Arc loop_; // For non-consuming symbols.
193  bool done_; // Matching done?
194 
195  ParenMatcher &operator=(const ParenMatcher &) = delete;
196 };
197 
198 template <class FST>
199 inline bool ParenMatcher<FST>::Find(Label match_label) {
200  open_paren_list_ = false;
201  close_paren_list_ = false;
202  paren_loop_ = false;
203  done_ = false;
204  // Returns all parenthesis arcs.
205  if (match_label == kNoLabel && (flags_ & kParenList)) {
206  if (open_parens_.LowerBound() != kNoLabel) {
207  matcher_.LowerBound(open_parens_.LowerBound());
208  open_paren_list_ = NextOpenParen();
209  if (open_paren_list_) return true;
210  }
211  if (close_parens_.LowerBound() != kNoLabel) {
212  matcher_.LowerBound(close_parens_.LowerBound());
213  close_paren_list_ = NextCloseParen();
214  if (close_paren_list_) return true;
215  }
216  }
217  // Returns the implicit paren loop.
218  if (match_label > 0 && (flags_ & kParenLoop) &&
219  (IsOpenParen(match_label) || IsCloseParen(match_label))) {
220  paren_loop_ = true;
221  return true;
222  }
223  // Returns all other labels.
224  if (matcher_.Find(match_label)) return true;
225  done_ = true;
226  return false;
227 }
228 
229 template <class FST>
230 inline void ParenMatcher<FST>::Next() {
231  if (paren_loop_) {
232  paren_loop_ = false;
233  done_ = true;
234  } else if (open_paren_list_) {
235  matcher_.Next();
236  open_paren_list_ = NextOpenParen();
237  if (open_paren_list_) return;
238  if (close_parens_.LowerBound() != kNoLabel) {
239  matcher_.LowerBound(close_parens_.LowerBound());
240  close_paren_list_ = NextCloseParen();
241  if (close_paren_list_) return;
242  }
243  done_ = !matcher_.Find(kNoLabel);
244  } else if (close_paren_list_) {
245  matcher_.Next();
246  close_paren_list_ = NextCloseParen();
247  if (close_paren_list_) return;
248  done_ = !matcher_.Find(kNoLabel);
249  } else {
250  matcher_.Next();
251  done_ = matcher_.Done();
252  }
253 }
254 
255 // Advances matcher to next open paren, returning true if it exists.
256 template <class FST>
257 inline bool ParenMatcher<FST>::NextOpenParen() {
258  for (; !matcher_.Done(); matcher_.Next()) {
259  Label label = match_type_ == MATCH_INPUT ? matcher_.Value().ilabel
260  : matcher_.Value().olabel;
261  if (label > open_parens_.UpperBound()) return false;
262  if (IsOpenParen(label)) return true;
263  }
264  return false;
265 }
266 
267 // Advances matcher to next close paren, returning true if it exists.
268 template <class FST>
269 inline bool ParenMatcher<FST>::NextCloseParen() {
270  for (; !matcher_.Done(); matcher_.Next()) {
271  Label label = match_type_ == MATCH_INPUT ? matcher_.Value().ilabel
272  : matcher_.Value().olabel;
273  if (label > close_parens_.UpperBound()) return false;
274  if (IsCloseParen(label)) return true;
275  }
276  return false;
277 }
278 
279 template <class Filter>
280 class ParenFilter {
281  public:
282  using FST1 = typename Filter::FST1;
283  using FST2 = typename Filter::FST2;
284  using Arc = typename Filter::Arc;
285  using Label = typename Arc::Label;
286  using StateId = typename Arc::StateId;
287  using Weight = typename Arc::Weight;
288 
289  using Matcher1 = typename Filter::Matcher1;
290  using Matcher2 = typename Filter::Matcher2;
291 
292  using StackId = StateId;
294  using FilterState1 = typename Filter::FilterState;
297 
298  ParenFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1 = nullptr,
299  Matcher2 *matcher2 = nullptr,
300  const std::vector<std::pair<Label, Label>> *parens = nullptr,
301  bool expand = false, bool keep_parens = true)
302  : filter_(fst1, fst2, matcher1, matcher2),
303  parens_(parens ? *parens : std::vector<std::pair<Label, Label>>()),
304  expand_(expand),
305  keep_parens_(keep_parens),
306  fs_(FilterState::NoState()),
307  stack_(parens_),
308  paren_id_(-1) {
309  if (parens) {
310  for (const auto &pair : *parens) {
311  parens_.push_back(pair);
312  GetMatcher1()->AddOpenParen(pair.first);
313  GetMatcher2()->AddOpenParen(pair.first);
314  if (!expand_) {
315  GetMatcher1()->AddCloseParen(pair.second);
316  GetMatcher2()->AddCloseParen(pair.second);
317  }
318  }
319  }
320  }
321 
322  ParenFilter(const ParenFilter &filter, bool safe = false)
323  : filter_(filter.filter_, safe),
324  parens_(filter.parens_),
325  expand_(filter.expand_),
326  keep_parens_(filter.keep_parens_),
327  fs_(FilterState::NoState()),
328  stack_(filter.parens_),
329  paren_id_(-1) {}
330 
331  FilterState Start() const {
332  return FilterState(filter_.Start(), FilterState2(0));
333  }
334 
335  void SetState(StateId s1, StateId s2, const FilterState &fs) {
336  fs_ = fs;
337  filter_.SetState(s1, s2, fs_.GetState1());
338  if (!expand_) return;
339  ssize_t paren_id = stack_.Top(fs.GetState2().GetState());
340  if (paren_id != paren_id_) {
341  if (paren_id_ != -1) {
342  GetMatcher1()->RemoveCloseParen(parens_[paren_id_].second);
343  GetMatcher2()->RemoveCloseParen(parens_[paren_id_].second);
344  }
345  paren_id_ = paren_id;
346  if (paren_id_ != -1) {
347  GetMatcher1()->AddCloseParen(parens_[paren_id_].second);
348  GetMatcher2()->AddCloseParen(parens_[paren_id_].second);
349  }
350  }
351  }
352 
353  FilterState FilterArc(Arc *arc1, Arc *arc2) const {
354  const auto fs1 = filter_.FilterArc(arc1, arc2);
355  const auto &fs2 = fs_.GetState2();
356  if (fs1 == FilterState1::NoState()) return FilterState::NoState();
357  if (arc1->olabel == kNoLabel && arc2->ilabel) { // arc2 parentheses.
358  if (keep_parens_) {
359  arc1->ilabel = arc2->ilabel;
360  } else if (arc2->ilabel) {
361  arc2->olabel = arc1->ilabel;
362  }
363  return FilterParen(arc2->ilabel, fs1, fs2);
364  } else if (arc2->ilabel == kNoLabel && arc1->olabel) { // arc1 parentheses.
365  if (keep_parens_) {
366  arc2->olabel = arc1->olabel;
367  } else {
368  arc1->ilabel = arc2->olabel;
369  }
370  return FilterParen(arc1->olabel, fs1, fs2);
371  } else {
372  return FilterState(fs1, fs2);
373  }
374  }
375 
376  void FilterFinal(Weight *w1, Weight *w2) const {
377  if (fs_.GetState2().GetState() != 0) *w1 = Weight::Zero();
378  filter_.FilterFinal(w1, w2);
379  }
380 
381  // Returns respective matchers; ownership stays with filter.
382 
383  Matcher1 *GetMatcher1() { return filter_.GetMatcher1(); }
384 
385  Matcher2 *GetMatcher2() { return filter_.GetMatcher2(); }
386 
387  uint64_t Properties(uint64_t iprops) const {
388  return filter_.Properties(iprops) & kILabelInvariantProperties &
390  }
391 
392  private:
393  const FilterState FilterParen(Label label, const FilterState1 &fs1,
394  const FilterState2 &fs2) const {
395  if (!expand_) return FilterState(fs1, fs2);
396  const auto stack_id = stack_.Find(fs2.GetState(), label);
397  if (stack_id < 0) {
398  return FilterState::NoState();
399  } else {
400  return FilterState(fs1, FilterState2(stack_id));
401  }
402  }
403 
404  Filter filter_;
405  std::vector<std::pair<Label, Label>> parens_;
406  bool expand_; // Expands to FST?
407  bool keep_parens_; // Retains parentheses in output?
408  FilterState fs_; // Current filter state.
409  mutable ParenStack stack_;
410  ssize_t paren_id_;
411 };
412 
413 // Class to setup composition options for PDT composition. Default is to take
414 // the PDT as the first composition argument.
415 template <class Arc, bool left_pdt = true>
417  : public ComposeFstOptions<
418  Arc, ParenMatcher<Fst<Arc>>,
419  ParenFilter<AltSequenceComposeFilter<ParenMatcher<Fst<Arc>>>>> {
420  public:
421  using Label = typename Arc::Label;
424 
428 
430  const std::vector<std::pair<Label, Label>> &parens,
431  const Fst<Arc> &ifst2, bool expand = false,
432  bool keep_parens = true) {
433  matcher1 = new PdtMatcher(ifst1, MATCH_OUTPUT, kParenList);
434  matcher2 = new PdtMatcher(ifst2, MATCH_INPUT, kParenLoop);
435  filter = new PdtFilter(ifst1, ifst2, matcher1, matcher2, &parens, expand,
436  keep_parens);
437  }
438 };
439 
440 // Class to setup composition options for PDT with FST composition.
441 // Specialization is for the FST as the first composition argument.
442 template <class Arc>
444  : public ComposeFstOptions<
445  Arc, ParenMatcher<Fst<Arc>>,
446  ParenFilter<SequenceComposeFilter<ParenMatcher<Fst<Arc>>>>> {
447  public:
448  using Label = typename Arc::Label;
451 
455 
456  PdtComposeFstOptions(const Fst<Arc> &ifst1, const Fst<Arc> &ifst2,
457  const std::vector<std::pair<Label, Label>> &parens,
458  bool expand = false, bool keep_parens = true) {
459  matcher1 = new PdtMatcher(ifst1, MATCH_OUTPUT, kParenLoop);
460  matcher2 = new PdtMatcher(ifst2, MATCH_INPUT, kParenList);
461  filter = new PdtFilter(ifst1, ifst2, matcher1, matcher2, &parens, expand,
462  keep_parens);
463  }
464 };
465 
466 enum class PdtComposeFilter : uint8_t {
467  PAREN, // Bar-Hillel construction; keeps parentheses.
468  EXPAND, // Bar-Hillel + expansion; removes parentheses.
469  EXPAND_PAREN, // Bar-Hillel + expansion; keeps parentheses.
470 };
471 
473  bool connect; // Connect output?
474  PdtComposeFilter filter_type; // Pre-defined filter to use.
475 
476  explicit PdtComposeOptions(bool connect = true, PdtComposeFilter filter_type =
478  : connect(connect), filter_type(filter_type) {}
479 };
480 
481 // Composes pushdown transducer (PDT) encoded as an FST (1st arg) and an FST
482 // (2nd arg) with the result also a PDT encoded as an FST (3rd arg). In the
483 // PDTs, some transitions are labeled with open or close parentheses. To be
484 // interpreted as a PDT, the parens must balance on a path (see PdtExpand()).
485 // The open-close parenthesis label pairs are passed using the parens argument.
486 template <class Arc>
487 void Compose(
488  const Fst<Arc> &ifst1,
489  const std::vector<std::pair<typename Arc::Label, typename Arc::Label>>
490  &parens,
491  const Fst<Arc> &ifst2, MutableFst<Arc> *ofst,
492  const PdtComposeOptions &opts = PdtComposeOptions()) {
493  bool expand = opts.filter_type != PdtComposeFilter::PAREN;
494  bool keep_parens = opts.filter_type != PdtComposeFilter::EXPAND;
495  PdtComposeFstOptions<Arc, true> copts(ifst1, parens, ifst2, expand,
496  keep_parens);
497  copts.gc_limit = 0;
498  *ofst = ComposeFst<Arc>(ifst1, ifst2, copts);
499  if (opts.connect) Connect(ofst);
500 }
501 
502 // Composes an FST (1st arg) and pushdown transducer (PDT) encoded as an FST
503 // (2nd arg) with the result also a PDT encoded as an FST (3rd arg). In the
504 // PDTs, some transitions are labeled with open or close parentheses. To be
505 // interpreted as a PDT, the parens must balance on a path (see ExpandFst()).
506 // The open-close parenthesis label pairs are passed using the parens argument.
507 template <class Arc>
508 void Compose(
509  const Fst<Arc> &ifst1, const Fst<Arc> &ifst2,
510  const std::vector<std::pair<typename Arc::Label, typename Arc::Label>>
511  &parens,
512  MutableFst<Arc> *ofst,
513  const PdtComposeOptions &opts = PdtComposeOptions()) {
514  bool expand = opts.filter_type != PdtComposeFilter::PAREN;
515  bool keep_parens = opts.filter_type != PdtComposeFilter::EXPAND;
516  PdtComposeFstOptions<Arc, false> copts(ifst1, ifst2, parens, expand,
517  keep_parens);
518  copts.gc_limit = 0;
519  *ofst = ComposeFst<Arc>(ifst1, ifst2, copts);
520  if (opts.connect) Connect(ofst);
521 }
522 
523 } // namespace fst
524 
525 #endif // FST_EXTENSIONS_PDT_COMPOSE_H_
void SetState(StateId s1, StateId s2, const FilterState &fs)
Definition: compose.h:335
void Next() final
Definition: matcher.h:317
void RemoveOpenParen(Label label)
Definition: compose.h:151
constexpr uint32_t kParenLoop
Definition: compose.h:48
void SetState(StateId s) final
Definition: matcher.h:257
FilterState Start() const
Definition: compose.h:331
PdtComposeFstOptions(const Fst< Arc > &ifst1, const Fst< Arc > &ifst2, const std::vector< std::pair< Label, Label >> &parens, bool expand=false, bool keep_parens=true)
Definition: compose.h:456
bool IsOpenParen(Label label) const
Definition: compose.h:171
constexpr int kNoLabel
Definition: fst.h:195
typename FST::Arc Arc
Definition: compose.h:58
Matcher1 * GetMatcher1()
Definition: compose.h:383
typename AltSequenceComposeFilter< ParenMatcher< Fst< Arc > > >::Arc Arc
Definition: compose.h:284
ParenMatcher(const FST &fst, MatchType match_type, uint32_t flags=(kParenLoop|kParenList))
Definition: compose.h:64
uint32_t Flags() const
Definition: compose.h:133
void LowerBound(Label label)
Definition: matcher.h:288
void RemoveCloseParen(Label label)
Definition: compose.h:159
ParenMatcher(const FST *fst, MatchType match_type, uint32_t flags=(kParenLoop|kParenList))
Definition: compose.h:79
const Arc & Value() const final
Definition: matcher.h:311
MatchType
Definition: fst.h:187
Key LowerBound() const
Definition: util.h:501
const Arc & Value() const
Definition: compose.h:119
PdtComposeOptions(bool connect=true, PdtComposeFilter filter_type=PdtComposeFilter::PAREN)
Definition: compose.h:476
bool Done() const
Definition: compose.h:117
void Connect(MutableFst< Arc > *fst)
Definition: connect.h:47
void Erase(Key key)
Definition: util.h:462
Key UpperBound() const
Definition: util.h:504
constexpr uint32_t kParenList
Definition: compose.h:45
MatchType Type(bool test) const override
Definition: matcher.h:241
FilterState FilterArc(Arc *arc1, Arc *arc2) const
Definition: compose.h:353
typename AltSequenceComposeFilter< ParenMatcher< Fst< Arc > > >::FST1 FST1
Definition: compose.h:282
constexpr int kNoStateId
Definition: fst.h:196
PdtComposeFstOptions(const Fst< Arc > &ifst1, const std::vector< std::pair< Label, Label >> &parens, const Fst< Arc > &ifst2, bool expand=false, bool keep_parens=true)
Definition: compose.h:429
typename Arc::StateId StateId
Definition: compose.h:60
#define FSTERROR()
Definition: util.h:56
bool Done() const final
Definition: matcher.h:301
virtual uint32_t Flags() const
Definition: matcher.h:163
bool Find(Label match_label) final
Definition: matcher.h:270
MatchType Type(bool test) const
Definition: compose.h:108
void SetState(StateId s)
Definition: compose.h:110
void ClearOpenParens()
Definition: compose.h:167
void Compose(const Fst< Arc > &ifst1, const Fst< Arc > &ifst2, MutableFst< Arc > *ofst, const ComposeOptions &opts=ComposeOptions())
Definition: compose.h:1005
uint64_t Properties(uint64_t props) const
Definition: compose.h:129
Weight Final(StateId s) const final
Definition: matcher.h:325
ParenMatcher< FST > * Copy(bool safe=false) const
Definition: compose.h:104
bool IsCloseParen(Label label) const
Definition: compose.h:173
void Insert(Key key)
Definition: util.h:456
ParenFilter(const ParenFilter &filter, bool safe=false)
Definition: compose.h:322
void Clear()
Definition: util.h:473
uint64_t Properties(uint64_t iprops) const
Definition: compose.h:387
void ClearCloseParens()
Definition: compose.h:169
void FilterFinal(Weight *w1, Weight *w2) const
Definition: compose.h:376
void AddCloseParen(Label label)
Definition: compose.h:143
const FST & GetFst() const
Definition: compose.h:127
constexpr uint64_t kOLabelInvariantProperties
Definition: properties.h:270
PdtComposeFilter filter_type
Definition: compose.h:474
typename AltSequenceComposeFilter< ParenMatcher< Fst< Arc > > >::FST2 FST2
Definition: compose.h:283
ssize_t Priority(StateId s)
Definition: compose.h:125
constexpr uint64_t kILabelInvariantProperties
Definition: properties.h:261
Weight Final(StateId s)
Definition: compose.h:123
ssize_t Priority(StateId s) final
Definition: matcher.h:327
Matcher2 * GetMatcher2()
Definition: compose.h:385
typename Arc::Weight Weight
Definition: compose.h:61
bool Member(Key key) const
Definition: util.h:486
ParenFilter(const FST1 &fst1, const FST2 &fst2, Matcher1 *matcher1=nullptr, Matcher2 *matcher2=nullptr, const std::vector< std::pair< Label, Label >> *parens=nullptr, bool expand=false, bool keep_parens=true)
Definition: compose.h:298
const FST & GetFst() const override
Definition: matcher.h:329
const FilterState2 & GetState2() const
Definition: filter-state.h:177
bool Find(Label match_label)
Definition: compose.h:199
ParenMatcher(const ParenMatcher< FST > &matcher, bool safe=false)
Definition: compose.h:94
typename AltSequenceComposeFilter< ParenMatcher< Fst< Arc > > >::FilterState FilterState1
Definition: compose.h:294
typename Arc::Label Label
Definition: compose.h:421
typename AltSequenceComposeFilter< ParenMatcher< Fst< Arc > > >::Matcher1 Matcher1
Definition: compose.h:289
typename Arc::Label Label
Definition: compose.h:59
size_t gc_limit
Definition: cache.h:52
PdtComposeFilter
Definition: compose.h:466
uint64_t Properties(uint64_t inprops) const override
Definition: matcher.h:331
typename AltSequenceComposeFilter< ParenMatcher< Fst< Arc > > >::Matcher2 Matcher2
Definition: compose.h:290
void AddOpenParen(Label label)
Definition: compose.h:135