Skip to content

Commit 227f196

Browse files
Ko van der SlootKo van der Sloot
authored andcommitted
more refactoring
1 parent a0b354f commit 227f196

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/GenerateTagger.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ struct more_second {
270270
}
271271
}
272272
if ( !skip )
273-
for( int f=0; f < nslots; f++){
273+
for( int f=0; f < nslots; ++f ){
274274
outfile << indexlex( TestPat[f], TheLex ) << " ";
275275
}
276276
int thisTagCode = -1;

src/RunTagger.cxx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace Tagger {
7171

7272
BeamData::~BeamData(){
7373
if ( paths ){
74-
for ( int q=0; q < size; q++ ){
74+
for ( int q=0; q < size; ++q ){
7575
delete n_best_array[q];
7676
delete [] paths[q];
7777
delete [] temppaths[q];
@@ -95,7 +95,7 @@ namespace Tagger {
9595
return false;
9696
}
9797
else {
98-
for ( int q=0; q < Size; q++ ){
98+
for ( int q=0; q < Size; ++q ){
9999
paths[q] = 0;
100100
temppaths[q] = 0;
101101
if ( (n_best_array[q] = new n_best_tuple) == 0 ){
@@ -111,7 +111,7 @@ namespace Tagger {
111111
delete [] temppaths[q];
112112
}
113113
}
114-
for ( int q=0; q < Size; q++ ){
114+
for ( int q=0; q < Size; ++q ){
115115
if ( (paths[q] = new int[noWords]) == 0 ||
116116
(temppaths[q] = new int[noWords]) == 0 ){
117117
throw runtime_error( "Beam: not enough memory for N-best search tables" );
@@ -124,13 +124,13 @@ namespace Tagger {
124124

125125
void BeamData::ClearBest(){
126126
DBG << "clearing n_best_array..." << endl;
127-
for ( int i=0; i < size; i++ )
127+
for ( int i=0; i < size; ++i )
128128
n_best_array[i]->clean();
129129
}
130130

131131
void BeamData::Shift( int no_words, int i_word ){
132-
for ( int q1 = 0; q1 < no_words; q1++ ){
133-
for ( int jb = 0; jb < size; jb++ ){
132+
for ( int q1 = 0; q1 < no_words; ++q1 ){
133+
for ( int jb = 0; jb < size; ++jb ){
134134
path_prob[jb] = n_best_array[jb]->prob;
135135
if ( n_best_array[jb]->path != EMPTY_PATH ){
136136
if ( q1 < i_word ){
@@ -150,8 +150,8 @@ namespace Tagger {
150150
temppaths[jb][q1] = EMPTY_PATH;
151151
}
152152
}
153-
for ( int jb = 0; jb < size; jb++ ){
154-
for ( int q1=0; q1 < no_words; q1++ )
153+
for ( int jb = 0; jb < size; ++jb ){
154+
for ( int q1=0; q1 < no_words; ++q1 )
155155
paths[jb][q1] = temppaths[jb][q1];
156156
}
157157
}
@@ -276,7 +276,7 @@ namespace Tagger {
276276
delete tmp_d_pnt;
277277
jb++;
278278
}
279-
for ( ; jb < size; jb++ ){
279+
for ( ; jb < size; ++jb ){
280280
paths[jb][0] = EMPTY_PATH;
281281
path_prob[jb] = 0.0;
282282
}
@@ -304,7 +304,7 @@ namespace Tagger {
304304
double thisWProb = d_pnt->prob;
305305
double thisPProb = thisWProb * path_prob[beam_cnt];
306306
int dtag = TheLex.Hash( d_pnt->name );
307-
for( int ane = size-1; ane >=0; ane-- ){
307+
for( int ane = size-1; ane >=0; --ane ){
308308
if ( thisPProb <= n_best_array[ane]->prob )
309309
break;
310310
if ( ane == 0 ||
@@ -317,7 +317,7 @@ namespace Tagger {
317317
<< endl;
318318
// shift
319319
n_best_tuple *keep = n_best_array[size-1];
320-
for ( int ash = size-1; ash > ane; ash-- ){
320+
for ( int ash = size-1; ash > ane; --ash ){
321321
n_best_array[ash] = n_best_array[ash-1];
322322
}
323323
n_best_array[ane] = keep;
@@ -362,7 +362,7 @@ namespace Tagger {
362362

363363
void TaggerClass::ShowCats( ostream& os, const vector<int>& Pat, int slots ){
364364
os << "Pattern : ";
365-
for( int slot=0; slot < slots; slot++){
365+
for( int slot=0; slot < slots; ++slot ){
366366
os << indexlex( Pat[slot], TheLex )<< " ";
367367
}
368368
os << endl;
@@ -378,12 +378,12 @@ namespace Tagger {
378378
else
379379
slots = Ktemplate.totalslots() - Ktemplate.skipfocus;
380380
string line;
381-
for( int f=0; f < slots; f++ ){
381+
for( int f=0; f < slots; ++f ){
382382
line += indexlex( pat[f], TheLex );
383383
line += " ";
384384
}
385385
const vector<string> enr = mySentence.getEnrichments(word);
386-
for ( auto er: enr ){
386+
for ( const auto& er: enr ){
387387
line += er + " ";
388388
}
389389
if ( input_kind != UNTAGGED )
@@ -396,7 +396,7 @@ namespace Tagger {
396396
// dump if desired
397397
//
398398
if ( dumpflag ){
399-
for( int slot=0; slot < slots; slot++){
399+
for( int slot=0; slot < slots; ++slot ){
400400
cout << indexlex( pat[slot], TheLex );
401401
}
402402
cout << endl;
@@ -737,11 +737,11 @@ namespace Tagger {
737737

738738
DBG << "Start: " << mySentence.getword( 0 ) << endl;
739739
InitTest( mySentence, TestPat, Action );
740-
for ( unsigned int iword=1; iword < mySentence.size(); iword++ ){
740+
for ( unsigned int iword=1; iword < mySentence.size(); ++iword ){
741741
// clear best_array
742742
DBG << endl << "Next: " << mySentence.getword( iword ) << endl;
743743
Beam->ClearBest();
744-
for ( int beam_count=0; beam_count < Beam_Size; beam_count++ ){
744+
for ( int beam_count=0; beam_count < Beam_Size; ++beam_count ){
745745
if ( !NextBest( mySentence, TestPat, iword, beam_count ) )
746746
break;
747747
}
@@ -835,7 +835,7 @@ namespace Tagger {
835835
int& no_correct_unknown ){
836836
string tagstring;
837837
//now some output
838-
for ( unsigned int Wcnt=0; Wcnt < mySentence.size(); Wcnt++ ){
838+
for ( unsigned int Wcnt=0; Wcnt < mySentence.size(); ++Wcnt ){
839839
tagstring = indexlex( Beam->paths[0][Wcnt], TheLex );
840840
if ( mySentence.known(Wcnt) ){
841841
no_known++;

0 commit comments

Comments
 (0)