20 #ifndef FST_MATCHER_H_ 21 #define FST_MATCHER_H_ 23 #include <sys/types.h> 32 #include <unordered_map> 40 #include <unordered_map> 155 virtual bool Done()
const = 0;
156 virtual const Arc &
Value()
const = 0;
157 virtual void Next() = 0;
159 virtual uint64_t
Properties(uint64_t)
const = 0;
163 virtual uint32_t
Flags()
const {
return 0; }
179 using Arc =
typename FST::Arc;
192 owned_fst_.reset(&fst_);
201 aiter_(std::nullopt),
202 match_type_(match_type),
203 binary_label_(binary_label),
208 switch (match_type_) {
213 std::swap(loop_.ilabel, loop_.olabel);
216 FSTERROR() <<
"SortedMatcher: Bad match type";
224 : owned_fst_(matcher.fst_.
Copy(safe)),
227 aiter_(std::nullopt),
228 match_type_(matcher.match_type_),
229 binary_label_(matcher.binary_label_),
232 loop_(matcher.loop_),
233 error_(matcher.error_) {}
242 if (match_type_ ==
MATCH_NONE)
return match_type_;
243 const auto true_prop =
245 const auto false_prop =
247 const auto props = fst_.Properties(true_prop | false_prop, test);
248 if (props & true_prop) {
250 }
else if (props & false_prop) {
258 if (state_ == s)
return;
261 FSTERROR() <<
"SortedMatcher: Bad match type";
264 aiter_.emplace(fst_, s);
273 current_loop_ =
false;
277 current_loop_ = match_label == 0;
278 match_label_ = match_label ==
kNoLabel ? 0 : match_label;
282 return current_loop_;
289 exact_match_ =
false;
290 current_loop_ =
false;
295 match_label_ = label;
302 if (current_loop_)
return false;
303 if (aiter_->Done())
return true;
304 if (!exact_match_)
return false;
308 return GetLabel() != match_label_;
312 if (current_loop_)
return loop_;
314 return aiter_->Value();
319 current_loop_ =
false;
332 return inprops | (error_ ?
kError : 0);
335 size_t Position()
const {
return aiter_ ? aiter_->Position() : 0; }
338 Label GetLabel()
const {
339 const auto &arc = aiter_->Value();
340 return match_type_ ==
MATCH_INPUT ? arc.ilabel : arc.olabel;
347 std::unique_ptr<const FST> owned_fst_;
350 mutable std::optional<ArcIterator<FST>>
369 size_t size = narcs_;
373 size_t high = size - 1;
375 const size_t half = size / 2;
376 const size_t mid = high - half;
378 if (GetLabel() >= match_label_) {
384 const auto label = GetLabel();
385 if (label == match_label_) {
388 if (label < match_label_) {
398 for (aiter_->Reset(); !aiter_->Done(); aiter_->Next()) {
399 const auto label = GetLabel();
400 if (label == match_label_)
return true;
401 if (label > match_label_)
break;
413 if (match_label_ >= binary_label_) {
414 return BinarySearch();
416 return LinearSearch();
427 using Arc =
typename FST::Arc;
439 owned_fst_.reset(&fst_);
446 match_type_(match_type),
449 state_table_(std::make_shared<StateTable>()) {
450 switch (match_type_) {
455 std::swap(loop_.ilabel, loop_.olabel);
458 FSTERROR() <<
"HashMatcher: Bad match type";
466 : owned_fst_(matcher.fst_.
Copy(safe)),
469 match_type_(matcher.match_type_),
470 loop_(matcher.loop_),
471 error_(matcher.error_),
472 state_table_(safe ? std::make_shared<StateTable>()
473 : matcher.state_table_) {}
485 current_loop_ = label == 0;
491 return Search(label);
495 if (current_loop_)
return false;
496 return label_it_ == label_end_;
500 if (current_loop_)
return loop_;
501 aiter_->Seek(label_it_->second);
502 return aiter_->Value();
507 current_loop_ =
false;
516 return inprops | (error_ ?
kError : 0);
520 Label GetLabel()
const {
521 const auto &arc = aiter_->Value();
522 return match_type_ ==
MATCH_INPUT ? arc.ilabel : arc.olabel;
525 bool Search(
Label match_label);
527 using LabelTable = std::unordered_multimap<Label, size_t>;
528 using StateTable = std::unordered_map<StateId, std::unique_ptr<LabelTable>>;
530 std::unique_ptr<const FST> owned_fst_;
537 std::unique_ptr<ArcIterator<FST>> aiter_;
538 std::shared_ptr<StateTable> state_table_;
539 LabelTable *label_table_;
540 typename LabelTable::iterator label_it_;
541 typename LabelTable::iterator label_end_;
546 if (state_ == s)
return;
549 loop_.nextstate = state_;
550 aiter_ = std::make_unique<ArcIterator<FST>>(fst_, state_);
552 FSTERROR() <<
"HashMatcher: Bad match type";
556 const auto &[it, success] =
557 state_table_->emplace(state_, std::make_unique<LabelTable>());
559 label_table_ = it->second.get();
561 if (!success)
return;
565 const auto aiter_flags =
568 aiter_->SetFlags(aiter_flags,
kArcFlags);
569 for (; !aiter_->Done(); aiter_->Next()) {
570 label_table_->emplace(GetLabel(), aiter_->Position());
577 std::tie(label_it_, label_end_) = label_table_->equal_range(match_label);
578 if (label_it_ == label_end_)
return false;
579 aiter_->Seek(label_it_->second);
609 using Arc =
typename FST::Arc;
616 bool phi_loop =
true,
618 M *matcher =
nullptr)
619 : matcher_(matcher ? matcher : new M(fst, match_type)),
620 match_type_(match_type),
621 phi_label_(phi_label),
626 FSTERROR() <<
"PhiMatcher: Bad match type";
631 rewrite_both_ = fst.Properties(
kAcceptor,
true);
633 rewrite_both_ =
true;
635 rewrite_both_ =
false;
641 bool phi_loop =
true,
643 M *matcher =
nullptr)
644 :
PhiMatcher(*fst, match_type, phi_label, phi_loop, rewrite_mode,
645 matcher ? matcher : new M(fst, match_type)) {}
649 : matcher_(new M(*matcher.matcher_, safe)),
650 match_type_(matcher.match_type_),
651 phi_label_(matcher.phi_label_),
652 rewrite_both_(matcher.rewrite_both_),
654 phi_loop_(matcher.phi_loop_),
655 error_(matcher.error_) {}
664 if (state_ == s)
return;
665 matcher_->SetState(s);
672 bool Done() const final {
return matcher_->Done(); }
675 if ((phi_match_ ==
kNoLabel) && (phi_weight_ == Weight::One())) {
676 return matcher_->Value();
677 }
else if (phi_match_ == 0) {
678 phi_arc_ =
Arc(
kNoLabel, 0, Weight::One(), state_);
680 std::swap(phi_arc_.ilabel, phi_arc_.olabel);
684 phi_arc_ = matcher_->Value();
685 phi_arc_.weight =
Times(phi_weight_, phi_arc_.weight);
688 if (phi_arc_.ilabel == phi_label_) phi_arc_.ilabel = phi_match_;
689 if (phi_arc_.olabel == phi_label_) phi_arc_.olabel = phi_match_;
691 phi_arc_.ilabel = phi_match_;
693 phi_arc_.olabel = phi_match_;
700 void Next() final { matcher_->Next(); }
703 auto weight = matcher_->Final(s);
704 if (phi_label_ ==
kNoLabel || weight != Weight::Zero()) {
707 weight = Weight::One();
708 matcher_->SetState(s);
709 while (matcher_->Final(s) == Weight::Zero()) {
710 if (!matcher_->Find(phi_label_ == 0 ? -1 : phi_label_))
break;
711 weight =
Times(weight, matcher_->Value().weight);
712 if (s == matcher_->Value().nextstate) {
713 return Weight::Zero();
715 s = matcher_->Value().nextstate;
716 matcher_->SetState(s);
718 weight =
Times(weight, matcher_->Final(s));
724 matcher_->SetState(s);
725 const bool has_phi = matcher_->Find(phi_label_ == 0 ? -1 : phi_label_);
726 return has_phi ? kRequirePriority : matcher_->Priority(s);
728 return matcher_->Priority(s);
732 const FST &
GetFst()
const override {
return matcher_->GetFst(); }
734 uint64_t
Properties(uint64_t props)
const override;
738 return matcher_->Flags();
746 mutable std::unique_ptr<M> matcher_;
752 mutable Arc phi_arc_;
764 if (label == phi_label_ && phi_label_ !=
kNoLabel && phi_label_ != 0) {
765 FSTERROR() <<
"PhiMatcher::Find: bad label (phi): " << phi_label_;
769 matcher_->SetState(state_);
771 phi_weight_ = Weight::One();
773 if (phi_label_ == 0) {
779 return matcher_->Find(0);
786 if (!has_phi_ || label == 0 || label ==
kNoLabel) {
787 return matcher_->Find(label);
790 while (!matcher_->Find(label)) {
793 if (!matcher_->Find(phi_label_ == 0 ? -1 : phi_label_))
return false;
794 if (phi_loop_ && matcher_->Value().nextstate == s) {
798 phi_weight_ =
Times(phi_weight_, matcher_->Value().weight);
799 s = matcher_->Value().nextstate;
801 if (!matcher_->Done()) {
802 FSTERROR() <<
"PhiMatcher: Phi non-determinism not supported";
805 matcher_->SetState(s);
812 auto outprops = matcher_->Properties(inprops);
813 if (error_) outprops |=
kError;
817 if (phi_label_ == 0) {
831 if (phi_label_ == 0) {
846 FSTERROR() <<
"PhiMatcher: Bad match type: " << match_type_;
868 using Arc =
typename FST::Arc;
876 M *matcher =
nullptr)
877 : matcher_(matcher ? matcher : new M(fst, match_type)),
878 match_type_(match_type),
879 rho_label_(rho_label),
884 FSTERROR() <<
"RhoMatcher: Bad match type";
888 if (rho_label == 0) {
889 FSTERROR() <<
"RhoMatcher: 0 cannot be used as rho_label";
894 rewrite_both_ = fst.Properties(
kAcceptor,
true);
896 rewrite_both_ =
true;
898 rewrite_both_ =
false;
905 M *matcher =
nullptr)
906 :
RhoMatcher(*fst, match_type, rho_label, rewrite_mode,
907 matcher ? matcher : new M(fst, match_type)) {}
911 : matcher_(new M(*matcher.matcher_, safe)),
912 match_type_(matcher.match_type_),
913 rho_label_(matcher.rho_label_),
914 rewrite_both_(matcher.rewrite_both_),
915 error_(matcher.error_),
926 if (state_ == s)
return;
928 matcher_->SetState(s);
933 if (label == rho_label_ && rho_label_ !=
kNoLabel) {
934 FSTERROR() <<
"RhoMatcher::Find: bad label (rho)";
938 if (matcher_->Find(label)) {
941 }
else if (has_rho_ && label != 0 && label !=
kNoLabel &&
942 (has_rho_ = matcher_->Find(rho_label_))) {
950 bool Done() const final {
return matcher_->Done(); }
954 return matcher_->Value();
956 rho_arc_ = matcher_->Value();
958 if (rho_arc_.ilabel == rho_label_) rho_arc_.ilabel = rho_match_;
959 if (rho_arc_.olabel == rho_label_) rho_arc_.olabel = rho_match_;
961 rho_arc_.ilabel = rho_match_;
963 rho_arc_.olabel = rho_match_;
969 void Next() final { matcher_->Next(); }
975 matcher_->SetState(s);
976 has_rho_ = matcher_->Find(rho_label_);
980 return matcher_->Priority(s);
984 const FST &
GetFst()
const override {
return matcher_->GetFst(); }
986 uint64_t
Properties(uint64_t props)
const override;
990 return matcher_->Flags();
998 std::unique_ptr<M> matcher_;
1003 mutable Arc rho_arc_;
1011 auto outprops = matcher_->Properties(inprops);
1012 if (error_) outprops |=
kError;
1016 if (rewrite_both_) {
1025 if (rewrite_both_) {
1035 FSTERROR() <<
"RhoMatcher: Bad match type: " << match_type_;
1057 using Arc =
typename FST::Arc;
1066 M *matcher =
nullptr)
1067 : matcher_(matcher ? matcher : new M(fst, match_type)),
1068 match_type_(match_type),
1069 sigma_label_(sigma_label),
1073 FSTERROR() <<
"SigmaMatcher: Bad match type";
1077 if (sigma_label == 0) {
1078 FSTERROR() <<
"SigmaMatcher: 0 cannot be used as sigma_label";
1083 rewrite_both_ = fst.Properties(
kAcceptor,
true);
1085 rewrite_both_ =
true;
1087 rewrite_both_ =
false;
1095 M *matcher =
nullptr)
1096 :
SigmaMatcher(*fst, match_type, sigma_label, rewrite_mode,
1097 matcher ? matcher : new M(fst, match_type)) {}
1101 : matcher_(new M(*matcher.matcher_, safe)),
1102 match_type_(matcher.match_type_),
1103 sigma_label_(matcher.sigma_label_),
1104 rewrite_both_(matcher.rewrite_both_),
1105 error_(matcher.error_),
1115 if (state_ == s)
return;
1117 matcher_->SetState(s);
1119 (sigma_label_ !=
kNoLabel) ? matcher_->Find(sigma_label_) :
false;
1123 match_label_ = match_label;
1124 if (match_label == sigma_label_ && sigma_label_ !=
kNoLabel) {
1125 FSTERROR() <<
"SigmaMatcher::Find: bad label (sigma)";
1129 if (matcher_->Find(match_label)) {
1132 }
else if (has_sigma_ && match_label != 0 && match_label !=
kNoLabel &&
1133 matcher_->Find(sigma_label_)) {
1134 sigma_match_ = match_label;
1141 bool Done() const final {
return matcher_->Done(); }
1145 return matcher_->Value();
1147 sigma_arc_ = matcher_->Value();
1148 if (rewrite_both_) {
1149 if (sigma_arc_.ilabel == sigma_label_) sigma_arc_.ilabel = sigma_match_;
1150 if (sigma_arc_.olabel == sigma_label_) sigma_arc_.olabel = sigma_match_;
1152 sigma_arc_.ilabel = sigma_match_;
1154 sigma_arc_.olabel = sigma_match_;
1162 if (matcher_->Done() && has_sigma_ && (sigma_match_ ==
kNoLabel) &&
1163 (match_label_ > 0)) {
1164 matcher_->Find(sigma_label_);
1165 sigma_match_ = match_label_;
1174 return has_sigma_ ? kRequirePriority : matcher_->Priority(s);
1176 return matcher_->Priority(s);
1180 const FST &
GetFst()
const override {
return matcher_->GetFst(); }
1182 uint64_t
Properties(uint64_t props)
const override;
1186 return matcher_->Flags();
1194 std::unique_ptr<M> matcher_;
1200 mutable Arc sigma_arc_;
1208 auto outprops = matcher_->Properties(inprops);
1209 if (error_) outprops |=
kError;
1212 }
else if (rewrite_both_) {
1226 FSTERROR() <<
"SigmaMatcher: Bad match type: " << match_type_;
1250 using Arc =
typename FST::Arc;
1257 uint32_t flags = (kMultiEpsLoop | kMultiEpsList),
1258 M *matcher =
nullptr,
bool own_matcher =
true)
1259 : matcher_(matcher ? matcher : new M(fst, match_type)),
1261 own_matcher_(matcher ? own_matcher : true) {
1267 uint32_t flags = (kMultiEpsLoop | kMultiEpsList),
1268 M *matcher =
nullptr,
bool own_matcher =
true)
1269 : matcher_(matcher ? matcher : new M(fst, match_type)),
1271 own_matcher_(matcher ? own_matcher : true) {
1277 : matcher_(new M(*matcher.matcher_, safe)),
1278 flags_(matcher.flags_),
1280 multi_eps_labels_(matcher.multi_eps_labels_),
1281 loop_(matcher.loop_) {
1286 if (own_matcher_)
delete matcher_;
1296 matcher_->SetState(state);
1297 loop_.nextstate = state;
1302 bool Done()
const {
return done_; }
1304 const Arc &
Value()
const {
return current_loop_ ? loop_ : matcher_->Value(); }
1307 if (!current_loop_) {
1309 done_ = matcher_->Done();
1310 if (done_ && multi_eps_iter_ != multi_eps_labels_.End()) {
1312 while ((multi_eps_iter_ != multi_eps_labels_.End()) &&
1313 !matcher_->Find(*multi_eps_iter_)) {
1316 if (multi_eps_iter_ != multi_eps_labels_.End()) {
1330 return matcher_->Properties(props);
1337 uint32_t
Flags()
const {
return matcher_->Flags(); }
1343 FSTERROR() <<
"MultiEpsMatcher: Bad multi-eps label: 0";
1345 multi_eps_labels_.Insert(label);
1351 FSTERROR() <<
"MultiEpsMatcher: Bad multi-eps label: 0";
1353 multi_eps_labels_.Erase(label);
1368 loop_.weight = Weight::One();
1389 multi_eps_iter_ = multi_eps_labels_.End();
1390 current_loop_ =
false;
1393 ret = matcher_->Find(0);
1395 if (flags_ & kMultiEpsList) {
1397 multi_eps_iter_ = multi_eps_labels_.Begin();
1398 while ((multi_eps_iter_ != multi_eps_labels_.End()) &&
1399 !matcher_->Find(*multi_eps_iter_)) {
1402 if (multi_eps_iter_ != multi_eps_labels_.End()) {
1411 }
else if ((flags_ & kMultiEpsLoop) &&
1412 multi_eps_labels_.Find(label) != multi_eps_labels_.End()) {
1414 current_loop_ =
true;
1417 ret = matcher_->Find(label);
1434 using Arc =
typename FST::Arc;
1441 : matcher_(matcher ? matcher : new M(fst, match_type)),
1442 match_type_(match_type),
1447 : matcher_(matcher ? matcher : new M(fst, match_type)),
1448 match_type_(match_type),
1453 : matcher_(new M(*matcher.matcher_, safe)),
1454 match_type_(matcher.match_type_),
1455 error_(matcher.error_) {}
1466 matcher_->Find(label);
1471 bool Done() const final {
return matcher_->Done(); }
1473 const Arc &
Value() const final {
return matcher_->Value(); }
1484 const FST &
GetFst() const final {
return matcher_->GetFst(); }
1487 return matcher_->Properties(inprops);
1492 uint32_t
Flags()
const override {
return matcher_->Flags(); }
1498 for (; !matcher_->Done(); matcher_->Next()) {
1499 const auto label = match_type_ ==
MATCH_INPUT ? matcher_->Value().ilabel
1500 : matcher_->Value().olabel;
1505 std::unique_ptr<M> matcher_;
1532 : owned_fst_(fst.
Copy()), base_(owned_fst_->InitMatcher(match_type)) {
1535 std::make_unique<SortedMatcher<FST>>(owned_fst_.get(), match_type);
1540 : base_(fst->InitMatcher(match_type)) {
1541 if (!base_) base_ = std::make_unique<SortedMatcher<FST>>(fst, match_type);
1546 : base_(matcher.base_->
Copy(safe)) {}
1559 bool Done()
const {
return base_->Done(); }
1567 uint64_t
Properties(uint64_t props)
const {
return base_->Properties(props); }
1576 std::unique_ptr<const FST> owned_fst_;
1577 std::unique_ptr<MatcherBase<Arc>> base_;
1582 #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)
virtual ~MatcherBase()=default
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