18 #ifndef FST_EXTENSIONS_SPECIAL_RHO_FST_H_ 19 #define FST_EXTENSIONS_SPECIAL_RHO_FST_H_ 41 template <
class Label>
45 Label rho_label = FST_FLAGS_rho_fst_rho_label,
48 : rho_label_(rho_label), rewrite_mode_(rewrite_mode) {}
51 : rho_label_(data.rho_label_), rewrite_mode_(data.rewrite_mode_) {}
55 auto data = std::make_unique<RhoFstMatcherData<Label>>();
60 return data.release();
65 WriteType(ostrm, static_cast<int32_t>(rewrite_mode_));
66 return !ostrm ?
false :
true;
78 LOG(WARNING) <<
"RhoFst: Unknown rewrite mode: " << mode <<
". " 79 <<
"Defaulting to auto.";
94 template <
class M, u
int8_t flags = kRhoFstMatchInput | kRhoFstMatchOutput>
98 using Arc =
typename M::Arc;
104 static constexpr uint8_t kFlags = flags;
109 std::shared_ptr<MatcherData> data = std::make_shared<MatcherData>())
119 std::shared_ptr<MatcherData> data = std::make_shared<MatcherData>())
128 :
RhoMatcher<M>(matcher, safe), data_(matcher.data_) {}
140 if (match_type ==
MATCH_INPUT && flags & kRhoFstMatchInput)
return label;
141 if (match_type ==
MATCH_OUTPUT && flags & kRhoFstMatchOutput)
return label;
145 std::shared_ptr<MatcherData> data_;
162 RhoFstMatcher<SortedMatcher<ConstFst<Arc>>, kRhoFstMatchInput>,
170 RhoFstMatcher<SortedMatcher<ConstFst<Arc>>, kRhoFstMatchOutput>,
171 output_rho_fst_type>;
177 #endif // FST_EXTENSIONS_SPECIAL_RHO_FST_H_
constexpr char input_rho_fst_type[]
RhoFstMatcher(const FST *fst, MatchType match_type, std::shared_ptr< MatcherData > data=std::make_shared< MatcherData >())
RhoFstMatcherData(Label rho_label=FST_FLAGS_rho_fst_rho_label, MatcherRewriteMode rewrite_mode=RewriteMode(FST_FLAGS_rho_fst_rewrite_mode))
RhoFstMatcherData(const RhoFstMatcherData &data)
RhoFstMatcher(const RhoFstMatcher< M, flags > &matcher, bool safe=false)
constexpr char output_rho_fst_type[]
RhoFstMatcher< M, flags > * Copy(bool safe=false) const override
std::ostream & WriteType(std::ostream &strm, const T t)
constexpr uint8_t kRhoFstMatchOutput
const MatcherData * GetData() const
typename Arc::Label Label
RhoFstMatcher(const FST &fst, MatchType match_type, std::shared_ptr< MatcherData > data=std::make_shared< MatcherData >())
DECLARE_string(rho_fst_rewrite_mode)
MatcherRewriteMode RewriteMode() const
constexpr char rho_fst_type[]
constexpr uint8_t kRhoFstMatchInput
bool Write(std::ostream &ostrm, const FstWriteOptions &opts) const
typename Arc::StateId StateId
std::istream & ReadType(std::istream &strm, T *t)
std::shared_ptr< MatcherData > GetSharedData() const
typename Arc::Weight Weight
DECLARE_int64(rho_fst_rho_label)
static RhoFstMatcherData< Label > * Read(std::istream &istrm, const FstReadOptions &read)