43#include "ling_class/EST_Relation.h"
44#include "ling_class/EST_Item.h"
45#include "relation_io.h"
97 nn = p_tail->insert_after(
si);
126 nn = p_head->insert_before(
si);
150 s->evaluate_features();
168 p_head = inext(
node);
170 p_tail = iprev(
node);
176 for (
EST_Item *s = p_head; s; s = next_item(s))
187 if (from.
root() != 0)
200 else if (type ==
"htk")
201 return save_htk_label(&
outf,*
this);
204 EST_warning(
"EST_Relation: unsupported type: \"%s\"", (
const char *)type);
214 return save_esps_label(filename,*
this,
evaluate_ff);
215 else if (type ==
"htk")
216 return save_htk_label(filename,*
this);
219 EST_warning(
"EST_Relation: unsupported type: \"%s\"", (
const char *)type);
235 outf <<
"Relation " <<
name() <<
" ; ";
243EST_write_status EST_Relation::save_items(
EST_Item *
node,
268 (n->contents() == 0 ? 0 :
cnames.val(n->contents())) <<
" " <<
269 (iup(n) == 0 ? 0 :
nodenames.val(iup(n))) <<
" " <<
270 (idown(n) == 0 ? 0 :
nodenames.val(idown(n))) <<
" " <<
271 (inext(n) == 0 ? 0 :
nodenames.val(inext(n))) <<
" " <<
283 if (
ts.get() !=
"Relation")
285 cerr <<
"load_relation: " <<
ts.pos_description() <<
286 " no new Relation" <<
endl;
287 return misc_read_error;
289 p_name =
ts.get().string();
292 cerr <<
"load_relation: " <<
ts.pos_description() <<
293 " semicolon missing after Relation name \"" <<
294 p_name <<
"\"" <<
endl;
295 return misc_read_error;
298 return misc_read_error;
299 if (load_items(
ts,contents) != format_ok)
300 return misc_read_error;
310 if (
ts.get() !=
"Relation")
312 cerr <<
"load_relation: " <<
ts.pos_description() <<
313 " no new Relation" <<
endl;
314 return misc_read_error;
316 p_name =
ts.get().string();
319 cerr <<
"load_relation: " <<
ts.pos_description() <<
320 " semicolon missing after Relation name \"" <<
321 p_name <<
"\"" <<
endl;
322 return misc_read_error;
325 return misc_read_error;
326 if (load_items(
ts,contents) != format_ok)
327 return misc_read_error;
332void EST_Relation::node_tidy_up_val(
int &k,
EST_Val &v)
366 EST_read_status r = format_ok;
371 while (
ts.peek() !=
"End_of_Relation")
378 EST_error(
"Unknown item %d",
name);
382 rel=
node->relation();
394 cerr <<
"load_nodes: " <<
ts.pos_description() <<
395 " node's item contents" <<
siname <<
" doesn't exist\n";
418 node->link_feats.set_val(
"link" + itoString(i),est_val(item));
430 p_head = get_item_from_name(
nodenames,1);
431 p_tail = last(p_head);
432 if (!p_head->verify())
434 cerr <<
"load_nodes: " <<
ts.pos_description() <<
435 " nodes do not form consistent graph" <<
endl;
464 EST_read_status r = format_ok;
469 while (
ts.peek() !=
"End_of_Relation")
476 EST_error(
"Unknown item %d",
name);
480 rel=
node->relation();
491 cerr <<
"load_nodes: " <<
ts.pos_description() <<
492 " node's stream item " <<
siname <<
" doesn't exist\n";
497 node->set_contents(c);
525 p_head = get_item_from_name(
nodenames,1);
527 p_tail = last(p_head);
528 if (p_head && !p_head->verify())
530 cerr <<
"load_nodes: " <<
ts.pos_description() <<
531 " nodes do not form consistent graph" <<
endl;
602 f.
set(
"filename",filename);
605 r = load_esps_label(
ts,*
this);
606 else if (type ==
"ogi")
607 r = load_ogi_label(
ts,*
this);
608 else if (type ==
"htk")
609 r = load_sample_label(
ts,*
this,10000000);
610 else if ((type ==
"ascii") || (type ==
"timit"))
611 r = load_sample_label(
ts,*
this,1);
612 else if (type ==
"words")
613 r = load_words_label(
ts,*
this);
615 r = load_esps_label(
ts,*
this);
627 if (((filename ==
"-") ?
ts.open(
cin) :
ts.open(filename)) != 0)
629 cerr <<
"load_relation: can't open relation input file "
631 return misc_read_error;
633 r =
load(filename,
ts, type);
645 for (n = first_leaf(h); n != 0; n=next_leaf(n))
void set(const EST_String &name, int ival)
EST_read_status load(EST_TokenStream &ts)
load features from already opened EST_TokenStream
EST_write_status save(ostream &outf) const
save features in already opened ostream
const EST_String S(const EST_String &path) const
EST_Relation * relation(void) const
The relation of this particular item.
void remove_item_feature(const EST_String &name)
void remove_item(EST_Item *item)
EST_read_status load(const EST_String &filename, const EST_String &type="esps")
EST_write_status save(const EST_String &filename, bool evaluate_ff=false) const
EST_Utterance * utt(void)
const EST_String & name() const
void evaluate_item_features()