23 #ifndef KALDI_LAT_SAUSAGES_H_ 24 #define KALDI_LAT_SAUSAGES_H_ 67 opts->
Register(
"decode-mbr", &decode_mbr,
"If true, do Minimum Bayes Risk " 68 "decoding (else, Maximum a Posteriori)");
69 opts->
Register(
"print-silence", &print_silence,
"Keep the inter-word '<eps>' " 70 "bins in the 1-best output (ctm, <eps> can be a 'silence' or a 'deleted' word)");
92 const std::vector<int32> &
words,
100 const std::vector<int32> &words,
101 const std::vector<std::pair<BaseFloat,BaseFloat> > ×,
108 const std::vector<std::vector<std::pair<BaseFloat, BaseFloat> > >
GetTimes()
const {
115 return sausage_times_;
123 return one_best_times_;
133 return one_best_confidences_;
139 const std::vector<std::vector<std::pair<int32, BaseFloat> > > &
GetSausageStats()
const {
158 if (a == b)
return 0.0;
159 else return (penalize ? 1.0 + delta() : 1.0);
176 static void RemoveEps(std::vector<int32> *vec);
180 static void NormalizeEps(std::vector<int32> *vec);
194 std::pair<const int32, double> pr(i, d);
195 std::pair<std::map<int32, double>::iterator,
bool> ret = gamma->insert(pr);
197 ret.first->second +=
d;
217 std::vector<std::vector<int32> >
pre_;
222 std::vector<int32>
R_;
229 std::vector<std::vector<std::pair<int32, BaseFloat> > >
gamma_;
235 std::vector<std::vector<std::pair<BaseFloat, BaseFloat> > >
times_;
259 bool operator () (
const std::pair<int32, BaseFloat> &a,
260 const std::pair<int32, BaseFloat> &b)
const {
261 if (a.second > b.second)
return true;
262 else if (a.second < b.second)
return false;
263 else return a.first > b.first;
270 #endif // KALDI_LAT_SAUSAGES_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
static void AddToMap(int32 i, double d, std::map< int32, double > *gamma)
Function used to increment map.
double l(int32 a, int32 b, bool penalize=false)
Without the 'penalize' argument this gives us the basic edit-distance function l(a,b), as in the paper.
const std::vector< BaseFloat > & GetOneBestConfidences() const
Outputs the confidences for the one-best transcript.
const std::vector< std::vector< std::pair< BaseFloat, BaseFloat > > > GetTimes() const
The implementation of the Minimum Bayes Risk decoding method described in "Minimum Bayes Risk decodin...
std::vector< std::vector< std::pair< BaseFloat, BaseFloat > > > times_
std::vector< int32 > state_times_
MinimumBayesRiskOptions opts_
bool print_silence
Boolean configuration parameter: if true, the 1-best path will 'keep' the <eps> bins,.
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
std::vector< BaseFloat > one_best_confidences_
MinimumBayesRiskOptions()
std::vector< std::vector< std::pair< int32, BaseFloat > > > gamma_
const std::vector< std::pair< BaseFloat, BaseFloat > > GetSausageTimes() const
int32 r(int32 q)
returns r_q, in one-based indexing, as in the paper.
const std::vector< std::pair< BaseFloat, BaseFloat > > & GetOneBestTimes() const
const std::vector< int32 > & GetOneBest() const
This class does the word-level Minimum Bayes Risk computation, and gives you either the 1-best MBR ou...
const std::vector< std::vector< std::pair< int32, BaseFloat > > > & GetSausageStats() const
fst::VectorFst< CompactLatticeArc > CompactLattice
std::vector< std::pair< BaseFloat, BaseFloat > > sausage_times_
void Register(OptionsItf *opts)
std::vector< std::vector< int32 > > pre_
For each node in the lattice, a list of arcs entering that node.
BaseFloat GetBayesRisk() const
Returns the expected WER over this sentence (assuming model correctness).
std::vector< std::pair< BaseFloat, BaseFloat > > one_best_times_
std::vector< Arc > arcs_
Arcs in the topologically sorted acceptor form of the word-level lattice, with one final-state...
bool decode_mbr
Boolean configuration parameter: if true, we actually update the hypothesis to do MBR decoding (if fa...