56 using StateId =
typename Arc::StateId;
57 using Weight =
typename Arc::Weight;
61 FSTERROR() <<
"Concat: Input/output symbol tables of 1st argument " 62 <<
"does not match input/output symbol tables of 2nd argument";
68 const auto start1 = fst1->
Start();
73 const auto numstates1 = fst1->
NumStates();
79 const auto s2 = siter2.Value();
83 auto arc = aiter.Value();
84 arc.nextstate += numstates1;
88 const auto start2 = fst2.
Start();
89 for (StateId s1 = 0; s1 < numstates1; ++s1) {
90 const auto weight = fst1->
Final(s1);
91 if (weight != Weight::Zero()) {
94 fst1->
AddArc(s1, Arc(0, 0, weight, start2 + numstates1));
122 using StateId =
typename Arc::StateId;
123 using Weight =
typename Arc::Weight;
127 FSTERROR() <<
"Concat: Input/output symbol tables of 1st argument " 128 <<
"does not match input/output symbol tables of 2nd argument";
134 const auto start2 = fst2->
Start();
139 const auto numstates2 = fst2->
NumStates();
144 const auto s1 = siter.Value();
146 const auto weight = fst1.
Final(s1);
147 if (weight != Weight::Zero()) {
149 fst2->
AddArc(s2, Arc(0, 0, weight, start2));
154 auto arc = aiter.Value();
155 arc.nextstate += numstates2;
159 const auto start1 = fst1.
Start();
161 fst2->
SetStart(start1 + numstates2);
173 for (
const auto *fst1 : fsts1)
Concat(*fst1, fst2);
254 #endif // FST_CONCAT_H_ uint64_t ConcatProperties(uint64_t inprops1, uint64_t inprops2, bool delayed=false)
virtual uint64_t Properties(uint64_t mask, bool test) const =0
virtual size_t NumArcs(StateId) const =0
typename Arc::StateId StateId
const SymbolTable * InputSymbols() const override=0
constexpr uint64_t kError
ConcatFst(const Fst< Arc > &fst1, const Fst< Arc > &fst2, const ConcatFstOptions &opts)
virtual Weight Final(StateId) const =0
virtual void SetStart(StateId)=0
typename ReplaceFst< Arc >::Arc Arc
typename Arc::Weight Weight
CacheOptions RationalFstOptions
virtual void ReserveArcs(StateId, size_t)
ArcIterator(const ConcatFst< Arc > &fst, StateId s)
void InitConcat(const Fst< Arc > &fst1, const Fst< Arc > &fst2)
const SymbolTable * OutputSymbols() const override=0
const Impl * GetImpl() const
typename Arc::StateId StateId
virtual void SetProperties(uint64_t props, uint64_t mask)=0
virtual StateId Start() const =0
ConcatFst(const Fst< Arc > &fst1, const Fst< Arc > &fst2)
virtual std::optional< StateId > NumStatesIfKnown() const
void Concat(MutableFst< Arc > *fst1, const Fst< Arc > &fst2)
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)
ConcatFst(const ConcatFst &fst, bool safe=false)
virtual StateId AddState()=0
virtual void ReserveStates(size_t)
virtual void SetFinal(StateId s, Weight weight=Weight::One())=0
StateIterator(const ConcatFst< Arc > &fst)
Impl * GetMutableImpl() const
bool CompatSymbols(const SymbolTable *syms1, const SymbolTable *syms2, bool warning=true)
ConcatFst * Copy(bool safe=false) const override
virtual StateId NumStates() const =0
virtual const SymbolTable * OutputSymbols() const =0