20 #ifndef FST_MATCHER_H_ 21 #define FST_MATCHER_H_ 33 #include <unordered_map> 148 virtual bool Done()
const = 0;
149 virtual const Arc &
Value()
const = 0;
150 virtual void Next() = 0;
152 virtual uint64_t
Properties(uint64_t)
const = 0;
156 virtual uint32_t
Flags()
const {
return 0; }
172 using Arc =
typename FST::Arc;
185 owned_fst_.reset(&fst_);
194 aiter_(std::nullopt),
195 match_type_(match_type),
196 binary_label_(binary_label),
201 switch (match_type_) {
206 std::swap(loop_.ilabel, loop_.olabel);
209 FSTERROR() <<
"SortedMatcher: Bad match type";
217 : owned_fst_(matcher.fst_.
Copy(safe)),
220 aiter_(std::nullopt),
221 match_type_(matcher.match_type_),
222 binary_label_(matcher.binary_label_),
225 loop_(matcher.loop_),
226 error_(matcher.error_) {}
235 if (match_type_ ==
MATCH_NONE)
return match_type_;
236 const auto true_prop =
238 const auto false_prop =
240 const auto props = fst_.Properties(true_prop | false_prop, test);
241 if (props & true_prop) {
243 }
else if (props & false_prop) {
251 if (state_ == s)
return;
254 FSTERROR() <<
"SortedMatcher: Bad match type";
257 aiter_.emplace(fst_, s);
266 current_loop_ =
false;
270 current_loop_ = match_label == 0;
271 match_label_ = match_label ==
kNoLabel ? 0 : match_label;
275 return current_loop_;
282 exact_match_ =
false;
283 current_loop_ =
false;
288 match_label_ = label;
295 if (current_loop_)
return false;
296 if (aiter_->Done())
return true;
297 if (!exact_match_)
return false;
301 return GetLabel() != match_label_;
305 if (current_loop_)
return loop_;
307 return aiter_->Value();
312 current_loop_ =
false;
325 return inprops | (error_ ?
kError : 0);
328 size_t Position()
const {
return aiter_ ? aiter_->Position() : 0; }
331 Label GetLabel()
const {
332 const auto &arc = aiter_->Value();
333 return match_type_ ==
MATCH_INPUT ? arc.ilabel : arc.olabel;
340 std::unique_ptr<const FST> owned_fst_;
343 mutable std::optional<ArcIterator<FST>>
362 size_t size = narcs_;
366 size_t high = size - 1;
368 const size_t half = size / 2;
369 const size_t mid = high - half;
371 if (GetLabel() >= match_label_) {
377 const auto label = GetLabel();
378 if (label == match_label_) {
381 if (label < match_label_) {
391 for (aiter_->Reset(); !aiter_->Done(); aiter_->Next()) {
392 const auto label = GetLabel();
393 if (label == match_label_)
return true;
394 if (label > match_label_)
break;
406 if (match_label_ >= binary_label_) {
407 return BinarySearch();
409 return LinearSearch();
420 using Arc =
typename FST::Arc;
432 owned_fst_.reset(&fst_);
439 match_type_(match_type),
442 state_table_(std::make_shared<StateTable>()) {
443 switch (match_type_) {
448 std::swap(loop_.ilabel, loop_.olabel);
451 FSTERROR() <<
"HashMatcher: Bad match type";
459 : owned_fst_(matcher.fst_.
Copy(safe)),
462 match_type_(matcher.match_type_),
463 loop_(matcher.loop_),
464 error_(matcher.error_),
465 state_table_(safe ? std::make_shared<StateTable>()
466 : matcher.state_table_) {}
478 current_loop_ = label == 0;
484 return Search(label);
488 if (current_loop_)
return false;
489 return label_it_ == label_end_;
493 if (current_loop_)
return loop_;
494 aiter_->Seek(label_it_->second);
495 return aiter_->Value();
500 current_loop_ =
false;
509 return inprops | (error_ ?
kError : 0);
513 Label GetLabel()
const {
514 const auto &arc = aiter_->Value();
515 return match_type_ ==
MATCH_INPUT ? arc.ilabel : arc.olabel;
518 bool Search(
Label match_label);
520 using LabelTable = std::unordered_multimap<Label, size_t>;
521 using StateTable = std::unordered_map<StateId, std::unique_ptr<LabelTable>>;
523 std::unique_ptr<const FST> owned_fst_;
530 std::unique_ptr<ArcIterator<FST>> aiter_;
531 std::shared_ptr<StateTable> state_table_;
532 LabelTable *label_table_;
533 typename LabelTable::iterator label_it_;
534 typename LabelTable::iterator label_end_;
539 if (state_ == s)
return;
542 loop_.nextstate = state_;
543 aiter_ = std::make_unique<ArcIterator<FST>>(fst_, state_);
545 FSTERROR() <<
"HashMatcher: Bad match type";
549 const auto &[it, success] =
550 state_table_->emplace(state_, std::make_unique<LabelTable>());
552 label_table_ = it->second.get();
554 if (!success)
return;
558 const auto aiter_flags =
561 aiter_->SetFlags(aiter_flags,
kArcFlags);
562 for (; !aiter_->Done(); aiter_->Next()) {
563 label_table_->emplace(GetLabel(), aiter_->Position());
570 std::tie(label_it_, label_end_) = label_table_->equal_range(match_label);
571 if (label_it_ == label_end_)
return false;
572 aiter_->Seek(label_it_->second);
602 using Arc =
typename FST::Arc;
609 bool phi_loop =
true,
611 M *matcher =
nullptr)
612 : matcher_(matcher ? matcher : new M(fst, match_type)),
613 match_type_(match_type),
614 phi_label_(phi_label),
619 FSTERROR() <<
"PhiMatcher: Bad match type";
624 rewrite_both_ = fst.Properties(
kAcceptor,
true);
626 rewrite_both_ =
true;
628 rewrite_both_ =
false;
634 bool phi_loop =
true,
636 M *matcher =
nullptr)
637 :
PhiMatcher(*fst, match_type, phi_label, phi_loop, rewrite_mode,
638 matcher ? matcher : new M(fst, match_type)) {}
642 : matcher_(new M(*matcher.matcher_, safe)),
643 match_type_(matcher.match_type_),
644 phi_label_(matcher.phi_label_),
645 rewrite_both_(matcher.rewrite_both_),
647 phi_loop_(matcher.phi_loop_),
648 error_(matcher.error_) {}
657 if (state_ == s)
return;
658 matcher_->SetState(s);
665 bool Done() const final {
return matcher_->Done(); }
668 if ((phi_match_ ==
kNoLabel) && (phi_weight_ == Weight::One())) {
669 return matcher_->Value();
670 }
else if (phi_match_ == 0) {
671 phi_arc_ =
Arc(
kNoLabel, 0, Weight::One(), state_);
673 std::swap(phi_arc_.ilabel, phi_arc_.olabel);
677 phi_arc_ = matcher_->Value();
678 phi_arc_.weight =
Times(phi_weight_, phi_arc_.weight);
681 if (phi_arc_.ilabel == phi_label_) phi_arc_.ilabel = phi_match_;
682 if (phi_arc_.olabel == phi_label_) phi_arc_.olabel = phi_match_;
684 phi_arc_.ilabel = phi_match_;
686 phi_arc_.olabel = phi_match_;
693 void Next() final { matcher_->Next(); }
696 auto weight = matcher_->Final(s);
697 if (phi_label_ ==
kNoLabel || weight != Weight::Zero()) {
700 weight = Weight::One();
701 matcher_->SetState(s);
702 while (matcher_->Final(s) == Weight::Zero()) {
703 if (!matcher_->Find(phi_label_ == 0 ? -1 : phi_label_))
break;
704 weight =
Times(weight, matcher_->Value().weight);
705 if (s == matcher_->Value().nextstate) {
706 return Weight::Zero();
708 s = matcher_->Value().nextstate;
709 matcher_->SetState(s);
711 weight =
Times(weight, matcher_->Final(s));
717 matcher_->SetState(s);
718 const bool has_phi = matcher_->Find(phi_label_ == 0 ? -1 : phi_label_);
719 return has_phi ? kRequirePriority : matcher_->Priority(s);
721 return matcher_->Priority(s);
725 const FST &
GetFst()
const override {
return matcher_->GetFst(); }
727 uint64_t
Properties(uint64_t props)
const override;
731 return matcher_->Flags();
739 mutable std::unique_ptr<M> matcher_;
745 mutable Arc phi_arc_;
757 if (label == phi_label_ && phi_label_ !=
kNoLabel && phi_label_ != 0) {
758 FSTERROR() <<
"PhiMatcher::Find: bad label (phi): " << phi_label_;
762 matcher_->SetState(state_);
764 phi_weight_ = Weight::One();
766 if (phi_label_ == 0) {
772 return matcher_->Find(0);
779 if (!has_phi_ || label == 0 || label ==
kNoLabel) {
780 return matcher_->Find(label);
783 while (!matcher_->Find(label)) {
786 if (!matcher_->Find(phi_label_ == 0 ? -1 : phi_label_))
return false;
787 if (phi_loop_ && matcher_->Value().nextstate == s) {
791 phi_weight_ =
Times(phi_weight_, matcher_->Value().weight);
792 s = matcher_->Value().nextstate;
794 if (!matcher_->Done()) {
795 FSTERROR() <<
"PhiMatcher: Phi non-determinism not supported";
798 matcher_->SetState(s);
805 auto outprops = matcher_->Properties(inprops);
806 if (error_) outprops |=
kError;
810 if (phi_label_ == 0) {
824 if (phi_label_ == 0) {
839 FSTERROR() <<
"PhiMatcher: Bad match type: " << match_type_;
861 using Arc =
typename FST::Arc;
869 M *matcher =
nullptr)
870 : matcher_(matcher ? matcher : new M(fst, match_type)),
871 match_type_(match_type),
872 rho_label_(rho_label),
877 FSTERROR() <<
"RhoMatcher: Bad match type";
881 if (rho_label == 0) {
882 FSTERROR() <<
"RhoMatcher: 0 cannot be used as rho_label";
887 rewrite_both_ = fst.Properties(
kAcceptor,
true);
889 rewrite_both_ =
true;
891 rewrite_both_ =
false;
898 M *matcher =
nullptr)
899 :
RhoMatcher(*fst, match_type, rho_label, rewrite_mode,
900 matcher ? matcher : new M(fst, match_type)) {}
904 : matcher_(new M(*matcher.matcher_, safe)),
905 match_type_(matcher.match_type_),
906 rho_label_(matcher.rho_label_),
907 rewrite_both_(matcher.rewrite_both_),
908 error_(matcher.error_),
919 if (state_ == s)
return;
921 matcher_->SetState(s);
926 if (label == rho_label_ && rho_label_ !=
kNoLabel) {
927 FSTERROR() <<
"RhoMatcher::Find: bad label (rho)";
931 if (matcher_->Find(label)) {
934 }
else if (has_rho_ && label != 0 && label !=
kNoLabel &&
935 (has_rho_ = matcher_->Find(rho_label_))) {
943 bool Done() const final {
return matcher_->Done(); }
947 return matcher_->Value();
949 rho_arc_ = matcher_->Value();
951 if (rho_arc_.ilabel == rho_label_) rho_arc_.ilabel = rho_match_;
952 if (rho_arc_.olabel == rho_label_) rho_arc_.olabel = rho_match_;
954 rho_arc_.ilabel = rho_match_;
956 rho_arc_.olabel = rho_match_;
962 void Next() final { matcher_->Next(); }
968 matcher_->SetState(s);
969 has_rho_ = matcher_->Find(rho_label_);
973 return matcher_->Priority(s);
977 const FST &
GetFst()
const override {
return matcher_->GetFst(); }
979 uint64_t
Properties(uint64_t props)
const override;
983 return matcher_->Flags();
991 std::unique_ptr<M> matcher_;
996 mutable Arc rho_arc_;
1004 auto outprops = matcher_->Properties(inprops);
1005 if (error_) outprops |=
kError;
1009 if (rewrite_both_) {
1018 if (rewrite_both_) {
1028 FSTERROR() <<
"RhoMatcher: Bad match type: " << match_type_;
1050 using Arc =
typename FST::Arc;
1059 M *matcher =
nullptr)
1060 : matcher_(matcher ? matcher : new M(fst, match_type)),
1061 match_type_(match_type),
1062 sigma_label_(sigma_label),
1066 FSTERROR() <<
"SigmaMatcher: Bad match type";
1070 if (sigma_label == 0) {
1071 FSTERROR() <<
"SigmaMatcher: 0 cannot be used as sigma_label";
1076 rewrite_both_ = fst.Properties(
kAcceptor,
true);
1078 rewrite_both_ =
true;
1080 rewrite_both_ =
false;
1088 M *matcher =
nullptr)
1089 :
SigmaMatcher(*fst, match_type, sigma_label, rewrite_mode,
1090 matcher ? matcher : new M(fst, match_type)) {}
1094 : matcher_(new M(*matcher.matcher_, safe)),
1095 match_type_(matcher.match_type_),
1096 sigma_label_(matcher.sigma_label_),
1097 rewrite_both_(matcher.rewrite_both_),
1098 error_(matcher.error_),
1108 if (state_ == s)
return;
1110 matcher_->SetState(s);
1112 (sigma_label_ !=
kNoLabel) ? matcher_->Find(sigma_label_) :
false;
1116 match_label_ = match_label;
1117 if (match_label == sigma_label_ && sigma_label_ !=
kNoLabel) {
1118 FSTERROR() <<
"SigmaMatcher::Find: bad label (sigma)";
1122 if (matcher_->Find(match_label)) {
1125 }
else if (has_sigma_ && match_label != 0 && match_label !=
kNoLabel &&
1126 matcher_->Find(sigma_label_)) {
1127 sigma_match_ = match_label;
1134 bool Done() const final {
return matcher_->Done(); }
1138 return matcher_->Value();
1140 sigma_arc_ = matcher_->Value();
1141 if (rewrite_both_) {
1142 if (sigma_arc_.ilabel == sigma_label_) sigma_arc_.ilabel = sigma_match_;
1143 if (sigma_arc_.olabel == sigma_label_) sigma_arc_.olabel = sigma_match_;
1145 sigma_arc_.ilabel = sigma_match_;
1147 sigma_arc_.olabel = sigma_match_;
1155 if (matcher_->Done() && has_sigma_ && (sigma_match_ ==
kNoLabel) &&
1156 (match_label_ > 0)) {
1157 matcher_->Find(sigma_label_);
1158 sigma_match_ = match_label_;
1167 return has_sigma_ ? kRequirePriority : matcher_->Priority(s);
1169 return matcher_->Priority(s);
1173 const FST &
GetFst()
const override {
return matcher_->GetFst(); }
1175 uint64_t
Properties(uint64_t props)
const override;
1179 return matcher_->Flags();
1187 std::unique_ptr<M> matcher_;
1193 mutable Arc sigma_arc_;
1201 auto outprops = matcher_->Properties(inprops);
1202 if (error_) outprops |=
kError;
1205 }
else if (rewrite_both_) {
1219 FSTERROR() <<
"SigmaMatcher: Bad match type: " << match_type_;
1243 using Arc =
typename FST::Arc;
1250 uint32_t flags = (kMultiEpsLoop | kMultiEpsList),
1251 M *matcher =
nullptr,
bool own_matcher =
true)
1252 : matcher_(matcher ? matcher : new M(fst, match_type)),
1254 own_matcher_(matcher ? own_matcher : true) {
1260 uint32_t flags = (kMultiEpsLoop | kMultiEpsList),
1261 M *matcher =
nullptr,
bool own_matcher =
true)
1262 : matcher_(matcher ? matcher : new M(fst, match_type)),
1264 own_matcher_(matcher ? own_matcher : true) {
1270 : matcher_(new M(*matcher.matcher_, safe)),
1271 flags_(matcher.flags_),
1273 multi_eps_labels_(matcher.multi_eps_labels_),
1274 loop_(matcher.loop_) {
1279 if (own_matcher_)
delete matcher_;
1289 matcher_->SetState(state);
1290 loop_.nextstate = state;
1295 bool Done()
const {
return done_; }
1297 const Arc &
Value()
const {
return current_loop_ ? loop_ : matcher_->Value(); }
1300 if (!current_loop_) {
1302 done_ = matcher_->Done();
1303 if (done_ && multi_eps_iter_ != multi_eps_labels_.End()) {
1305 while ((multi_eps_iter_ != multi_eps_labels_.End()) &&
1306 !matcher_->Find(*multi_eps_iter_)) {
1309 if (multi_eps_iter_ != multi_eps_labels_.End()) {
1323 return matcher_->Properties(props);
1330 uint32_t
Flags()
const {
return matcher_->Flags(); }
1336 FSTERROR() <<
"MultiEpsMatcher: Bad multi-eps label: 0";
1338 multi_eps_labels_.Insert(label);
1344 FSTERROR() <<
"MultiEpsMatcher: Bad multi-eps label: 0";
1346 multi_eps_labels_.Erase(label);
1361 loop_.weight = Weight::One();
1382 multi_eps_iter_ = multi_eps_labels_.End();
1383 current_loop_ =
false;
1386 ret = matcher_->Find(0);
1388 if (flags_ & kMultiEpsList) {
1390 multi_eps_iter_ = multi_eps_labels_.Begin();
1391 while ((multi_eps_iter_ != multi_eps_labels_.End()) &&
1392 !matcher_->Find(*multi_eps_iter_)) {
1395 if (multi_eps_iter_ != multi_eps_labels_.End()) {
1404 }
else if ((flags_ & kMultiEpsLoop) &&
1405 multi_eps_labels_.Find(label) != multi_eps_labels_.End()) {
1407 current_loop_ =
true;
1410 ret = matcher_->Find(label);
1427 using Arc =
typename FST::Arc;
1434 : matcher_(matcher ? matcher : new M(fst, match_type)),
1435 match_type_(match_type),
1440 : matcher_(matcher ? matcher : new M(fst, match_type)),
1441 match_type_(match_type),
1446 : matcher_(new M(*matcher.matcher_, safe)),
1447 match_type_(matcher.match_type_),
1448 error_(matcher.error_) {}
1459 matcher_->Find(label);
1464 bool Done() const final {
return matcher_->Done(); }
1466 const Arc &
Value() const final {
return matcher_->Value(); }
1477 const FST &
GetFst() const final {
return matcher_->GetFst(); }
1480 return matcher_->Properties(inprops);
1485 uint32_t
Flags()
const override {
return matcher_->Flags(); }
1491 for (; !matcher_->Done(); matcher_->Next()) {
1492 const auto label = match_type_ ==
MATCH_INPUT ? matcher_->Value().ilabel
1493 : matcher_->Value().olabel;
1498 std::unique_ptr<M> matcher_;
1525 : owned_fst_(fst.
Copy()), base_(owned_fst_->InitMatcher(match_type)) {
1528 std::make_unique<SortedMatcher<FST>>(owned_fst_.get(), match_type);
1533 : base_(fst->InitMatcher(match_type)) {
1534 if (!base_) base_ = std::make_unique<SortedMatcher<FST>>(fst, match_type);
1539 : base_(matcher.base_->
Copy(safe)) {}
1552 bool Done()
const {
return base_->Done(); }
1560 uint64_t
Properties(uint64_t props)
const {
return base_->Properties(props); }
1569 std::unique_ptr<const FST> owned_fst_;
1570 std::unique_ptr<MatcherBase<Arc>> base_;
1575 #endif // FST_MATCHER_H_ bool Find(Label label) final
MatchType Type(bool test) const
void SetState(StateId s) final
RhoMatcher(const RhoMatcher &matcher, bool safe=false)
Weight Final(StateId s) const final
const Arc & Value() const final
void SetState(StateId s) final
constexpr uint8_t kArcValueFlags
virtual uint64_t Properties(uint64_t) const =0
constexpr ssize_t kRequirePriority
typename typename Filter::Matcher2::FST FST
Matcher(const FST &fst, MatchType match_type)
const FST & GetFst() const
void AddMultiEpsLabel(Label label)
typename Arc::Label Label
constexpr uint8_t kArcNoCache
SortedMatcher * Copy(bool safe=false) const override
constexpr uint64_t kOEpsilons
uint32_t Flags() const override
ssize_t Priority(StateId s) final
const Arc & Value() const final
ExplicitMatcher(const FST *fst, MatchType match_type, M *matcher=nullptr)
void LowerBound(Label label)
typename Arc::Label Label
PhiMatcher * Copy(bool safe=false) const override
const Arc & Value() const final
MatchType Type(bool test) const override
ssize_t Priority(StateId s) final
uint64_t Properties(uint64_t props) const
const M * GetMatcher() const
uint64_t Properties(uint64_t props) const override
SigmaMatcher(const SigmaMatcher &matcher, bool safe=false)
Arc::Weight Final(const ExpandedFst< Arc > &fst, typename Arc::StateId s)
constexpr uint32_t kMultiEpsList
constexpr uint8_t kArcFlags
ErrorWeight Times(const ErrorWeight &, const ErrorWeight &)
constexpr uint64_t kError
PhiMatcher(const FST *fst, MatchType match_type, Label phi_label=kNoLabel, bool phi_loop=true, MatcherRewriteMode rewrite_mode=MATCHER_REWRITE_AUTO, M *matcher=nullptr)
Weight Final(StateId s) const
uint64_t Properties(uint64_t props) const override
bool Find(Label label) final
typename Arc::StateId StateId
virtual bool Find(Label)=0
typename Arc::Label Label
uint64_t Properties(uint64_t props) const
MatchType Type(bool test) const override
Weight Final(StateId s) const final
Matcher(const Matcher &matcher, bool safe=false)
SigmaMatcher(const FST &fst, MatchType match_type, Label sigma_label=kNoLabel, MatcherRewriteMode rewrite_mode=MATCHER_REWRITE_AUTO, M *matcher=nullptr)
ExplicitMatcher(const ExplicitMatcher &matcher, bool safe=false)
ExplicitMatcher * Copy(bool safe=false) const override
void SetState(StateId s) final
const FST & GetFst() const override
void SetState(StateId s) final
constexpr uint8_t kArcILabelValue
constexpr uint64_t kEpsilons
ssize_t NumArcs(const ExpandedFst< Arc > &fst, typename Arc::StateId s)
constexpr uint64_t kNotOLabelSorted
HashMatcher * Copy(bool safe=false) const override
ExplicitMatcher(const FST &fst, MatchType match_type, M *matcher=nullptr)
typename Arc::Weight Weight
uint32_t Flags() const override
MatchType Type(bool test) const override
void SetState(StateId state)
PhiMatcher(const PhiMatcher &matcher, bool safe=false)
RhoMatcher(const FST &fst, MatchType match_type, Label rho_label=kNoLabel, MatcherRewriteMode rewrite_mode=MATCHER_REWRITE_AUTO, M *matcher=nullptr)
typename Arc::StateId StateId
constexpr uint64_t kODeterministic
MultiEpsMatcher(const FST *fst, MatchType match_type, uint32_t flags=(kMultiEpsLoop|kMultiEpsList), M *matcher=nullptr, bool own_matcher=true)
typename Arc::Weight Weight
typename Arc::StateId StateId
void RemoveMultiEpsLabel(Label label)
MatchType Type(bool test) const
uint32_t Flags() const override
constexpr uint32_t kMultiEpsLoop
const FST & GetFst() const override
constexpr uint64_t kNonIDeterministic
const Arc & Value() const
typename Arc::Label Label
const Arc & Value() const final
virtual uint32_t Flags() const
MatchType Type(bool test) const override
constexpr uint64_t kNotILabelSorted
bool Find(Label label) final
bool Find(Label match_label) final
virtual ssize_t Priority(StateId s)
virtual Weight Final(StateId s) const
typename Arc::StateId StateId
constexpr uint64_t kNoOEpsilons
const M * GetMatcher() const
constexpr uint64_t kOLabelSorted
Weight Final(StateId s) const final
virtual void SetState(StateId)=0
ssize_t Priority(StateId s)
constexpr uint64_t kNoEpsilons
const Arc & Value() const final
Matcher(const FST *fst, MatchType match_type)
const FST & GetFst() const override
constexpr uint8_t kArcOLabelValue
Weight Final(StateId s) const final
RhoMatcher * Copy(bool safe=false) const override
Matcher * Copy(bool safe=false) const
void SetState(StateId s) final
constexpr uint64_t kIDeterministic
typename Arc::StateId StateId
virtual const Fst< Arc > & GetFst() const =0
Matcher(MatcherBase< Arc > *base_matcher)
bool Find(Label match_label) final
constexpr uint64_t kIEpsilons
const FST & GetFst() const override
uint32_t Flags() const override
HashMatcher(const HashMatcher &matcher, bool safe=false)
SigmaMatcher * Copy(bool safe=false) const override
void ClearMultiEpsLabels()
constexpr uint64_t kILabelSorted
ssize_t Priority(StateId s) final
SortedMatcher(const FST &fst, MatchType match_type, Label binary_label=1)
void SetState(StateId s) final
MultiEpsMatcher(const MultiEpsMatcher &matcher, bool safe=false)
virtual MatcherBase * Copy(bool safe=false) const =0
ssize_t Priority(StateId s) final
constexpr uint64_t kNonODeterministic
ssize_t Priority(StateId s) final
const FST & GetFst() const final
constexpr uint32_t kMatcherFlags
typename Arc::Weight Weight
SortedMatcher(const FST *fst, MatchType match_type, Label binary_label=1)
typename Arc::Weight Weight
SortedMatcher(const SortedMatcher &matcher, bool safe=false)
const FST & GetFst() const override
uint64_t Properties(uint64_t props) const override
typename Arc::Weight Weight
constexpr uint64_t kString
typename Arc::Label Label
virtual MatchType Type(bool) const =0
Weight Final(StateId s) const final
SigmaMatcher(const FST *fst, MatchType match_type, Label sigma_label=kNoLabel, MatcherRewriteMode rewrite_mode=MATCHER_REWRITE_AUTO, M *matcher=nullptr)
HashMatcher(const FST &fst, MatchType match_type)
PhiMatcher(const FST &fst, MatchType match_type, Label phi_label=kNoLabel, bool phi_loop=true, MatcherRewriteMode rewrite_mode=MATCHER_REWRITE_AUTO, M *matcher=nullptr)
MatchType Type(bool test) const override
ssize_t Priority(StateId s)
typename Arc::Weight Weight
const Arc & Value() const
typename Arc::Label Label
MatchType Type(bool test) const override
typename Arc::Label Label
typename Arc::Weight Weight
typename Arc::Label Label
typename Arc::StateId StateId
MultiEpsMatcher(const FST &fst, MatchType match_type, uint32_t flags=(kMultiEpsLoop|kMultiEpsList), M *matcher=nullptr, bool own_matcher=true)
uint64_t Properties(uint64_t inprops) const override
typename Arc::Weight Weight
constexpr uint64_t kNoIEpsilons
bool Find(Label match_label) final
MultiEpsMatcher * Copy(bool safe=false) const
uint64_t Properties(uint64_t inprops) const override
uint64_t Properties(uint64_t inprops) const override
RhoMatcher(const FST *fst, MatchType match_type, Label rho_label=kNoLabel, MatcherRewriteMode rewrite_mode=MATCHER_REWRITE_AUTO, M *matcher=nullptr)
HashMatcher(const FST *fst, MatchType match_type)
virtual bool Done() const =0
virtual const Arc & Value() const =0
const Arc & Value() const final
constexpr uint64_t kAcceptor
Weight Final(StateId s) const
const FST & GetFst() const
typename Arc::StateId StateId
constexpr uint32_t kRequireMatch
typename Arc::StateId StateId