21 #ifndef FST_RANDEQUIVALENT_H_ 22 #define FST_RANDEQUIVALENT_H_ 48 template <
class Arc,
class ArcSelector>
52 uint64_t seed = std::random_device()(),
53 bool *error =
nullptr) {
54 using Weight =
typename Arc::Weight;
55 if (error) *error =
false;
59 FSTERROR() <<
"RandEquivalent: Input/output symbol tables of 1st " 60 <<
"argument do not match input/output symbol tables of 2nd " 62 if (error) *error =
true;
74 std::mt19937 rand(seed);
75 std::bernoulli_distribution coin(.5);
76 for (int32_t n = 0; n < npath; ++n) {
78 const auto &
fst = coin(rand) ? sfst1 : sfst2;
104 VLOG(1) <<
"Sum1 = " << sum1;
105 VLOG(1) <<
"Sum2 = " << sum2;
111 if (error) *error =
true;
123 uint64_t seed = std::random_device()(),
124 int32_t max_length = std::numeric_limits<int32_t>::max(),
125 bool *error =
nullptr) {
129 return RandEquivalent(fst1, fst2, npath, opts, delta, seed, error);
134 #endif // FST_RANDEQUIVALENT_H_ constexpr uint64_t kCyclic
bool RandEquivalent(const Fst< Arc > &fst1, const Fst< Arc > &fst2, int32_t npath, const RandGenOptions< ArcSelector > &opts, float delta=kDelta, uint64_t seed=std::random_device()(), bool *error=nullptr)
virtual uint64_t Properties(uint64_t mask, bool test) const =0
constexpr uint64_t kError
void Connect(MutableFst< Arc > *fst)
std::bool_constant<(W::Properties()&kIdempotent)!=0 > IsIdempotent
void RandGen(const Fst< FromArc > &ifst, MutableFst< ToArc > *ofst, const RandGenOptions< Selector > &opts)
void ArcSort(MutableFst< Arc > *fst, Compare comp)
void Compose(const Fst< Arc > &ifst1, const Fst< Arc > &ifst2, MutableFst< Arc > *ofst, const ComposeOptions &opts=ComposeOptions())
void Project(const Fst< Arc > &ifst, MutableFst< Arc > *ofst, ProjectType project_type)
virtual const SymbolTable * InputSymbols() const =0
void ShortestDistance(const Fst< Arc > &fst, std::vector< typename Arc::Weight > *distance, const ShortestDistanceOptions< Arc, Queue, ArcFilter > &opts)
bool CompatSymbols(const SymbolTable *syms1, const SymbolTable *syms2, bool warning=true)
bool ApproxEqual(const ErrorWeight &, const ErrorWeight &, float)
uint64_t Properties(uint64_t mask, bool test) const override
virtual const SymbolTable * OutputSymbols() const =0