21 #ifndef KALDI_FSTEXT_LATTICE_UTILS_H_ 22 #define KALDI_FSTEXT_LATTICE_UTILS_H_ 24 #include "fst/fstlib.h" 48 template<
class Weight,
class Int>
50 const ExpandedFst<ArcTpl<Weight> > &ifst,
51 MutableFst<ArcTpl<CompactLatticeWeightTpl<Weight, Int> > > *ofst,
63 template<
class Weight,
class Int>
65 const ExpandedFst<ArcTpl<CompactLatticeWeightTpl<Weight, Int> > > &ifst,
66 MutableFst<ArcTpl<Weight> > *ofst,
76 template<
class WeightIn,
class WeightOut>
78 const ExpandedFst<ArcTpl<WeightIn> > &ifst,
79 MutableFst<ArcTpl<WeightOut> > *ofst);
89 VectorFst<ArcTpl<CompactLatticeWeightTpl<LatticeWeightTpl<float>, Int> > >
fst;
98 VectorFst<ArcTpl<CompactLatticeWeightTpl<LatticeWeightTpl<double>, Int> > >
fst;
107 VectorFst<ArcTpl<CompactLatticeWeightTpl<LatticeWeightTpl<float>, Int> > >
fst;
116 VectorFst<ArcTpl<CompactLatticeWeightTpl<LatticeWeightTpl<double>, Int> > >
fst;
123 template <
class Real>
125 const ExpandedFst<ArcTpl<TropicalWeight> > &ifst,
131 std::vector<std::vector<double> > ans(2);
132 ans[0].resize(2, 0.0);
133 ans[1].resize(2, 0.0);
134 ans[0][0] = ans[1][1] = 1.0;
139 std::vector<std::vector<double> > ans(2);
140 ans[0].resize(2, 0.0);
141 ans[1].resize(2, 0.0);
148 std::vector<std::vector<double> > ans(2);
149 ans[0].resize(2, 0.0);
150 ans[1].resize(2, 0.0);
156 inline std::vector<std::vector<double> >
LatticeScale(
double lmwt,
double acwt) {
157 std::vector<std::vector<double> > ans(2);
158 ans[0].resize(2, 0.0);
159 ans[1].resize(2, 0.0);
173 template<
class Weight,
class ScaleFloat>
175 const std::vector<std::vector<ScaleFloat> > &scale,
176 MutableFst<ArcTpl<Weight> > *
fst);
180 template<
class Weight,
class Int>
186 template<
class Weight,
class Int>
206 LatticeWeight(arc.weight.Value(),
207 arc.weight == StdArc::Weight::Zero() ?
208 arc.weight.Value() : 0.0),
231 return StdArc(arc.ilabel, arc.olabel,
246 template<
class Weight,
class Int>
256 #endif // KALDI_FSTEXT_LATTICE_UTILS_H_ void RemoveAlignmentsFromCompactLattice(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *fst)
Removes state-level alignments (the strings that are part of the weights).
LatticeWeightTpl< Real > LatticeWeight
MapSymbolsAction InputSymbolsAction()
uint64 Properties(uint64 props)
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
ArcTpl< LatticeWeight > LatticeArc
LatticeArc operator()(const StdArc &arc)
StdArc operator()(const LatticeArc &arc)
Class LatticeToStdMapper maps a LatticeArc to a normal arc (StdArc) by adding the elements of the Lat...
std::vector< std::vector< double > > AcousticLatticeScale(double acwt)
ArcTpl< LatticeWeight > LatticeArc
MapSymbolsAction OutputSymbolsAction()
void ScaleLattice(const std::vector< std::vector< ScaleFloat > > &scale, MutableFst< ArcTpl< Weight > > *fst)
Scales the pairs of weights in LatticeWeight or CompactLatticeWeight by viewing the pair (a...
bool CompactLatticeHasAlignment(const ExpandedFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > &fst)
Returns true if lattice has alignments, i.e.
MapSymbolsAction InputSymbolsAction()
void ConvertLattice(const ExpandedFst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *ofst, bool invert)
Convert lattice from a normal FST to a CompactLattice FST.
std::vector< std::vector< double > > LatticeScale(double lmwt, double acwt)
LatticeWeightTpl< Real > LatticeWeight
void PruneCompactLattice(Weight beam, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *fst)
uint64 Properties(uint64 props)
fst::StdArc::Weight Weight
std::vector< std::vector< double > > GraphLatticeScale(double lmwt)
Class StdToLatticeMapper maps a normal arc (StdArc) to a LatticeArc by putting the StdArc weight as t...
void ConvertFstToLattice(const ExpandedFst< ArcTpl< TropicalWeight > > &ifst, MutableFst< ArcTpl< LatticeWeightTpl< Real > > > *ofst)
Converts TropicalWeight to LatticeWeight (puts all the weight on the first float in the lattice's pai...
MapSymbolsAction OutputSymbolsAction()
MapFinalAction FinalAction()
MapFinalAction FinalAction()
std::vector< std::vector< double > > DefaultLatticeScale()
Returns a default 2x2 matrix scaling factor for LatticeWeight.