Skip to content

Commit d01acbf

Browse files
committed
Fix unqualified std::vector occurrences.
1 parent 80ccb9b commit d01acbf

14 files changed

Lines changed: 77 additions & 79 deletions

‎src/decoder/nbest-decoder.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class NBestDecoder {
179179
continue; // skip that token
180180
}
181181
LatticeWeight path_w(lmscore, amscore);
182-
CompactLatticeWeight path_weight(path_w, vector<int32>());
182+
CompactLatticeWeight path_weight(path_w, std::vector<int32>());
183183

184184
std::vector<CompactLatticeArc*> arcs_reverse; // reverse order output arcs
185185
// outer loop for word tokens
@@ -230,8 +230,8 @@ class NBestDecoder {
230230
// ShortestPath(fst, &fst_one);
231231
// ConvertLattice(fst_one, fst_out, true);
232232
// return true;
233-
// }
234-
233+
// }
234+
235235
private:
236236

237237
// TokenStore is a store of linked tokens with its own allocator
@@ -388,7 +388,7 @@ class NBestDecoder {
388388
return tok2;
389389
}
390390
}
391-
391+
392392
inline bool CombineN(Elem *head, Token *new_tok) { // n-best version
393393
if (!new_tok) return false;
394394
Elem *e = head;
@@ -435,7 +435,7 @@ class NBestDecoder {
435435
}
436436
inline Token* Advance(Token *source, Arc &arc, int32 frame,
437437
BaseFloat cutoff) {
438-
// compute new weight
438+
// compute new weight
439439
Weight w = Times(source->c, arc.weight);
440440
Weight amscore = Weight::One();
441441
if (arc.ilabel > 0) { // emitting arc
@@ -446,7 +446,7 @@ class NBestDecoder {
446446
if (w.Value() > cutoff) { // prune
447447
return NULL;
448448
}
449-
// create new token
449+
// create new token
450450
Token *tok;
451451
if (arc.olabel > 0) { // create new token
452452
// find or create corresponding Token
@@ -593,10 +593,10 @@ class NBestDecoder {
593593
// KALDI_ASSERT(state == tok->arc_.nextstate);
594594
for (fst::ArcIterator<fst::Fst<Arc> > aiter(fst_, state);
595595
!aiter.Done(); aiter.Next()) {
596-
// for all a in A(state)
596+
// for all a in A(state)
597597
Arc arc = aiter.Value();
598598
if (arc.ilabel != 0) { // propagate only emitting
599-
Token *new_tok =
599+
Token *new_tok =
600600
token_store_.Advance(tok, arc, frame, next_weight_cutoff);
601601
if (new_tok) {
602602
Elem *e_found = toks_.Find(arc.nextstate);
@@ -637,7 +637,7 @@ class NBestDecoder {
637637
queue_.erase(queue_.begin());
638638
Elem *elem = toks_.Find(state); // would segfault if state not
639639
// in toks_ but this can't happen.
640-
640+
641641
// we have to pop all tokens with the same state
642642
// this may create some unneccessary repetitions, since only the new token
643643
// needs to be forwarded, but I don't know yet how to solve this

‎src/kws/kws-functions.cc‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ bool CompareInterval(const Interval &i1,
3838
}
3939

4040
bool ClusterLattice(CompactLattice *clat,
41-
const vector<int32> &state_times) {
41+
const std::vector<int32> &state_times) {
4242
using namespace fst;
4343
typedef CompactLattice::StateId StateId;
4444

4545
// Hashmap to store the cluster heads.
46-
unordered_map<StateId, vector<Interval> > head;
46+
unordered_map<StateId, std::vector<Interval> > head;
4747

4848
// Step 1: Iterate over the lattice to get the arcs
4949
StateId max_id = 0;
@@ -69,11 +69,11 @@ bool ClusterLattice(CompactLattice *clat,
6969
// the cluster heads is to take the first one as a cluster head; then go
7070
// till we find the next one that doesn't overlap in time with the current
7171
// cluster head, and so on.
72-
unordered_map<StateId, vector<Interval> >::iterator iter;
72+
unordered_map<StateId, std::vector<Interval> >::iterator iter;
7373
for (iter = head.begin(); iter != head.end(); ++iter) {
7474
// For this ilabel, sort all the arcs on time, from first to last.
7575
sort(iter->second.begin(), iter->second.end(), CompareInterval);
76-
vector<Interval> tmp;
76+
std::vector<Interval> tmp;
7777
tmp.push_back(iter->second[0]);
7878
for (int32 i = 1; i < iter->second.size(); i++) {
7979
if (tmp.back().End() <= iter->second[i].Start())
@@ -145,16 +145,16 @@ class CompactLatticeToKwsProductFstMapper {
145145

146146

147147
bool CreateFactorTransducer(const CompactLattice &clat,
148-
const vector<int32> &state_times,
148+
const std::vector<int32> &state_times,
149149
int32 utterance_id,
150150
KwsProductFst *factor_transducer) {
151151
using namespace fst;
152152
typedef KwsProductArc::StateId StateId;
153153

154154
// We first compute the alphas and betas
155155
bool success = false;
156-
vector<double> alpha;
157-
vector<double> beta;
156+
std::vector<double> alpha;
157+
std::vector<double> beta;
158158
success = ComputeCompactLatticeAlphas(clat, &alpha);
159159
success = success && ComputeCompactLatticeBetas(clat, &beta);
160160
if (!success)
@@ -248,7 +248,7 @@ bool CreateFactorTransducer(const CompactLattice &clat,
248248
}
249249

250250
void RemoveLongSilences(int32 max_silence_frames,
251-
const vector<int32> &state_times,
251+
const std::vector<int32> &state_times,
252252
KwsProductFst *factor_transducer) {
253253
using namespace fst;
254254
typedef KwsProductArc::StateId StateId;

‎src/kws/kws-functions.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ bool CompareInterval(const Interval &i1,
6262
// It puts disambiguating symbols in the olabels, leaving the words on the
6363
// ilabels.
6464
bool ClusterLattice(CompactLattice *clat,
65-
const vector<int32> &state_times);
65+
const std::vector<int32> &state_times);
6666

6767
// This function contains two steps: weight pushing and factor generation. The
6868
// original ShortestDistance() is not very efficient, so we do the weight
6969
// pushing and shortest path manually by computing the alphas and betas. The
7070
// factor generation step expand the lattice to the LXTXT' semiring, with
7171
// additional start state and end state (and corresponding arcs) added.
7272
bool CreateFactorTransducer(const CompactLattice &clat,
73-
const vector<int32> &state_times,
73+
const std::vector<int32> &state_times,
7474
int32 utterance_id,
7575
KwsProductFst *factor_transducer);
7676

@@ -81,7 +81,7 @@ bool CreateFactorTransducer(const CompactLattice &clat,
8181
// step, so the "search area" is limited to the original arcs before factor
8282
// generation.
8383
void RemoveLongSilences(int32 max_silence_frames,
84-
const vector<int32> &state_times,
84+
const std::vector<int32> &state_times,
8585
KwsProductFst *factor_transducer);
8686

8787
// Do the factor merging part: encode input and output, and apply weighted

‎src/kwsbin/lattice-to-kws-index.cc‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ int main(int argc, char *argv[]) {
110110
n_fail++;
111111
continue;
112112
}
113-
}
113+
}
114114

115115
// Get the alignments
116-
vector<int32> state_times;
116+
std::vector<int32> state_times;
117117
CompactLatticeStateTimes(clat, &state_times);
118118

119119
// Cluster the arcs in the CompactLattice, write the cluster_id on the
@@ -145,9 +145,9 @@ int main(int argc, char *argv[]) {
145145
EnsureEpsilonProperty(&clat);
146146
fst::TopSort(&clat);
147147
// We have to recompute the state times because they will have changed.
148-
CompactLatticeStateTimes(clat, &state_times);
148+
CompactLatticeStateTimes(clat, &state_times);
149149
}
150-
150+
151151
// Generate factor transducer
152152
// CreateFactorTransducer() corresponds to the "Factor Generation" part of
153153
// Dogan and Murat's paper. But we also move the weight pushing step to
@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) {
158158
success = CreateFactorTransducer(clat, state_times, utterance_id, &factor_transducer);
159159
if (!success) {
160160
KALDI_WARN << "Cannot generate factor transducer for lattice " << key;
161-
n_fail++;
161+
n_fail++;
162162
}
163163

164164
MaybeDoSanityCheck(factor_transducer);
@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
178178
DoFactorMerging(&factor_transducer, &index_transducer);
179179

180180
MaybeDoSanityCheck(index_transducer);
181-
181+
182182
// Do factor disambiguation. It corresponds to the "Factor Disambiguation"
183183
// step in Dogan and Murat's paper.
184184
KALDI_VLOG(1) << "Doing factor disambiguation...";
@@ -191,10 +191,10 @@ int main(int argc, char *argv[]) {
191191
KALDI_VLOG(1) << "Optimizing factor transducer...";
192192
OptimizeFactorTransducer(&index_transducer, max_states, allow_partial);
193193

194-
MaybeDoSanityCheck(index_transducer);
195-
194+
MaybeDoSanityCheck(index_transducer);
195+
196196
// Write result
197-
index_writer.Write(key, index_transducer);
197+
index_writer.Write(key, index_transducer);
198198

199199
n_done++;
200200
}

‎src/lat/lattice-functions.h‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ BaseFloat LatticeForwardBackward(const Lattice &lat,
6767
// the CompactLattice lattice format. Also we only need the alpha in the forward
6868
// path, not the posteriors.
6969
bool ComputeCompactLatticeAlphas(const CompactLattice &lat,
70-
vector<double> *alpha);
70+
std::vector<double> *alpha);
7171

7272
// A sibling of the function CompactLatticeAlphas()... We compute the beta from
7373
// the backward path here.
7474
bool ComputeCompactLatticeBetas(const CompactLattice &lat,
75-
vector<double> *beta);
75+
std::vector<double> *beta);
7676

7777

7878
// Computes (normal or Viterbi) alphas and betas; returns (total-prob, or
@@ -82,8 +82,8 @@ bool ComputeCompactLatticeBetas(const CompactLattice &lat,
8282
template<typename LatticeType>
8383
double ComputeLatticeAlphasAndBetas(const LatticeType &lat,
8484
bool viterbi,
85-
vector<double> *alpha,
86-
vector<double> *beta);
85+
std::vector<double> *alpha,
86+
std::vector<double> *beta);
8787

8888

8989
/// Topologically sort the compact lattice if not already topologically sorted.
@@ -321,4 +321,3 @@ void ComposeCompactLatticeDeterministic(
321321
} // namespace kaldi
322322

323323
#endif // KALDI_LAT_LATTICE_FUNCTIONS_H_
324-

‎src/lat/sausages.cc‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ namespace kaldi {
2525

2626
// this is Figure 6 in the paper.
2727
void 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() {
7171
struct Int32IsZero {
7272
bool operator() (int32 i) { return (i == 0); }
7373
};
74-
// static
74+
// static
7575
void 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.
133133
void 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

268268
void 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

351351
MinimumBayesRisk::MinimumBayesRisk(const CompactLattice &clat_in,

‎src/latbin/lattice-oracle.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void MapWildCards(const LabelSet &wildcards, fst::StdVectorFst *ofst) {
6767
LabelSet::const_iterator it = wildcards.find(arc.ilabel);
6868
if (it != wildcards.end()) {
6969
KALDI_VLOG(4) << "MapWildCards: mapping symbol " << arc.ilabel
70-
<< " to epsilon" << endl;
70+
<< " to epsilon" << std::endl;
7171
arc.ilabel = 0;
7272
}
7373
it = wildcards.find(arc.olabel);
@@ -173,7 +173,7 @@ void CountErrors(const fst::StdVectorFst &fst,
173173
bool CheckFst(const fst::StdVectorFst &fst, string name, string key) {
174174
#ifdef DEBUG
175175
StateId numstates = fst.NumStates();
176-
cerr << " " << name << " has " <<numstates << " states" <<endl;
176+
std::cerr << " " << name << " has " << numstates << " states" << std::endl;
177177
std::stringstream ss;
178178
ss << name << key << ".fst";
179179
fst.Write(ss.str());
@@ -285,7 +285,7 @@ int main(int argc, char *argv[]) {
285285
for (; !lattice_reader.Done(); lattice_reader.Next()) {
286286
std::string key = lattice_reader.Key();
287287
const Lattice &lat = lattice_reader.Value();
288-
cerr << "Lattice " << key << " read." << endl;
288+
std::cerr << "Lattice " << key << " read." << std::endl;
289289

290290
// remove all weights while creating a standard FST
291291
VectorFst<StdArc> lattice_fst;

0 commit comments

Comments
 (0)