Edinburgh Speech Tools  2.1-release
EST_relation_aux.cc
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author : Paul Taylor and Simon King */
34 /* Date : June 1995 */
35 /*-----------------------------------------------------------------------*/
36 /* Relation class auxiliary routines */
37 /* */
38 /*=======================================================================*/
39 #include <cstdlib>
40 #include <iostream>
41 #include <fstream>
42 #include <cmath>
43 #include "EST_types.h"
46 #include "EST_string_aux.h"
47 #include "EST_io_aux.h"
48 #include "EST_Option.h"
49 #include "EST_Token.h"
50 
51 using namespace std;
52 
53 static int is_in_class(const EST_String &name, EST_StrList &s);
54 
55 bool dp_match(const EST_Relation &lexical,
56  const EST_Relation &surface,
57  EST_Relation &match,
58  float ins, float del, float sub);
59 
60 
61 float start(EST_Item *n)
62 {
63  return (n->prev() == 0) ? 0.0 : n->prev()->F("end");
64 }
65 
66 float duration(EST_Item *n)
67 {
68  return n->F("end") - start(n);
69 }
70 
71 void quantize(EST_Relation &a, float q)
72 {
73  EST_Item *a_ptr;
74  float end;
75 
76  for (a_ptr = a.head(); a_ptr != 0; a_ptr = a_ptr->next())
77  {
78  end = a_ptr->F("end") / q;
79  end = rint(end);
80  end = end * q;
81  a_ptr->set("end", end);
82  }
83 }
84 
85 // edit labels using a sed file to do the editing
86 
88 {
89  EST_Item *a_ptr;
90  EST_String command;
91  char newname[100];
92  FILE *fp;
93  EST_String file1, file2;
94  int system_result;
95  file1 = make_tmp_filename();
96  file2 = make_tmp_filename();
97 
98  fp = fopen(file1, "wb");
99  if (fp == NULL)
100  {
101  fprintf(stderr,"edit_labels: cannot open \"%s\" for writing\n",
102  (const char *)file1);
103  return -1;
104  }
105  for (a_ptr = a.head(); a_ptr != 0; a_ptr = a_ptr->next())
106  {
107  fprintf(fp, "%s\n", (const char*) a_ptr->name());
108  }
109  fclose(fp);
110 
111  command = "cat \"" + file1 + "\" | sed -f \"" + sedfile + "\" > " + file2;
112 
113  printf("command: %s\n", (const char*) command);
114  system_result = system((const char*) command);
115  if (system_result != 0)
116  {
117  fprintf(stderr, "Error running command. Command returned %d\n",
118  system_result);
119  return -1;
120  }
121 
122  fp = fopen(file2, "rb");
123  if (fp == NULL)
124  {
125  fprintf(stderr,"edit_labels: cannot open \"%s\" for reading\n",
126  (const char *)file2);
127  return -1;
128  }
129  for (a_ptr = a.head(); a_ptr != 0; a_ptr = a_ptr->next())
130  {
131  if (fscanf(fp, "%99s", newname) != 1)
132  cerr << "Error reading newname from file" << endl;
133 // cout << "oldname: " << a_ptr->name() << " newname: " << newname << endl;
134  a_ptr->set_name(newname);
135  }
136  fclose(fp);
137  return 0;
138 }
139 
140 // make new EST_Relation from start and end points.
141 void extract(const EST_Relation &orig, float s,
142  float e, EST_Relation &ex)
143 {
144  EST_Item *a;
145  EST_Item *tmp;
146 
147  for (a = orig.head(); a != 0; a = a->next())
148  if ((a->F("end") > s) && (start(a) < e))
149  {
150  tmp = ex.append(a);
151  if ((a->F("end") > e))
152  tmp->set("end", e);
153  }
154 }
155 
156 void merge_all_label(EST_Relation &seg, const EST_String &labtype)
157 {
158  EST_Item *a_ptr, *n_ptr;
159  (void)labtype; // unused parameter
160 
161  for (a_ptr = seg.head(); a_ptr != seg.tail(); a_ptr = n_ptr)
162  {
163  n_ptr = a_ptr->next();
164  if (a_ptr->name() == a_ptr->next()->name())
165  seg.remove_item(a_ptr);
166  }
167 }
168 
169 void change_label(EST_Relation &seg, const EST_String &oname,
170  const EST_String &nname)
171 {
172  EST_Item *a_ptr;
173 
174  for (a_ptr = seg.head(); a_ptr != 0; a_ptr = a_ptr->next())
175  if (a_ptr->name() == oname)
176  a_ptr->set_name(nname);
177 }
178 
179 void change_label(EST_Relation &seg, const EST_StrList &oname,
180  const EST_String &nname)
181 {
182  EST_Item *a_ptr;
183  EST_Litem *p;
184 
185  for (a_ptr = seg.head(); a_ptr != 0; a_ptr = a_ptr->next())
186  for (p = oname.head(); p ; p = p->next())
187  if (a_ptr->name() == oname(p))
188  a_ptr->set_name(nname);
189 }
190 
191 static int is_in_class(const EST_String &name, EST_StrList &s)
192 {
193  EST_Litem *p;
194 
195  for (p = s.head(); p; p = p->next())
196  if (name == s(p))
197  return TRUE;
198 
199  return FALSE;
200 }
201 
203 {
204  EST_Item *s;
205  for (s = a.head(); s; s = s->next())
206  if (!is_in_class(s->name(), vocab))
207  {
208  cerr<<"Illegal entry in file " <<a.name()<< ":\"" << *s << "\"\n";
209  return -1;
210  }
211  return 0;
212 }
213 
214 void convert_to_broad_class(EST_Relation &seg, const EST_String &class_type,
215  EST_Option &options)
216 {
217  // class_type contains a list of whitepsace separated segment names.
218  // This function looks at each segment and adds a feature "pos"
219  // if its name is contained in the list.
220  EST_String tmp_class_type = class_type + "_list";
221  EST_String bc_list(options.val(tmp_class_type, 1));
222  EST_StrList pos_list;
223  EST_TokenStream ts;
224 
225  ts.open_string(bc_list);
226  while (!ts.eof())
227  pos_list.append(ts.get().string());
228 
229  convert_to_broad(seg, pos_list);
230 }
231 
233  EST_String broad_name, int polarity)
234 {
235  EST_Item *a_ptr;
236  if (broad_name == "")
237  broad_name = "pos";
238 
239  for (a_ptr = seg.head(); a_ptr != 0; a_ptr = a_ptr->next())
240  if (is_in_class(a_ptr->name(), pos_list))
241  a_ptr->set(broad_name, (polarity) ? 1 : 0);
242  else
243  a_ptr->set(broad_name, (polarity) ? 0 : 1);
244 }
245 
247 {
248  EST_Item *p, *n;
249 
250  for (p = seg.head(); p != 0; p = n)
251  {
252  n = p->next();
253  if (map.present(p->name()))
254  {
255  if (map.val(p->name()) == "!DELETE")
256  seg.remove_item(p);
257  else
258  p->set_name(map.val(p->name()));
259  }
260 
261  }
262 }
263 
264 void shift_label(EST_Relation &seg, float shift)
265 {
266  //shift every end time by adding x seconds.
267  EST_Item *a_ptr;
268 
269  for (a_ptr = seg.head(); a_ptr != 0; a_ptr = a_ptr->next())
270  a_ptr->set("end", a_ptr->F("end") + shift);
271 }
272 
274  exact_match)
275 {
276  // select only files in 'filenames'
277  // remove all others from mlf
278  EST_Litem *fptr, *ptr;
279  bool flag;
280 
281  // if not exact match, only match basenames
282  EST_StrList tmp_filenames;
283  for (ptr = filenames.head(); ptr != NULL; ptr = ptr->next())
284  if(exact_match)
285  tmp_filenames.append( filenames(ptr) );
286  else
287  tmp_filenames.append( basename(filenames(ptr)) );
288 
289  for(fptr=mlf.head(); fptr != NULL;)
290  {
291  flag=false;
292  for (ptr = tmp_filenames.head(); ptr != NULL; ptr = ptr->next())
293  if(exact_match)
294  {
295  if(tmp_filenames(ptr) == mlf(fptr).name())
296  {
297  flag=true;
298  break;
299  }
300  }
301  else if(mlf(fptr).name().contains(tmp_filenames(ptr)))
302  {
303  flag=true;
304  break;
305  }
306 
307  if(!flag)
308  {
309  fptr = mlf.remove(fptr);
310 
311  if(fptr==0) // must have removed head of list
312  fptr=mlf.head();
313  else
314  fptr=fptr->next();
315  }
316  else
317  fptr=fptr->next();
318  }
319  tmp_filenames.clear();
320 }
321 
322 // look for a single file called "filename" and make a EST_Relation out of
323 // this
325 {
326 
327  EST_Litem *p;
328  EST_String test, ref;
329 
330  if (base)
331  for (p = mlf.head(); p; p = p->next())
332  {
333  if (basename(mlf(p).name(), "*")==basename(filename, "*"))
334  return mlf(p);
335  }
336  else
337  for (p = mlf.head(); p; p = p->next())
338  {
339  if (basename(mlf(p).name()) == filename)
340  return mlf(p);
341  }
342 
343  cerr << "No match for file " << filename << " found in mlf\n";
344  EST_Relation d;
345  return d;
346 }
347 
348 // combine all relation in MLF into a single relation.
350 {
351  EST_Litem *p;
352  EST_Relation all;
353  EST_Item *s, *t = 0;
354  float last = 0.0;
355 
356  for (p = mlf.head(); p; p = p->next())
357  {
358  for (s = mlf(p).head(); s; s = s->next())
359  {
360  t = all.append();
361  t->set("name", s->S("name"));
362  t->set("end", s->F("end") + last);
363  cout << "appended t " << t << endl;
364  }
365  last = (t != 0) ? t->F("end") : 0.0;
366  }
367  return all;
368 }
369 
371 {
372  EST_Litem *p;
373  EST_Relation all;
374  EST_Item *s, *t = 0, *k;
375  float st;
376 
377  if (key.length() != mlf.length())
378  {
379  cerr << "RelationList has " << mlf.length() << " elements: expected "
380  << key.length() << " from key file\n";
381  return all;
382  }
383 
384  for (k = key.head(), p = mlf.head(); p; p = p->next(), k = k->next())
385  {
386  st = start(k);
387  for (s = mlf(p).head(); s; s = s->next())
388  {
389  t = all.append();
390  t->set("name", s->S("name"));
391  t->set("end", (s->F("end") + st));
392  }
393  }
394  return all;
395 }
396 
398  EST_Relation &keylab,
399  EST_StrList &blank, EST_String ext)
400 { // divides a single relation into multiple chunks according to the
401  // keylab relation. If the keylab boundary falls in the middle of a label,
402  // the label is assigned to the chunk which has the most overlap with
403  // it. Some labels may be specified in the "blank" list which means thy
404  // are duplicated across boundaries.
405 
406  EST_Relation a, newkey;
407  EST_Item *s, *k, *t = 0, *n;
408  EST_String filename;
409  float kstart;
410 
411  slist.clear();
412 
413  if ((keylab.tail())->F("end") < (lab.tail())->F("end"))
414  {
415  cerr << "Key file must extend beyond end of label file\n";
416  return -1;
417  }
418 
419  // find a the first keylab that will make a non-empty file
420  for (k = keylab.head(); k ; k = k->next())
421  if (k->F("end") > lab.head()->F("end"))
422  break;
423  if (k != NULL)
424  filename = (EST_String)k->f("file");
425  else
426  filename = "no_name";
427  a.f.set("name", (filename + ext));
428  kstart = 0.0;
429 
430  for (s = lab.head(); s; s = s->next())
431  {
432  n = s->next();
433  if (n == 0)
434  {
435  t = a.append(s);
436  t->set("end", (s->F("end") - kstart));
437  break;
438  }
439  if (n->F("end") > k->F("end"))
440  {
441  if (((n->F("end") - k->F("end")) <
442  (k->F("end") - start(n))) ||
443  is_in_class(n->name(), blank))
444  {
445  t = a.append(s);
446  t->set("end", (s->F("end") - kstart));
447 
448  t = a.append(n);
449  t->set("end", (k->F("end") - kstart));
450 
451  if (!is_in_class(n->name(), blank))
452  s = s->next();
453  }
454  else
455  {
456  t = a.append(s);
457  t->set("end", (k->F("end") - kstart));
458  }
459 
460  slist.append(a);
461  k = k->next();
462  kstart = start(k);
463  a.clear();
464  filename = (EST_String)k->f("file");
465  a.f.set("name", (filename + ext));
466  }
467  else
468  {
469  t = a.append(s);
470  t->set("end", (s->F("end") - kstart));
471  }
472  }
473  slist.append(a);
474 
475  return 0;
476 }
477 
479  EST_Relation &keylab, EST_String ext)
480 {
481  EST_Relation a, newkey;
482  EST_Item *s, *k, *t;
483  float kstart;
484 
485  mlf.clear();
486 
487  if ((keylab.tail())->F("end") < (lab.tail())->F("end"))
488  {
489  cerr << "Key file must extend beyond end of label file\n";
490  return -1;
491  }
492 
493  k = keylab.head();
494  a.f.set("name", (k->name() + ext));
495  kstart = 0.0;
496 
497  for (s = lab.head(); s; s = s->next())
498  {
499  t = a.append();
500  t->set_name(s->name());
501  t->set("end", (s->F("end") - kstart));
502 
503  if (s->F("end") > k->F("end"))
504  {
505  cout << "appending " << a;
506  mlf.append(a);
507 
508  kstart = s->F("end");
509  k->set("end", (s->F("end")));
510  k = k->next();
511  a.clear();
512  a.f.set("name", (k->name() + ext));
513  }
514  }
515  cout << "appending " << a;
516  mlf.append(a);
517 
518  return 0;
519 }
520 
521 
522 
523 
524 void map_match_times(EST_Relation &target, const EST_String &match_name,
525  const EST_String &time_name, bool do_start)
526 {
527  EST_Item *s, *t, *p;
528  float prev_end, inc, first_end, last_end;
529  int i;
530 
531  // first pass, copy times as appropriate, and find first
532  // and last defined ends
533  // This is hacky and certainly won't work for many cases
534 
535  first_end = -1.0;
536  prev_end = 0.0;
537  last_end = 0.0;
538 
539 // cout << "surface: " << surface << endl;
540 
541  for (s = target.head(); s; s = s->next())
542  {
543  if ((t = daughter1(s->as_relation(match_name))) != 0)
544  {
545  s->set(time_name + "end", t->F("end"));
546  if (do_start)
547  s->set(time_name + "start", t->F("start"));
548 
549  last_end = t->F("end");
550  if (first_end < 0.0)
551  first_end = t->F("end");
552  }
553  }
554 
555  if (!target.head()->f_present(time_name + "end"))
556  {
557  target.head()->set(time_name + "end", first_end / 2.0);
558  if (do_start)
559  target.head()->set(time_name + "start", 0.0);
560  }
561 
562  if (!target.tail()->f_present(time_name + "end"))
563  {
564  target.tail()->set(time_name + "end", last_end + 0.01);
565  if (do_start)
566  target.tail()->set(time_name + "start", last_end);
567  }
568 
569  for (s = target.head(); s; s = s->next())
570  {
571  if (!s->f_present(time_name + "end"))
572  {
573 // cout << "missing end feature for " << *s << endl;
574  for (i = 1, p = s; p; p = p->next(), ++i)
575  if (p->f_present(time_name + "end"))
576  break;
577  inc = (p->F(time_name + "end") - prev_end) / ((float) i);
578 // cout << "inc is : " << inc << endl;
579 
580 // cout << "stop phone is " << *p << endl;
581 
582  for (i = 1; s !=p ; s = s->next(), ++i)
583  {
584  s->set(time_name + "end", (prev_end + ((float) i * inc)));
585  if (do_start)
586  s->set(time_name + "start", (prev_end+((float) (i - 1 )* inc)));
587  }
588  }
589  prev_end = s->F("end");
590  }
591 }
592 
593 void dp_time_align(EST_Utterance &utt, const EST_String &source_name,
594  const EST_String &target_name,
595  const EST_String &time_name,
596  bool do_start)
597 {
598  utt.create_relation("Match");
599 
600  dp_match(*utt.relation(target_name), *utt.relation(source_name),
601  *utt.relation("Match"), 7.0, 7.0, 7.0);
602 
603  map_match_times(*utt.relation(target_name), "Match", time_name, do_start);
604 }
605 
606 
608 {
609  EST_Litem *p;
610  EST_String test, ref;
611 
612  if (base)
613  for (p = mlf.head(); p; p = p->next())
614  {
615  if (basename(mlf(p).name(), "*")==basename(filename, "*"))
616  return p;
617  }
618  else
619  for (p = mlf.head(); p; p = p->next())
620  if (mlf(p).name() == filename)
621  return p;
622 
623  cerr << "No match for file " << filename << " found in mlf\n";
624  return 0;
625 }
626 
628 {
629  if (al.present("-shift"))
630  shift_label(lab, al.fval("-shift"));
631 
632  // fix option later.
633  if (al.present("-extend"))
634  al.override_fval("-length",
635  al.fval("-extend",0) * lab.tail()->F("end"));
636 
637  // quantize (ie round up or down) label times
638  if (al.present("-q"))
639  quantize(lab, al.fval("-q"));
640 
641  if (al.present("-start"))
642  {
643  if (!al.present("-end"))
644  cerr << "-start option must be used with -end option\n";
645  else
646  extract(lab, al.fval("-start"), al.fval("-end"), lab);
647  }
648 
649  if (al.present("-class"))
650  convert_to_broad_class(lab, al.val("-class"), op);
651 
652  else if (al.present("-pos"))
653  {
654  EST_StrList bclass;
655  StringtoStrList(al.val("-lablist"), bclass);
656  convert_to_broad(lab, bclass);
657  }
658  else if (al.present("-sed"))
659  edit_labels(lab, al.val("-sed"));
660  else if (al.present("-map"))
661  {
662  EST_Option map;
663  if (map.load(al.val("-map")) != format_ok)
664  return;
665  label_map(lab, map);
666  }
667 }
668 
669 
670 
672 {
673  EST_Item *s;
675 
676  for (s = stream.head(); s; s = s->next())
677  {
678  cout << s->name() << "\t:";
679  for(p.begin(s->features()); p; ++p)
680  cout << p->k << " "
681  << p->v << "; ";
682  cout << endl;
683  }
684 
685 }
686 
687 
689  EST_hashedRelationList &hash_table,
690  const bool base)
691 {
692  EST_Litem *p;
693  if (base)
694  for (p = mlf.head(); p; p = p->next())
695  hash_table.add_item(basename(mlf(p).name(), "*"),
696  &(mlf(p)));
697  else
698  for (p = mlf.head(); p; p = p->next())
699  hash_table.add_item(mlf(p).name(),
700  &(mlf(p)));
701 }
702 
703 
705  const EST_hashedRelationList &hash_table,
706  const EST_String &filename, bool base)
707 {
708  EST_Relation *d;
709  EST_String fname = filename;
710  int found;
711 
712  if (base)
713  fname=basename(filename, "*");
714 
715  d=hash_table.val(fname,found);
716 
717  if(found)
718  {
719  rel = d;
720  return true;
721  }
722  cerr << "No match for file " << fname << " found in mlf\n";
723  return false;
724 }
725 
726 
EST_Item * head() const
Definition: EST_Relation.h:121
EST_TokenStream & get(EST_Token &t)
get next token in stream
Definition: EST_Token.cc:499
float end(const EST_Item &item)
Definition: EST_item_aux.cc:96
void print_relation_features(EST_Relation &stream)
void shift_label(EST_Relation &seg, float shift)
void relation_convert(EST_Relation &lab, EST_Option &al, EST_Option &op)
const EST_String name() const
Definition: EST_Item.h:250
Utility IO Function header file.
void change_label(EST_Relation &seg, const EST_String &oname, const EST_String &nname)
void remove_item(EST_Item *item)
EST_Item * tail() const
Definition: EST_Relation.h:127
void convert_to_broad(EST_Relation &seg, EST_StrList &pos_list, EST_String broad_name, int polarity)
EST_Relation * create_relation(const EST_String &relname)
create a new relation called n.
float start(EST_Item *n)
void set(const EST_String &name, ssize_t ival)
Definition: EST_Item.h:185
int override_fval(const EST_String rkey, const float rval)
add to end of list or overwrite. If rval is empty, do nothing
Definition: EST_Option.cc:62
void label_map(EST_Relation &seg, EST_Option &map)
int length() const
float fval(const EST_String &rkey, int m=1) const
Definition: EST_Option.cc:104
int edit_labels(EST_Relation &a, EST_String sedfile)
void set(const EST_String &name, int ival)
Definition: EST_Features.h:186
A specialised hash table for when the key is an EST_String.
Definition: EST_THash.h:304
EST_String make_tmp_filename()
Make a unique temporary filename.
Definition: util_io.cc:56
int check_vocab(EST_Relation &a, EST_StrList &vocab)
EST_Item * as_relation(const char *relname) const
View item from another relation (const char *) method.
Definition: EST_Item.h:316
void convert_to_broad_class(EST_Relation &seg, const EST_String &class_type, EST_Option &options)
EST_UItem * next()
Definition: EST_UList.h:55
void quantize(EST_Relation &a, float q)
float duration(EST_Item *n)
const EST_Val f(const EST_String &name) const
Definition: EST_Item.h:260
int open_string(const EST_String &newbuffer)
open a EST_TokenStream for string rather than a file
Definition: EST_Token.cc:264
void RelationList_select(EST_RelationList &mlf, EST_StrList filenames, bool exact_match)
EST_Relation RelationList_combine(EST_RelationList &mlf)
int eof()
end of file
Definition: EST_Token.h:362
void set_name(const EST_String &name) const
Definition: EST_Item.h:254
void map_match_times(EST_Relation &target, const EST_String &match_name, const EST_String &time_name, bool do_start)
const EST_String & name() const
Definition: EST_Relation.h:118
EST_FMatrix sub(const EST_FMatrix &a, ssize_t row, ssize_t col)
Definition: vec_mat_aux.cc:187
EST_read_status load(const EST_String &filename, const EST_String &comment=";")
Definition: EST_Option.cc:144
EST_Item * prev() const
Definition: EST_Item.h:350
float F(const EST_String &name) const
Definition: EST_Item.h:135
V & val(const K &key, int &found) const
Definition: EST_THash.cc:114
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...
void build_RelationList_hash_table(EST_RelationList &mlf, EST_hashedRelationList &hash_table, const bool base)
hashed relation lists for super speed
int relation_divide2(EST_RelationList &mlf, EST_Relation &lab, EST_Relation &keylab, EST_String ext)
#define FALSE
Definition: EST_bool.h:119
NULL
Definition: EST_WFST.cc:55
bool dp_match(const EST_Relation &lexical, const EST_Relation &surface, EST_Relation &match, float ins, float del, float sub)
EST_Features & features() const
Definition: EST_Item.h:258
bool hashed_RelationList_extract(EST_Relation *&rel, const EST_hashedRelationList &hash_table, const EST_String &filename, bool base)
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
Definition: EST_TKVL.cc:145
EST_Relation RelationList_extract(EST_RelationList &mlf, const EST_String &filename, bool base)
void append(const T &item)
add item onto end of list
Definition: EST_TList.h:196
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...
Definition: util_io.cc:167
int add_item(const K &key, const V &value, int no_search=0)
Add an entry to the table.
Definition: EST_THash.cc:167
EST_Item * next() const
Definition: EST_Item.h:348
int length() const
Definition: EST_UList.cc:57
EST_Features f
Definition: EST_Relation.h:101
void begin(const Container &over)
Set the iterator ready to run over this container.
void extract(const EST_Relation &orig, float s, float e, EST_Relation &ex)
#define format_ok
int relation_divide(EST_RelationList &slist, EST_Relation &lab, EST_Relation &keylab, EST_StrList &blank, EST_String ext)
int present(const K &rkey) const
Returns true if key is present.
Definition: EST_TKVL.cc:222
EST_Litem * RelationList_ptr_extract(EST_RelationList &mlf, const EST_String &filename, bool base)
EST_UItem * head() const
Definition: EST_UList.h:97
const EST_String S(const EST_String &name) const
Definition: EST_Item.h:144
EST_Relation * relation(const char *name, int err_on_not_found=1) const
get relation by name
EST_Item * append(EST_Item *si)
Definition: EST_Relation.cc:88
LISP fp
Definition: kkcompile.cc:63
void dp_time_align(EST_Utterance &utt, const EST_String &source_name, const EST_String &target_name, const EST_String &time_name, bool do_start)
EST_String
#define TRUE
Definition: EST_bool.h:118
void merge_all_label(EST_Relation &seg, const EST_String &labtype)
EST_Item * daughter1(const EST_Item *n)
return first daughter of n
void clear(void)
remove all items in list
Definition: EST_TList.h:244
EST_StrVector vocab
Definition: dp_main.cc:85
EST_Litem * remove(EST_Litem *ptr)
Definition: EST_TList.h:180
Utility EST_String Functions header file.
int f_present(const EST_String &name) const
Definition: EST_Item.h:236