"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "main/align_main.cc" between
speech_tools-2.4-release.tar.gz and speech_tools-2.5.0-release.tar.gz

About: The speech_tools - Edinburgh Speech Tools Library (used by the Festival Speech Synthesis System).

align_main.cc  (speech_tools-2.4-release):align_main.cc  (speech_tools-2.5.0-release)
skipping to change at line 188 skipping to change at line 188
rts.open(reffile); rts.open(reffile);
hts.open(hypofile); hts.open(hypofile);
s_total=s_ins=s_del=s_sub=s_correct=0; s_total=s_ins=s_del=s_sub=s_correct=0;
while (!rts.eof()) while (!rts.eof())
{ {
EST_Utterance u; EST_Utterance u;
load_sentence(u,"ref",rts); load_sentence(u,"ref",rts);
load_sentence(u,"hypo",hts); load_sentence(u,"hypo",hts);
r = u.relation("ref")->last(); r = u.relation("ref")->rlast();
h = u.relation("hypo")->last(); h = u.relation("hypo")->rlast();
if ((!r->name().matches(id)) || if ((!r->name().matches(id)) ||
(r->name() != h->name())) (r->name() != h->name()))
{ {
cerr << "Align: failed to match sentence " << cerr << "Align: failed to match sentence " <<
sents << " at id " << r->name() << endl; sents << " at id " << r->name() << endl;
} }
else else
{ {
// Ids aren't counted as words // Ids aren't counted as words
r->unref_all(); r->unref_all();
skipping to change at line 272 skipping to change at line 272
const EST_String &alignrel, const EST_String &alignrel,
int &total,int &ins,int &del,int &sub,int &correct) int &total,int &ins,int &del,int &sub,int &correct)
{ {
// Score alignment // Score alignment
EST_Item *ri,*hi; EST_Item *ri,*hi;
total=ins=del=correct=sub=0; total=ins=del=correct=sub=0;
for (ri=u.relation(refrel)->first(), for (ri=u.relation(refrel)->first(),
hi=u.relation(hyporel)->first(); hi=u.relation(hyporel)->first();
ri; ri;
ri=ri->next(),hi=hi->next()) ri=inext(ri),hi=inext(hi))
{ {
for ( ; (as(hi,alignrel) == 0) && hi ; hi=hi->next()) for ( ; (as(hi,alignrel) == 0) && hi ; hi=inext(hi))
{ {
fprintf(stdout,"inserted: %s\n",(const char *)hi->name()); fprintf(stdout,"inserted: %s\n",(const char *)hi->name());
ins++; ins++;
} }
for ( ; (daughter1(ri,alignrel) == 0) && ri; ri=ri->next()) for ( ; (daughter1(ri,alignrel) == 0) && ri; ri=inext(ri))
{ {
fprintf(stdout,"deleted: %s\n",(const char *)ri->name()); fprintf(stdout,"deleted: %s\n",(const char *)ri->name());
del++; del++;
} }
if (!ri) if (!ri)
break; break;
if (name_distance(ri,daughter1(ri,alignrel)) == 0) if (name_distance(ri,daughter1(ri,alignrel)) == 0)
{ {
fprintf(stdout,"correct: %s\n",(const char *)ri->name()); fprintf(stdout,"correct: %s\n",(const char *)ri->name());
correct++; correct++;
} }
else else
{ {
fprintf(stdout,"substituted: %s\n",(const char *)ri->name()); fprintf(stdout,"substituted: %s\n",(const char *)ri->name());
sub++; sub++;
} }
} }
// For trailing hypothesized (or ref is nil) // For trailing hypothesized (or ref is nil)
for ( ; hi ; hi=hi->next()) for ( ; hi ; hi=inext(hi))
{ {
fprintf(stdout,"inserted: %s\n",(const char *)hi->name()); fprintf(stdout,"inserted: %s\n",(const char *)hi->name());
ins++; ins++;
} }
total = u.relation(refrel)->length(); total = u.relation(refrel)->length();
// fprintf(stdout,"total %d ins %d del %d subs %d correct %d\n", // fprintf(stdout,"total %d ins %d del %d subs %d correct %d\n",
// total, ins, del, sub, correct); // total, ins, del, sub, correct);
} }
skipping to change at line 357 skipping to change at line 357
dpt(i,0) = insdel_cost + dpt(i-1,0); dpt(i,0) = insdel_cost + dpt(i-1,0);
dpp(i,0) = -1; // deletion dpp(i,0) = -1; // deletion
} }
for (j=1; j < h_size+1; j++) for (j=1; j < h_size+1; j++)
{ {
dpt(0,j) = insdel_cost + dpt(0,j-1); dpt(0,j) = insdel_cost + dpt(0,j-1);
dpp(0,j) = 1; // insertion dpp(0,j) = 1; // insertion
} }
ri = utt.relation(refrel)->first(); ri = utt.relation(refrel)->first();
for (i=1; ri; ri=ri->next(),i++) for (i=1; ri; ri=inext(ri),i++)
{ {
ar->append(ri); // for use later ar->append(ri); // for use later
hi = utt.relation(hyporel)->first(); hi = utt.relation(hyporel)->first();
for (j=1; hi; hi=hi->next(),j++) for (j=1; hi; hi=inext(hi),j++)
{ {
cost = name_distance(ri,hi); cost = name_distance(ri,hi);
to_insert = insdel_cost + dpt(i,j-1); to_insert = insdel_cost + dpt(i,j-1);
to_del = insdel_cost + dpt(i-1,j); to_del = insdel_cost + dpt(i-1,j);
to_subs = (cost * subs_cost) + dpt(i-1,j-1); to_subs = (cost * subs_cost) + dpt(i-1,j-1);
if (to_insert < to_del) if (to_insert < to_del)
{ {
if (to_insert < to_subs) if (to_insert < to_subs)
{ {
dpt(i,j) = to_insert; dpt(i,j) = to_insert;
skipping to change at line 396 skipping to change at line 396
} }
else else
{ {
dpt(i,j) = to_subs; dpt(i,j) = to_subs;
dpp(i,j) = 0; dpp(i,j) = 0;
} }
} }
} }
} }
// for (i=1,ri=utt.relation(refrel)->first(); i < r_size+1; i++,ri=ri->next ()) // for (i=1,ri=utt.relation(refrel)->first(); i < r_size+1; i++,ri=inext(ri ))
// { // {
// fprintf(stdout,"%10s ",(const char *)ri->name()); // fprintf(stdout,"%10s ",(const char *)ri->name());
// for (j=1,hi=utt.relation(hyporel)->first(); j<h_size+1; j++,hi=hi->next() ) // for (j=1,hi=utt.relation(hyporel)->first(); j<h_size+1; j++,hi=inext(hi))
// fprintf(stdout,"%3d/%2d ",(int)dpt(i,j),dpp(i,j)); // fprintf(stdout,"%3d/%2d ",(int)dpt(i,j),dpp(i,j));
// fprintf(stdout,"\n"); // fprintf(stdout,"\n");
// } // }
for (i=r_size,j=h_size, for (i=r_size,j=h_size,
ri=utt.relation(refrel)->last(), ri=utt.relation(refrel)->rlast(),
hi=utt.relation(hyporel)->last(); hi=utt.relation(hyporel)->rlast();
ri; i--,ri=ri->prev()) ri; i--,ri=iprev(ri))
{ {
while (dpp(i,j) == 1) while (dpp(i,j) == 1)
{ {
j--; j--;
// fprintf(stdout,"skipping hi %s\n", // fprintf(stdout,"skipping hi %s\n",
// (const char *)hi->name()); // (const char *)hi->name());
hi=hi->prev(); hi=iprev(hi);
} }
if (dpp(i,j) == 0) if (dpp(i,j) == 0)
{ {
// fprintf(stdout,"linking %s %s\n", // fprintf(stdout,"linking %s %s\n",
// (const char *)ri->name(), // (const char *)ri->name(),
// (const char *)hi->name()); // (const char *)hi->name());
append_daughter(ri,alignrel,hi); append_daughter(ri,alignrel,hi);
j--; j--;
hi=hi->prev(); hi=iprev(hi);
} }
// else // else
// fprintf(stdout,"skipping ri %s\n", // fprintf(stdout,"skipping ri %s\n",
// (const char *)ri->name()); // (const char *)ri->name());
} }
} }
 End of changes. 12 change blocks. 
15 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)