@@ -25,21 +25,21 @@ namespace kaldi {
2525
2626// this is Figure 6 in the paper.
2727void MinimumBayesRisk::MbrDecode () {
28-
28+
2929 for (size_t counter = 0 ; ; counter++) {
3030 NormalizeEps (&R_ );
3131 AccStats (); // writes to gamma_
3232 double delta_Q = 0.0 ; // change in objective function.
3333
3434 one_best_times_.clear ();
3535 one_best_confidences_.clear ();
36-
36+
3737 // Caution: q in the line below is (q-1) in the algorithm
3838 // in the paper; both R_ and gamma_ are indexed by q-1.
3939 for (size_t q = 0 ; q < R_ .size (); q++) {
40- if (do_mbr_) { // This loop updates R_ [indexed same as gamma_].
40+ if (do_mbr_) { // This loop updates R_ [indexed same as gamma_].
4141 // gamma_[i] is sorted in reverse order so most likely one is first.
42- const vector<pair<int32, BaseFloat> > &this_gamma = gamma_[q];
42+ const std:: vector<std:: pair<int32, BaseFloat> > &this_gamma = gamma_[q];
4343 double old_gamma = 0 , new_gamma = this_gamma[0 ].second ;
4444 int32 rq = R_ [q], rhat = this_gamma[0 ].first ; // rq: old word, rhat: new.
4545 for (size_t j = 0 ; j < this_gamma.size (); j++)
@@ -71,7 +71,7 @@ void MinimumBayesRisk::MbrDecode() {
7171struct Int32IsZero {
7272 bool operator () (int32 i) { return (i == 0 ); }
7373};
74- // static
74+ // static
7575void MinimumBayesRisk::RemoveEps (std::vector<int32> *vec) {
7676 Int32IsZero pred;
7777 vec->erase (std::remove_if (vec->begin (), vec->end (), pred),
@@ -96,7 +96,7 @@ double MinimumBayesRisk::EditDistance(int32 N, int32 Q,
9696 Vector<double > &alpha_dash_arc) {
9797 alpha (1 ) = 0.0 ; // = log(1). Line 5.
9898 alpha_dash (1 , 0 ) = 0.0 ; // Line 5.
99- for (int32 q = 1 ; q <= Q; q++)
99+ for (int32 q = 1 ; q <= Q; q++)
100100 alpha_dash (1 , q) = alpha_dash (1 , q-1 ) + l (0 , r (q)); // Line 7.
101101 for (int32 n = 2 ; n <= N; n++) {
102102 double alpha_n = kLogZeroDouble ;
@@ -132,7 +132,7 @@ double MinimumBayesRisk::EditDistance(int32 N, int32 Q,
132132// Figure 5 in the paper.
133133void MinimumBayesRisk::AccStats () {
134134 using std::map;
135-
135+
136136 int32 N = static_cast <int32>(pre_.size ()) - 1 ,
137137 Q = static_cast <int32>(R_ .size ());
138138
@@ -141,8 +141,8 @@ void MinimumBayesRisk::AccStats() {
141141 Vector<double > alpha_dash_arc (Q+1 ); // index 0...Q
142142 Matrix<double > beta_dash (N+1 , Q+1 ); // index (1...N, 0...Q)
143143 Vector<double > beta_dash_arc (Q+1 ); // index 0...Q
144- vector<char > b_arc (Q+1 ); // integer in {1,2,3}; index 1...Q
145- vector<map<int32, double > > gamma (Q+1 ); // temp. form of gamma.
144+ std:: vector<char > b_arc (Q+1 ); // integer in {1,2,3}; index 1...Q
145+ std:: vector<map<int32, double > > gamma (Q+1 ); // temp. form of gamma.
146146 // index 1...Q [word] -> occ.
147147
148148 // The tau arrays below are the sums over words of the tau_b
@@ -151,7 +151,7 @@ void MinimumBayesRisk::AccStats() {
151151 // the sausage bins, not specifically for the 1-best output.
152152 Vector<double > tau_b (Q+1 ), tau_e (Q+1 );
153153
154- double Ltmp = EditDistance (N, Q, alpha, alpha_dash, alpha_dash_arc);
154+ double Ltmp = EditDistance (N, Q, alpha, alpha_dash, alpha_dash_arc);
155155 if (L_ != 0 && Ltmp > L_ ) { // L_ != 0 is to rule out 1st iter.
156156 KALDI_WARN << " Edit distance increased: " << Ltmp << " > "
157157 << L_ ;
@@ -262,7 +262,7 @@ void MinimumBayesRisk::AccStats() {
262262 double avg = 0.5 * (times_[q-2 ].second + times_[q-1 ].first );
263263 times_[q-2 ].second = times_[q-1 ].first = avg;
264264 }
265- }
265+ }
266266}
267267
268268void MinimumBayesRisk::PrepareLatticeAndInitStats (CompactLattice *clat) {
@@ -271,7 +271,7 @@ void MinimumBayesRisk::PrepareLatticeAndInitStats(CompactLattice *clat) {
271271 CreateSuperFinal (clat); // Add super-final state to clat... this is
272272 // one of the requirements of the MBR algorithm, as mentioned in the
273273 // paper (i.e. just one final state).
274-
274+
275275 // Topologically sort the lattice, if not already sorted.
276276 kaldi::uint64 props = clat->Properties (fst::kFstProperties , false );
277277 if (!(props & fst::kTopSorted )) {
@@ -283,7 +283,7 @@ void MinimumBayesRisk::PrepareLatticeAndInitStats(CompactLattice *clat) {
283283 state_times_.push_back (0 ); // we'll convert to 1-based numbering.
284284 for (size_t i = state_times_.size ()-1 ; i > 0 ; i--)
285285 state_times_[i] = state_times_[i-1 ];
286-
286+
287287 // Now we convert the information in "clat" into a special internal
288288 // format (pre_, post_ and arcs_) which allows us to access the
289289 // arcs preceding any given state.
@@ -343,9 +343,9 @@ MinimumBayesRisk::MinimumBayesRisk(const CompactLattice &clat_in, bool do_mbr):
343343 L_ = 0.0 ; // Set current edit-distance to 0 [just so we know
344344 // when we're on the 1st iter.]
345345 }
346-
346+
347347 MbrDecode ();
348-
348+
349349}
350350
351351MinimumBayesRisk::MinimumBayesRisk (const CompactLattice &clat_in,
0 commit comments