viterbi_main.cc (speech_tools-2.4-release) | : | viterbi_main.cc (speech_tools-2.5.0-release) | ||
---|---|---|---|---|
skipping to change at line 383 | skipping to change at line 383 | |||
FILE *fd; | FILE *fd; | |||
if (out_file == "-") | if (out_file == "-") | |||
fd = stdout; | fd = stdout; | |||
else if ((fd = fopen(out_file,"wb")) == NULL) | else if ((fd = fopen(out_file,"wb")) == NULL) | |||
{ | { | |||
cerr << "can't open \"" << out_file << "\" for output" << endl; | cerr << "can't open \"" << out_file << "\" for output" << endl; | |||
exit(-1); | exit(-1); | |||
} | } | |||
for (s=wstream.head(); s != 0 ; s=s->next()) | for (s=wstream.head(); s != 0 ; s=inext(s)) | |||
{ | { | |||
predict = s->f("best").string(); | predict = s->f("best").string(); | |||
pscore = s->f("best_score"); | pscore = s->f("best_score"); | |||
fprintf(fd,"%s %f\n",(const char *)predict,pscore); | fprintf(fd,"%s %f\n",(const char *)predict,pscore); | |||
} | } | |||
if (out_file != "") | if (out_file != "") | |||
fclose(fd); | fclose(fd); | |||
} | } | |||
skipping to change at line 447 | skipping to change at line 447 | |||
if (vocab.length() != obs.num_channels()) | if (vocab.length() != obs.num_channels()) | |||
{ | { | |||
cerr << "Number in vocab (" << vocab.length() << | cerr << "Number in vocab (" << vocab.length() << | |||
") not equal to observation's width (" << | ") not equal to observation's width (" << | |||
obs.num_channels() << ")" << endl; | obs.num_channels() << ")" << endl; | |||
exit(-1); | exit(-1); | |||
} | } | |||
if(w.empty()) | if(w.empty()) | |||
{ | ||||
for (i=0; i < obs.num_frames(); i++) | for (i=0; i < obs.num_frames(); i++) | |||
{ | ||||
add_word(w,itoString(i),i); | add_word(w,itoString(i),i); | |||
} | ||||
} | ||||
} | } | |||
static void load_given(const EST_String &filename, | static void load_given(const EST_String &filename, | |||
const int ngram_order) | const int ngram_order) | |||
{ | { | |||
EST_String word, pos; | EST_String word, pos; | |||
EST_Litem *p; | EST_Litem *p; | |||
int i,j; | int i,j; | |||
skipping to change at line 488 | skipping to change at line 493 | |||
// Load vocabulary (strings) | // Load vocabulary (strings) | |||
EST_TokenStream ts; | EST_TokenStream ts; | |||
if (ts.open(vfile) == -1) | if (ts.open(vfile) == -1) | |||
{ | { | |||
cerr << "can't find vocab file \"" << vfile << "\"" << endl; | cerr << "can't find vocab file \"" << vfile << "\"" << endl; | |||
exit(-1); | exit(-1); | |||
} | } | |||
while (!ts.eof()) | while (!ts.eof()) | |||
{ | ||||
if (ts.peek() != "") | if (ts.peek() != "") | |||
{ | ||||
vocab.append(ts.get().string()); | vocab.append(ts.get().string()); | |||
} | ||||
} | ||||
ts.close(); | ts.close(); | |||
} | } | |||
static void add_word(EST_Relation &w, const EST_String &word, int pos) | static void add_word(EST_Relation &w, const EST_String &word, int pos) | |||
{ | { | |||
EST_Item *item = w.append(); | EST_Item *item = w.append(); | |||
item->set_name(word); | item->set_name(word); | |||
item->set("pos",pos); | item->set("pos",pos); | |||
skipping to change at line 797 | skipping to change at line 806 | |||
} | } | |||
if(this_best == NULL) | if(this_best == NULL) | |||
break; // give up now - must have run out of candidates | break; // give up now - must have run out of candidates | |||
// move best candidate over to new list | // move best candidate over to new list | |||
if(prev_to_best == NULL) | if(prev_to_best == NULL) | |||
// best was head of list | // best was head of list | |||
all_c = this_best->next; | all_c = this_best->next; | |||
else | else | |||
{ | ||||
// best was not head of all_c | // best was not head of all_c | |||
prev_to_best->next = this_best->next; | prev_to_best->next = this_best->next; | |||
this_best->next = top_c; | this_best->next = top_c; | |||
top_c = this_best; | top_c = this_best; | |||
} | ||||
} | } | |||
delete all_c; | delete all_c; | |||
all_c = top_c; | all_c = top_c; | |||
/* | /* | |||
cerr << "Here are the top " << n_beam << " candidates" << endl; | cerr << "Here are the top " << n_beam << " candidates" << endl; | |||
for(p=all_c;p != NULL;p=p->next) | for(p=all_c;p != NULL;p=p->next) | |||
cerr << p->score << endl; | cerr << p->score << endl; | |||
*/ | */ | |||
End of changes. 9 change blocks. | ||||
1 lines changed or deleted | 12 lines changed or added |