32 Lattice *
fst = fst::RandPairFst<LatticeArc>(opts);
48 int32 first_label = -1;
50 bool first_label_set =
false;
51 for (ArcIterator<CompactLattice> aiter(clat2, s); !aiter.Done();
53 if (aiter.Value().weight.String().size() == 0) {
56 int32 this_label = aiter.Value().weight.String().front();
57 if (first_label_set) {
58 if (this_label != first_label) ok =
true;
60 first_label = this_label;
61 first_label_set =
true;
66 if (clat2.Final(s).String().size() == 0) ok =
true;
68 int32 this_label = clat2.Final(s).String().front();
69 if (first_label_set && this_label != first_label) ok =
true;
87 for (ArcIterator<CompactLattice> aiter(clat2, s); !aiter.Done();
89 sum =
Plus(sum, aiter.Value().weight.Weight());
93 fst::FstPrinter<CompactLatticeArc> printer(clat2, NULL, NULL,
94 NULL,
true,
true,
"\t");
95 printer.Print(&std::cerr,
"<unknown>");
98 fst::FstPrinter<CompactLatticeArc> printer(*clat, NULL, NULL,
99 NULL,
true,
true,
"\t");
100 printer.Print(&std::cerr,
"<unknown>");
102 KALDI_ERR <<
"Bad lattice being pushed.";
113 using namespace kaldi;
fst::StdArc::StateId StateId
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
static const LatticeWeightTpl One()
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
LatticeWeightTpl< FloatType > Plus(const LatticeWeightTpl< FloatType > &w1, const LatticeWeightTpl< FloatType > &w2)
CompactLattice * RandCompactLattice()
bool PushCompactLatticeStrings(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *clat)
This function pushes the transition-ids as far towards the start as they will go. ...
bool PushCompactLatticeWeights(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *clat)
This function pushes the weights in the CompactLattice so that all states except possibly the start s...
void TestPushCompactLatticeWeights()
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.
fst::VectorFst< LatticeArc > Lattice
void TestPushCompactLatticeStrings()
int Rand(struct RandomState *state)
fst::VectorFst< CompactLatticeArc > CompactLattice
#define KALDI_ASSERT(cond)
static const CompactLatticeWeightTpl< WeightType, IntType > Zero()
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)).