59 FSTERROR() <<
"Union: Input/output symbol tables of 1st argument " 60 <<
"do not match input/output symbol tables of 2nd argument";
64 const auto numstates1 = fst1->
NumStates();
65 const bool initial_acyclic1 =
69 const auto start2 = fst2.
Start();
74 if (std::optional<typename Arc::StateId> numstates2 =
76 fst1->
ReserveStates(numstates1 + *numstates2 + (initial_acyclic1 ? 0 : 1));
80 const auto s2 = siter.Value();
84 auto arc = aiter.Value();
85 arc.nextstate += numstates1;
86 fst1->
AddArc(s1, std::move(arc));
89 const auto start1 = fst1->
Start();
95 if (initial_acyclic1) {
96 fst1->
AddArc(start1, Arc(0, 0, start2 + numstates1));
98 const auto nstart1 = fst1->
AddState();
100 fst1->
AddArc(nstart1, Arc(0, 0, start1));
101 fst1->
AddArc(nstart1, Arc(0, 0, start2 + numstates1));
112 for (
const auto *fst2 : fsts2)
Union(fst1, *fst2);
189 #endif // FST_UNION_H_
virtual uint64_t Properties(uint64_t mask, bool test) const =0
StateIterator(const UnionFst< Arc > &fst)
virtual size_t NumArcs(StateId) const =0
const SymbolTable * InputSymbols() const override=0
constexpr uint64_t kError
constexpr uint64_t kInitialAcyclic
virtual Weight Final(StateId) const =0
virtual void SetStart(StateId)=0
typename ReplaceFst< Arc >::Arc Arc
CacheOptions RationalFstOptions
virtual void ReserveArcs(StateId, size_t)
UnionFst(const Fst< Arc > &fst1, const Fst< Arc > &fst2)
const SymbolTable * OutputSymbols() const override=0
typename Arc::StateId StateId
uint64_t UnionProperties(uint64_t inprops1, uint64_t inprops2, bool delayed=false)
void Union(RationalFst< Arc > *fst1, const Fst< Arc > &fst2)
constexpr uint64_t kCopyProperties
virtual void SetProperties(uint64_t props, uint64_t mask)=0
typename Arc::StateId StateId
virtual StateId Start() const =0
virtual std::optional< StateId > NumStatesIfKnown() const
constexpr uint64_t kFstProperties
virtual void AddArc(StateId, const Arc &)=0
typename ReplaceFst< Arc >::Arc Arc
virtual const SymbolTable * InputSymbols() const =0
Arc::StateId CountStates(const Fst< Arc > &fst)
virtual StateId AddState()=0
virtual void ReserveStates(size_t)
virtual void SetFinal(StateId s, Weight weight=Weight::One())=0
ArcIterator(const UnionFst< Arc > &fst, StateId s)
typename Arc::Weight Weight
UnionFst(const Fst< Arc > &fst1, const Fst< Arc > &fst2, const UnionFstOptions &opts)
bool CompatSymbols(const SymbolTable *syms1, const SymbolTable *syms2, bool warning=true)
UnionFst(const UnionFst &fst, bool safe=false)
internal::RationalFstImpl< A > * GetMutableImpl() const
virtual StateId NumStates() const =0
UnionFst * Copy(bool safe=false) const override
const internal::RationalFstImpl< A > * GetImpl() const
virtual const SymbolTable * OutputSymbols() const =0