42 #include "ling_class/EST_Utterance.h"
45 static EST_Item *
const def_val_item_ptr = NULL;
46 template <>
EST_Item*
const *EST_Item_ptr_Vector::def_val = &def_val_item_ptr;
48 static EST_Item* error_return_item_ptr = NULL;
49 template <>
EST_Item* *EST_Item_ptr_Vector::error_return = &error_return_item_ptr;
51 #if defined(INSTANTIATE_TEMPLATES)
53 #include "../base_class/EST_TVector.cc"
60 float (*local_cost_function)(
const EST_Item *item1,
64 bool (*local_pruning_function)(
const int i,
69 bool dp_sub(
int i,
int j,
73 local_cost_function lcf,
74 local_pruning_function lpf,
78 void trace_back_and_link(
int i,
int j,
84 inline bool null_lpf(
const int,
const int,
const int,
const int)
92 local_cost_function lcf,
93 local_pruning_function lpf,
100 local_cost_function lcf,
105 return dp_match(lexical,surface,match,lcf,null_lpf,null_sym);
109 static float fixed_ins;
110 static float fixed_del;
111 static float fixed_sub;
118 if (s1->name() == s2->name())
122 if (s1->name() == null_sym)
124 else if (s2->name() == null_sym)
135 float ins,
float del,
float sub)
142 return dp_match(lexical, surface, match, fixed_local_cost,
143 null_lpf, &null_sym);
150 local_cost_function lcf,
151 local_pruning_function lpf,
171 l1 = lexical.
length() + 1;
172 l2 = surface.
length() + 1;
181 for (p=lexical.
head(),i=1; p != 0; p = p->next(),i++)
183 for (p=surface.
head(),i=1; p != 0; p = p->next(),i++)
211 if(!dp_sub(l1-1,l2-1,
214 lcf,lpf,null_sym,cost))
216 cerr <<
"No path found (over pruning ?)" << endl;
221 for (p = lexical.
head(); p; p = p->next())
234 trace_back_and_link(l1-1,l2-1,
237 DP_path_i,DP_path_j,null_sym);
243 bool dp_sub(
int i,
int j,
247 local_cost_function lcf,
248 local_pruning_function lpf,
261 int best_i=-1,best_j=-1;
263 float best_c=MAXFLOAT;
280 best_c = lcf(null_sym,null_sym);
286 if(dp_sub(i,j-1,vr1,vr2,
288 lcf,lpf, null_sym,cost))
292 best_c = lcf(null_sym,vr2(j)) + cost.a(i,j-1);
303 if(dp_sub(i-1,j,vr1,vr2,
305 lcf,lpf, null_sym,cost))
309 best_c = lcf(vr1(i),null_sym) + cost.a(i-1,j);
320 if(dp_sub(i-1,j-1,vr1,vr2,
322 lcf,lpf, null_sym,cost))
324 sub = 2 * lcf(vr1(i),vr2(j)) + cost(i-1,j-1);
333 if(dp_sub(i,j-1,vr1,vr2,
335 lcf,lpf, null_sym,cost))
337 ins=lcf(null_sym,vr2(j)) + cost(i,j-1);
346 if(dp_sub(i-1,j,vr1,vr2,
348 lcf,lpf, null_sym,cost))
350 del=lcf(vr1(i),null_sym) + cost(i-1,j);
360 cost.a(i,j) = best_c;
367 if(best_c == MAXFLOAT)
376 void trace_back_and_link(
int i,
int j,
394 if(DP_path_i(i,j) == i-1)
396 if(DP_path_j(i,j) == j-1)
400 p1->append_daughter(p2);
415 trace_back_and_link(DP_path_i(i,j), DP_path_j(i,j),