44#include "EST_FMatrix.h"
45#include "ling_class/EST_Relation.h"
47#include "EST_string_aux.h"
48#include "ling_class/EST_relation_aux.h"
49#include "ling_class/EST_relation_compare.h"
50#include "EST_io_aux.h"
55 return ((start(&b) < a.
F(
"end")) && (start(&a) < b.
F(
"end")));
63 for (ptr = a.
list.head(); ptr != 0; ptr = ptr->next())
73 for (ptr = b.
list.head(); ptr != 0; ptr = ptr->next())
97 if (
a_ptr->f(
"pos")==1)
113 if (
a_ptr->f(
"pos")==1)
116 if ((
b_ptr->f(
"pos")==1)
160 cout.setf(ios::left,ios::adjustfield);
165 cout <<
"Deletions: ";
168 cout <<
"Insertions: ";
178 if (
a_ptr->f(
"pos") == 1)
192 s =
fabs(start(&ref) - start(&test));
193 e =
fabs(ref.
F(
"end") - test.
F(
"end"));
195 return (s +
e) / duration(&ref);
204 s = (start(&test) < start(&ref)) ? start(&ref) - start(&test) : 0;
205 e = (ref.
F(
"end") < test.
F(
"end")) ?
206 test.
F(
"end") - ref.
F(
"end") : 0;
208 return (s +
e) / duration(&ref);
216 for (i = 0; i <
m.num_rows(); ++i)
217 if ((
m(i,
j) > -0.01) && (
m(i,
j) < val))
230 for (
int j = 0;
j <
m.num_columns(); ++
j)
233 for (i = 0; i <
m.num_rows(); ++i)
236 for (i = 0; i <
m.num_rows(); ++i)
247 for (i = 0; i <
m.num_rows(); ++i)
250 for (
j = 0;
j <
m.num_columns(); ++
j)
251 if ((
m(i,
j) < val) && (
m(i,
j) > -0.01))
253 for (
j = 0;
j <
m.num_columns(); ++
j)
263 for (i = 0; i <
m.num_rows(); ++i)
264 for (
j = 0;
j <
m.num_columns(); ++
j)
275 for (i = 0; i <
m.num_rows(); ++i)
276 for (
j = 0;
j <
m.num_columns(); ++
j)
280 return (
m.num_rows() - n);
289 for (i = 0; i <
m.num_rows(); ++i)
293 if (s->f(
"minor") == 1)
296 for (
j = 0;
j <
m.num_columns(); ++
j)
300 return (
m.num_rows() - n);
308 for (
j = 0;
j <
m.num_columns(); ++
j)
309 for (i = 0; i <
m.num_rows(); ++i)
313 return (
m.num_columns() - n);
322 for (
j = 0;
j <
m.num_columns(); ++
j)
326 if (s->f(
"minor") == 1)
329 for (i = 0; i <
m.num_rows(); ++i)
334 return (
m.num_columns() - n);
337int lowest_pos(
float *
m,
int n)
342 for (i = 0; i < n; ++i)
362 if (
r_ptr->f(
"pos")==1)
366 cout <<
"score is" << score <<
endl;
368 a =
r_ptr->rlink(
"blank").first();
369 cout <<
"score is" << score <<
" address: " << a <<
endl;
394 score =
new float[
reflab.length()];
397 if (
r_ptr->f(
"pos")==1)
401 a =
r_ptr->rlink(
"test").first();
407 if (
s_ptr->f(
"pos")==1)
408 if (
s_ptr->rlink(
"test").first() == a)
415 for (i = 0, p =
la.head(); p!= 0; p = p->next(), ++i)
422 pos = lowest_pos(score, i);
426 for (i = 0, p =
la.head(); p!= 0; p = p->next(), ++i)
430 t_ptr->rlink(
"test").clear();
460 if (
r_ptr->f(
"pos")==1)
464 if (
r_ptr->f(
"pos")==1)
469 if ((
m.num_rows() == 0) || (
m.num_columns() == 0))
476 if (
t_ptr->f(
"pos")==1)
479 if (
r_ptr->f(
"pos")==1)
494 minimise_matrix_by_column(
m);
495 minimise_matrix_by_row(
m);
496 matrix_ceiling(
m, t);
503 if (
r_ptr->f(
"pos")==1)
505 pos = lowest_pos(
m,
j);
527 StringtoStrList(
"m l mrb mfb lrb lfb",
rminorlist);
528 StringtoStrList(
"m l mrb mfb lrb lfb",
tminorlist);
535 pr = RelationList_ptr_extract(
rlist,
tlist(
pt).name(), TRUE);
555 ltot =
m.num_columns();
556 ldel = matrix_deletions(
m);
558 lins = matrix_insertions(
m);
582 cout <<
"Correct " <<
rc <<
"% Accuracy " <<
ra <<
"%" <<
endl;
583 cout <<
"Major Correct " <<
mrc <<
"% Accuracy " <<
mra <<
"%" <<
endl;
594 for (i = 0, s =
e.head(); s; s = inext(s))
595 if ((
int)s->f(
"pos"))
597 if (column_hit(
m, i) >= 0)
605 for (i = 0, s =
e.head(); s; s = inext(s))
606 if ((
int)s->f(
"pos"))
608 if (row_hit(
m, i) >= 0)
621 for (ptr = a.
list.head(); ptr != 0; ptr= ptr->next())
622 if (a.
val(ptr) == -1)
637 relation_match(ref.stream(name), test.stream(name));
640 function_match(
uref, ref.stream(name), test.stream(name));
641 function_match(
utest, test.stream(name), ref.stream(name));
667 a_ptr->link(b.stream_name())->clear();
668 if ((
a_ptr->f(
"pos")==1) && (
ua.val(
a_ptr->addr()) != -1))
669 a_ptr->make_link(b.stream_name(),
ua.val(
a_ptr->addr()));
673 b_ptr->link(a.stream_name())->clear();
674 if ((
b_ptr->f(
"pos")==1) && (
ub.val(
b_ptr->addr()) != -1))
675 b_ptr->make_link(a.stream_name(),
ub.val(
b_ptr->addr()));
709 c = (b == -1) ? -1:
ltest.val(b);
710 d = (c == -1) ? -1: f1.val(c);
738 compare_labels(ref, test,
"Event", f2,
inv_f2);
739 compare_labels(ref, test,
"Syllable", f1,
inv_f1);
743 cout <<
"Syllable mapping from ref to test\n" << f1;
744 cout <<
"Syllable mapping from test to ref\n" <<
inv_f1;
748 cout <<
"Event mapping from ref to test\n" << f2;
749 cout <<
"Event mapping from test to ref\n" <<
inv_f2;
755 cout <<
"Syllable_deletions: " << insdel(f1) <<
endl;
760 cout <<
"Event_deletions: " << insdel(f2) <<
endl;
765 function_match(
lref, ref.stream(
"Event"), ref.stream(
"Syllable"));
766 function_match(
ltest, test.stream(
"Event"), test.stream(
"Syllable"));
768 if (op.
present(
"print_functions"))
772 cout <<
"f1\n" << f1;
773 cout <<
"f2\n" << f2;
781 if (
a_ptr->f(
"pos")==1)
789 if (
a_ptr->f(
"pos")==1)
800 if (op.
present(
"print_derivation"))
804 if (
a_ptr->f(
"pos")==1)
810 cout <<
"f1(Lt(f2(ei))): "
816 cout <<
" is correct\n";
818 cout <<
" is incorrect\n";
826 cout.setf(ios::left,ios::adjustfield);
829 cout <<
m.num_columns();
830 cout <<
"Deletions: ";
832 cout << matrix_deletions(
m);
833 cout <<
"Insertions: ";
846 if (
r_ptr->f(
"pos")==1)
852 cout.setf(ios::right);
860 if (
t_ptr->f(
"pos")==1)
867 cout.setf(ios::right);
868 cout.setf(ios::fixed, ios::floatfield);
869 cout << a(i,
j) <<
" ";
880 for (i = 0; i <
m.num_columns(); ++i)
891 for (i = 0; i <
m.num_rows(); ++i)
898int num_b_insertions(
EST_FMatrix &
m,
int last,
int current)
901 c1 = column_hit(
m, last);
902 c2 = column_hit(
m, current);
907int num_b_deletions(
EST_FMatrix &
m,
int last,
int current)
910 c1 = row_hit(
m, last);
911 c2 = row_hit(
m, current);
938 for (s = a.
head(); s; s = inext(s))
940 if (s->f(
"pos") == 0)
942 else if (s->f(
"hit") == 1)
946 s->features().
clear();
954 for (a =
lab.head(); a; a = n)
1068 print_i_d_scores(
m);
1074 print_aligned_trans(ref, test,
m);
1075 print_i_d_scores(
m);
1081 print_matrix_scores(ref, test,
m);
1082 print_i_d_scores(
m);
1088 print_matrix_scores(ref, test,
m);
1089 print_aligned_trans(ref, test,
m);
1090 print_i_d_scores(
m);
1095 print_matrix_scores(ref, test,
m);
1096 error_location(ref,
m, 1);
1097 make_hit_and_miss(ref);
1098 error_location(test,
m, 0);
1099 make_hit_and_miss(test);
1100 ref.
save(
"ref.error");
1101 test.
save(
"test.errors");
1105 error_location(ref,
m, 1);
1106 make_hit_and_miss(ref);
1107 error_location(test,
m, 0);
1108 make_hit_and_miss(test);
1109 ref.
save(
"ref.error");
1110 test.
save(
"test.error");
void set(const EST_String &name, int ival)
const float F(const EST_String &name) const
int f_present(const EST_String &name) const
EST_write_status save(const EST_String &filename, bool evaluate_ff=false) const
const EST_String & name() const
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
EST_TList< EST_TKVI< K, V > > list
Linked list of key-val pairs. Don't use this as it will be made private in the future.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
const int present(const K &rkey) const
Returns true if key is present.
const K & key(EST_Litem *ptr, int m=1) const
find key, reference by ptr
int change_val(const K &rkey, const V &rval)
int change_key(EST_Litem *ptr, const K &rkey)
change name of key pair.
int num_columns() const
return number of columns
int num_rows() const
return number of rows