44#include "ling_class/EST_Relation.h"
45#include "ling_class/EST_relation_aux.h"
46#include "EST_string_aux.h"
47#include "EST_io_aux.h"
48#include "EST_Option.h"
56 float ins,
float del,
float sub);
61 return (iprev(n) == 0) ? 0.0 : iprev(n)->
F(
"end");
66 return n->
F(
"end") - start(n);
79 a_ptr->set(
"end", end);
92 file1 = make_tmp_filename();
93 file2 = make_tmp_filename();
98 fprintf(
stderr,
"edit_labels: cannot open \"%s\" for writing\n",
121 fprintf(
stderr,
"edit_labels: cannot open \"%s\" for reading\n",
122 (
const char *)
file2);
142 for (a =
orig.head(); a != 0; a = inext(a))
143 if ((a->
F(
"end") > s) && (start(a) <
e))
146 if ((a->
F(
"end") >
e))
181 for (p =
oname.head(); p ; p = p->next())
190 for (p = s.head(); p; p = p->next())
200 for (s = a.
head(); s; s = inext(s))
201 if (!is_in_class(s->name(), vocab))
203 cerr<<
"Illegal entry in file " <<a.
name()<<
":\"" << *s <<
"\"\n";
245 for (p =
seg.head(); p != 0; p = inext(p))
249 if (map.
val(p->name()) ==
"!DELETE")
252 p->set_name(map.
val(p->name()));
277 for (ptr =
filenames.head(); ptr != NULL; ptr = ptr->next())
286 for (ptr =
tmp_filenames.head(); ptr != NULL; ptr = ptr->next())
325 for (p =
mlf.head(); p; p = p->next())
327 if (basename(
mlf(p).name(),
"*")==basename(filename,
"*"))
331 for (p =
mlf.head(); p; p = p->next())
333 if (basename(
mlf(p).name()) == filename)
337 cerr <<
"No match for file " << filename <<
" found in mlf\n";
350 for (p =
mlf.head(); p; p = p->next())
352 for (s =
mlf(p).head(); s; s = inext(s))
355 t->
set(
"name", s->
S(
"name"));
356 t->
set(
"end", s->
F(
"end") + last);
359 last = (t != 0) ? t->
F(
"end") : 0.0;
373 cerr <<
"RelationList has " <<
mlf.length() <<
" elements: expected "
374 << key.
length() <<
" from key file\n";
378 for (k = key.
head(), p =
mlf.head(); p; p = p->next(), k = inext(k))
381 for (s =
mlf(p).head(); s; s = inext(s))
384 t->
set(
"name", s->
S(
"name"));
385 t->
set(
"end", (s->
F(
"end") +
st));
407 if ((
keylab.tail())->F(
"end") < (
lab.tail())->F(
"end"))
409 cerr <<
"Key file must extend beyond end of label file\n";
414 for (k =
keylab.head(); k ; k = inext(k))
415 if (k->
F(
"end") >
lab.head()->F(
"end"))
419 a.
f.
set(
"name", (filename +
ext));
422 for (s =
lab.head(); s; s = inext(s))
431 if (n->
F(
"end") > k->
F(
"end"))
433 if (((n->
F(
"end") - k->
F(
"end")) <
434 (k->
F(
"end") - start(n))) ||
435 is_in_class(n->name(),
blank))
443 if (!is_in_class(n->name(),
blank))
457 a.
f.
set(
"name", (filename +
ext));
479 if ((
keylab.tail())->F(
"end") < (
lab.tail())->F(
"end"))
481 cerr <<
"Key file must extend beyond end of label file\n";
486 a.
f.
set(
"name", (k->name() +
ext));
489 for (s =
lab.head(); s; s = inext(s))
492 t->set_name(s->name());
495 if (s->
F(
"end") > k->
F(
"end"))
497 cout <<
"appending " << a;
501 k->
set(
"end", (s->
F(
"end")));
504 a.f.set(
"name", (k->name() +
ext));
507 cout <<
"appending " << a;
533 for (s =
target.head(); s; s = inext(s))
561 for (s =
target.head(); s; s = inext(s))
566 for (i = 1, p = s; p; p = inext(p), ++i)
574 for (i = 1; s !=p ; s = inext(s), ++i)
593 *utt.
relation(
"Match"), 7.0, 7.0, 7.0);
605 for (p =
mlf.head(); p; p = p->next())
607 if (basename(
mlf(p).name(),
"*")==basename(filename,
"*"))
611 for (p =
mlf.head(); p; p = p->next())
612 if (
mlf(p).name() == filename)
615 cerr <<
"No match for file " << filename <<
" found in mlf\n";
621 if (
al.present(
"-shift"))
622 shift_label(
lab,
al.fval(
"-shift"));
625 if (
al.present(
"-extend"))
626 al.override_fval(
"-length",
627 al.fval(
"-extend",0) *
lab.tail()->F(
"end"));
630 if (
al.present(
"-q"))
631 quantize(
lab,
al.fval(
"-q"));
633 if (
al.present(
"-start"))
635 if (!
al.present(
"-end"))
636 cerr <<
"-start option must be used with -end option\n";
638 extract(
lab,
al.fval(
"-start"),
al.fval(
"-end"),
lab);
641 if (
al.present(
"-class"))
642 convert_to_broad_class(
lab,
al.val(
"-class"), op);
644 else if (
al.present(
"-pos"))
647 StringtoStrList(
al.val(
"-lablist"),
bclass);
650 else if (
al.present(
"-sed"))
651 edit_labels(
lab,
al.val(
"-sed"));
652 else if (
al.present(
"-map"))
655 if (map.
load(
al.val(
"-map")) != format_ok)
668 for (s =
stream.head(); s; s = inext(s))
670 cout << s->name() <<
"\t:";
671 for(p.
begin(s->features()); p; ++p)
686 for (p =
mlf.head(); p; p = p->next())
690 for (p =
mlf.head(); p; p = p->next())
705 fname=basename(filename,
"*");
714 cerr <<
"No match for file " <<
fname <<
" found in mlf\n";
void set(const EST_String &name, int ival)
void set(const EST_String &name, int ival)
const EST_String S(const EST_String &name) const
const float F(const EST_String &name) const
EST_Item * as_relation(const char *relname) const
View item from another relation (const char *) method.
int f_present(const EST_String &name) const
EST_read_status load(const EST_String &filename, const EST_String &comment=";")
const EST_String & name() const
void begin(const Container &over)
Set the iterator ready to run over this container.
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.
EST_Relation * relation(const char *name, int err_on_not_found=1) const
get relation by name
EST_Relation * create_relation(const EST_String &relname)
create a new relation called <parameter>n</parameter>.