56 return ((
start(&b) < a.
F(
"end")) && (
start(&a) < b.
F(
"end")));
96 for (i = 0, a_ptr = a.
head(); a_ptr != 0; a_ptr = a_ptr->
next(), ++i)
98 if (a_ptr->
f(
"pos")==1)
101 for (i_ptr = a_ptr->link(b.stream_name())->head(); i_ptr != 0;
102 i_ptr = i_ptr->
next())
103 u.
change_val(a_ptr->addr(), a_ptr->link(b.stream_name())->item(i_ptr));
113 for (a_ptr = a.
head(); a_ptr != 0; a_ptr = a_ptr->
next())
114 if (a_ptr->
f(
"pos")==1)
115 for (b_ptr = b.
head(); b_ptr != 0; b_ptr = b_ptr->
next())
117 if ((b_ptr->
f(
"pos")==1)
122 link(*a_ptr, *b_ptr);
138 cout <<
"Ref\n" << reflab;
139 cout <<
"Test\n" << testlab;
144 cout <<
"Ref\n" << reflab;
145 cout <<
"Test\n" << testlab;
146 cout <<
"Keyval REF\n" << uref;
147 cout <<
"Keyval TEST\n" << utest;
156 cout <<
"Keyval REF\n" << uref;
157 cout <<
"Keyval TEST\n" << utest;
165 cout << uref.length();
166 cout <<
"Deletions: ";
169 cout <<
"Insertions: ";
171 cout<<
insdel(utest) << endl;
178 for (a_ptr = a.
head(); a_ptr != 0; a_ptr = a_ptr->
next())
179 if (a_ptr->
f(
"pos") == 1)
194 e = fabs(ref.
F(
"end") - test.
F(
"end"));
206 e = (ref.
F(
"end") < test.
F(
"end")) ?
207 test.
F(
"end") - ref.
F(
"end") : 0;
218 if ((m(i, j) > -0.01) && (m(i, j) <
val))
252 if ((m(i, j) < val) && (m(i, j) > -0.01))
294 if (s->
f(
"minor") == 1)
327 if (s->
f(
"minor") == 1)
343 for (i = 0; i < n; ++i)
362 for (r_ptr = reflab.
head(); r_ptr != 0; r_ptr = r_ptr->
next())
363 if (r_ptr->
f(
"pos")==1)
367 cout <<
"score is" << score << endl;
369 a = r_ptr->rlink(
"blank").
first();
370 cout <<
"score is" << score <<
" address: " << a << endl;
395 score =
new float[reflab.
length()];
397 for (r_ptr = reflab.
head(); r_ptr != 0; r_ptr = r_ptr->
next())
398 if (r_ptr->
f(
"pos")==1)
402 a = r_ptr->rlink(
"test").
first();
407 for (s_ptr = r_ptr->
next(); s_ptr != 0; s_ptr = s_ptr->
next())
408 if (s_ptr->
f(
"pos")==1)
409 if (s_ptr->rlink(
"test").
first() == a)
412 cout <<
"la: " << la;
416 for (i = 0, p = la.head(); p!= 0; p = p->
next(), ++i)
418 t_ptr = reflab.item(la.item(p));
425 cout <<
"best is " << pos << endl;
427 for (i = 0, p = la.head(); p!= 0; p = p->
next(), ++i)
430 t_ptr = reflab.item(la.item(p));
431 t_ptr->rlink(
"test").clear();
452 int num_ref, num_test;
457 num_ref = num_test = 0;
460 for (r_ptr = testlab.
head(); r_ptr != 0; r_ptr = r_ptr->
next())
461 if (r_ptr->
f(
"pos")==1)
464 for (r_ptr = reflab.
head(); r_ptr != 0; r_ptr = r_ptr->
next())
465 if (r_ptr->
f(
"pos")==1)
476 for (i = 0, t_ptr = testlab.
head(); t_ptr != 0; t_ptr = t_ptr->
next())
477 if (t_ptr->
f(
"pos")==1)
479 for (j = 0, r_ptr = reflab.
head(); r_ptr != 0; r_ptr = r_ptr->
next())
480 if (r_ptr->
f(
"pos")==1)
484 else if (method == 2)
487 cerr <<
"Unknown comparision method" << method << endl;
520 EST_StrList rposlist, tposlist, rminorlist, tminorlist;
521 float ra, rc, mra, mrc;
528 int tot, del, ins, ltot, ldel, lins, lmdel, mdel, lmins, mins;
529 tot = del = ins = mdel = mins = 0;
531 for (pt = tlist.
head(); pt; pt = pt->
next())
571 rc = float(tot - del)/(float)tot * 100.0;
572 ra = float(tot - del -ins)/(float)tot *100.0;
573 mrc = float(tot - mdel)/(float)tot * 100.0;
574 mra = float(tot - mdel - mins)/(float)tot *100.0;
584 cout <<
"Total " << tot <<
" del: " << del <<
" ins: " << ins << endl;
585 cout <<
"Total " << tot <<
" major del " << mdel <<
" major ins" << mins << endl;
587 cout <<
"Correct " << rc <<
"% Accuracy " << ra <<
"%" << endl;
588 cout <<
"Major Correct " << mrc <<
"% Accuracy " << mra <<
"%" << endl;
599 for (i = 0, s = e.
head(); s; s = s->
next())
600 if ((
int)s->
f(
"pos"))
610 for (i = 0, s = e.
head(); s; s = s->
next())
611 if ((
int)s->
f(
"pos"))
627 if (a.
val(ptr) == -1)
670 for (a_ptr = a.
head(); a_ptr != 0; a_ptr = a_ptr->
next())
672 a_ptr->link(b.stream_name())->clear();
673 if ((a_ptr->
f(
"pos")==1) && (ua.
val(a_ptr->addr()) != -1))
674 a_ptr->make_link(b.stream_name(), ua.
val(a_ptr->addr()));
676 for (b_ptr = b.
head(); b_ptr != 0; b_ptr = b_ptr->
next())
678 b_ptr->link(a.stream_name())->clear();
679 if ((b_ptr->
f(
"pos")==1) && (ub.
val(b_ptr->addr()) != -1))
680 b_ptr->make_link(a.stream_name(), ub.
val(b_ptr->addr()));
693 for (a_ptr = a.
head(); a_ptr != 0; a_ptr = a_ptr->
next())
695 a_ptr->link(stream_type)->clear();
696 if ((a_ptr->
f(
"pos")==1) && (u.
val(a_ptr->addr()) != -1))
697 a_ptr->make_link(stream_type, u.
val(a_ptr->addr()));
714 c = (b == -1) ? -1: ltest.
val(b);
715 d = (c == -1) ? -1: f1.
val(c);
741 EST_II_KVL f2, inv_f2, inv_f1, f1, lref, ltest;
748 cout <<
"Syllable mapping from ref to test\n" << f1;
749 cout <<
"Syllable mapping from test to ref\n" << inv_f1;
753 cout <<
"Event mapping from ref to test\n" << f2;
754 cout <<
"Event mapping from test to ref\n" << inv_f2;
758 cout <<
"Syllable_insertions: " <<
insdel(inv_f1) << endl;
760 cout <<
"Syllable_deletions: " <<
insdel(f1) << endl;
763 cout <<
"Event_insertions: " <<
insdel(inv_f2) << endl;
765 cout <<
"Event_deletions: " <<
insdel(f2) << endl;
770 function_match(lref, ref.stream(
"Event"), ref.stream(
"Syllable"));
771 function_match(ltest, test.stream(
"Event"), test.stream(
"Syllable"));
773 if (op.
present(
"print_functions"))
775 cout <<
"Lref\n" << lref;
776 cout <<
"Ltest\n" << ltest;
777 cout <<
"f1\n" << f1;
778 cout <<
"f2\n" << f2;
782 int correct, n_ev, n_syl;
784 correct = n_ev = n_syl = 0;
785 for (a_ptr = ref.stream(
"Event").head(); a_ptr != 0; a_ptr = a_ptr->
next())
786 if (a_ptr->
f(
"pos")==1)
789 if (lref.
val(a_ptr->addr())
790 ==
commutate(a_ptr, f1, f2, lref, ltest))
793 for (a_ptr = ref.stream(
"Syllable").head();a_ptr != 0; a_ptr = a_ptr->
next())
794 if (a_ptr->
f(
"pos")==1)
798 cout <<
"Number_of_Syllables: " << n_syl << endl;
800 cout <<
"Number_of_Events: " << n_ev << endl;
803 cout <<
"Correct_links: " << correct <<endl;
805 if (op.
present(
"print_derivation"))
807 for (a_ptr = ref.stream(
"Event").head();a_ptr!= 0; a_ptr = a_ptr->
next())
809 if (a_ptr->
f(
"pos")==1)
811 cout <<
"Lr(ei): " << lref.
val(a_ptr->addr()) << endl;
812 cout <<
"f2(ei): " << f2.
val(a_ptr->addr()) << endl;
813 cout <<
"Lt(f2(ei)): " << ltest.
val(f2.
val(a_ptr->addr()))
815 cout <<
"f1(Lt(f2(ei))): " 816 << f1.
val(ltest.
val(f2.
val(a_ptr->addr()))) << endl;
818 cout <<
"Event " << *a_ptr;
819 if ( lref.
val(a_ptr->addr())
820 == f1.
val(ltest.
val(f2.
val(a_ptr->addr()))))
821 cout <<
" is correct\n";
823 cout <<
" is incorrect\n";
831 std::ios_base::fmtflags oldsetf = cout.setf(ios::fixed, ios::adjustfield);
833 std::streamsize oldwidth = cout.width(10);
835 cout <<
"Deletions: ";
838 cout <<
"Insertions: ";
842 cout.width(oldwidth);
852 for (r_ptr = ref.
head(); r_ptr != 0; r_ptr = r_ptr->
next())
854 if (r_ptr->
f(
"pos")==1)
858 cout << r_ptr->
name() <<
" ";
861 cout<< r_ptr->
F(
"end") <<
" ";
868 if (t_ptr->
f(
"pos")==1)
870 cout << t_ptr->
name() <<
" ";
876 cout.setf(ios::fixed, ios::floatfield);
877 cout << a(i, j) <<
" ";
946 for (s = a.
head(); s; s = s->
next())
948 if (s->
f(
"pos") == 0)
950 else if (s->
f(
"hit") == 1)
962 for (a = lab.
head(); a; a = n)
1063 int del,
int ins,
int v)
1108 ref.
save(
"ref.error");
1109 test.
save(
"test.errors");
1117 ref.
save(
"ref.error");
1118 test.
save(
"test.error");
void print_matrix_scores(EST_Relation &ref, EST_Relation &test, EST_FMatrix &a)
void minimise_matrix_by_column(EST_FMatrix &m)
const K & key(EST_Litem *ptr, int m=1) const
find key, reference by ptr
const EST_String name() const
Utility IO Function header file.
int change_key(EST_Litem *ptr, const K &rkey)
change name of key pair.
void remove_item(EST_Item *item)
void relation_match(EST_Relation &a, EST_Relation &b)
void reassign_links(EST_Relation &a, EST_Relation &b, EST_II_KVL &ua, EST_II_KVL &ub)
ssize_t num_columns() const
return number of columns
const EST_String name(void)
ssize_t major_matrix_insertions(EST_FMatrix &m, EST_Relation &ref_lab)
void pos_only(EST_Relation &lab)
void set(const EST_String &name, ssize_t ival)
void print_i_d_scores(EST_FMatrix &m)
STATIC void left(STATUS Change)
int insdel(EST_II_KVL &a)
STATIC void right(STATUS Change)
void threshold_labels(EST_Relation &reflab, float t)
ssize_t lowest_pos(const EST_FMatrix &m, ssize_t j)
ssize_t row_hit(EST_FMatrix &m, ssize_t r)
ssize_t num_rows() const
return number of rows
int change_val(const K &rkey, const V &rval)
void compare_labels(EST_Relation &reflab, EST_Relation &testlab)
const EST_Val f(const EST_String &name) const
float max(float a, float b)
int num_b_deletions(EST_FMatrix &m, int last, int current)
ssize_t matrix_insertions(EST_FMatrix &m)
void function_match(EST_II_KVL &u, EST_Relation &a, EST_Relation &b)
void print_aligned_trans(EST_Relation &ref, EST_Relation &test, EST_FMatrix &m)
void set_name(const EST_String &name) const
void multiple_labels(EST_Relation &reflab)
void print_results(EST_Relation &ref, EST_Relation &test, EST_FMatrix &m, int tot, int del, int ins, int v)
const EST_String & name() const
EST_Item * nthpos(EST_Relation &a, int n)
float F(const EST_String &name) const
void StringtoStrList(EST_String s, EST_StrList &l, EST_String sep)
Convert a EST_String to a EST_StrList by separating tokens in s delimited by the separator sep...
int commutate(EST_Item *a_ptr, EST_II_KVL &f1, EST_II_KVL &f2, EST_II_KVL &lref, EST_II_KVL <est)
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.
EST_Item * link(int l, EST_Item *n)
ssize_t major_matrix_deletions(EST_FMatrix &m, EST_Relation &ref_lab)
Templated Key-Value list. Objects of type EST_TKVL contain lists which are accessed by a key of type ...
void matrix_ceiling(EST_FMatrix &m, float max)
EST_Features & features() const
void print_s_trans(EST_Relation &a, int width)
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
void error_location(EST_Relation &e, EST_FMatrix &m, int ref)
ssize_t matrix_deletions(EST_FMatrix &m)
void append(const T &item)
add item onto end of list
EST_String basename(EST_String full, EST_String ext="")
This acts like the bourne shell basename command. By default, it strips any leading path from a strin...
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
float start(const EST_Item &item)
void multiple_matrix_compare(EST_RelationList &rlist, EST_RelationList &tlist, EST_FMatrix &m, EST_String rpos, EST_String tpos, int method, float t, int v)
void make_hit_and_miss(EST_Relation &a)
int present(const K &rkey) const
Returns true if key is present.
float duration(EST_Item *n)
EST_write_status save(const EST_String &filename, bool evaluate_ff=false) const
EST_Litem * RelationList_ptr_extract(EST_RelationList &mlf, const EST_String &filename, bool base)
void test_labels(EST_Utterance &ref, EST_Utterance &test, EST_Option &op)
int close_enough(EST_Item &a, EST_Item &b)
void monotonic_match(EST_II_KVL &a, EST_II_KVL &b)
float label_distance2(EST_Item &ref, EST_Item &test)
void clear(void)
remove all items in list
void minimise_matrix_by_row(EST_FMatrix &m)
float label_distance1(EST_Item &ref, EST_Item &test)
ssize_t column_hit(EST_FMatrix &m, ssize_t c)
EST_FMatrix matrix_compare(EST_Relation &reflab, EST_Relation &testlab, int method, float t, int v)
ssize_t num_b_insertions(EST_FMatrix &m, ssize_t last, ssize_t current)
Utility EST_String Functions header file.
int f_present(const EST_String &name) const