4 #ifndef FST_EXTENSIONS_SPECIAL_RHO_FST_H_ 5 #define FST_EXTENSIONS_SPECIAL_RHO_FST_H_ 20 template <
class Label>
24 Label rho_label = FLAGS_rho_fst_rho_label,
26 : rho_label_(rho_label), rewrite_mode_(rewrite_mode) {}
29 : rho_label_(data.rho_label_), rewrite_mode_(data.rewrite_mode_) {}
43 WriteType(ostrm, static_cast<int32>(rewrite_mode_));
44 return !ostrm ?
false :
true;
56 LOG(WARNING) <<
"RhoFst: Unknown rewrite mode: " << mode <<
". " 57 <<
"Defaulting to auto.";
70 template <
class M, u
int8 flags = kRhoFstMatchInput | kRhoFstMatchOutput>
73 using FST =
typename M::FST;
74 using Arc =
typename M::Arc;
76 using Label =
typename Arc::Label;
80 enum :
uint8 { kFlags = flags };
85 std::shared_ptr<MatcherData> data = std::make_shared<MatcherData>())
95 std::shared_ptr<MatcherData> data = std::make_shared<MatcherData>())
104 :
RhoMatcher<M>(matcher, safe), data_(matcher.data_) {}
116 if (match_type ==
MATCH_INPUT && flags & kRhoFstMatchInput)
return label;
117 if (match_type ==
MATCH_OUTPUT && flags & kRhoFstMatchOutput)
return label;
121 std::shared_ptr<MatcherData> data_;
152 RhoFstMatcher<SortedMatcher<ConstFst<Log64Arc>>, kRhoFstMatchInput>,
158 output_rho_fst_type>;
163 output_rho_fst_type>;
167 RhoFstMatcher<SortedMatcher<ConstFst<Log64Arc>>, kRhoFstMatchOutput>,
168 output_rho_fst_type>;
172 #endif // FST_EXTENSIONS_SPECIAL_RHO_FST_H_
const char rho_fst_type[]
RhoFstMatcher(const FST *fst, MatchType match_type, std::shared_ptr< MatcherData > data=std::make_shared< MatcherData >())
RhoFstMatcherData(const RhoFstMatcherData &data)
RhoFstMatcher(const RhoFstMatcher< M, flags > &matcher, bool safe=false)
RhoFstMatcher< M, flags > * Copy(bool safe=false) const override
std::ostream & WriteType(std::ostream &strm, const T t)
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
RhoFstMatcherData(Label rho_label=FLAGS_rho_fst_rho_label, MatcherRewriteMode rewrite_mode=RewriteMode(FLAGS_rho_fst_rewrite_mode))
const char output_rho_fst_type[]
bool Write(std::ostream &ostrm, const FstWriteOptions &opts) const
typename Arc::StateId StateId
constexpr uint8 kRhoFstMatchInput
std::istream & ReadType(std::istream &strm, T *t)
std::shared_ptr< MatcherData > GetSharedData() const
typename Arc::Weight Weight
const char input_rho_fst_type[]
DECLARE_int64(rho_fst_rho_label)
constexpr uint8 kRhoFstMatchOutput
static RhoFstMatcherData< Label > * Read(std::istream &istrm, const FstReadOptions &read)