44#include "EST_string_aux.h"
45#include "ling_class/EST_Utterance.h"
46#include "EST_UtteranceFile.h"
47#include "EST_string_aux.h"
60#if defined(INSTANTIATE_TEMPLATES)
62#include "../base_class/EST_TList.cc"
63#include "../base_class/EST_TKVL.cc"
81 int i =
f.
val(
"max_id").Int();
118 if ((p == 0) || (p->
S(
"id",
"0") == n))
121 for (s = daughter1(p); s; s = inext(s))
138 if ((t = item_id(s, n)) != 0)
140 EST_error(
"Could not find item matching id %s\n", (
const char *)n);
167 return ::relation(
relations.
f(name,est_val(r)));
176 BracketStringtoStrList(name, s);
182 for (
EST_Litem *p = names.head(); p ; p = p->next())
230void EST_Utterance::sub_utterance(
EST_Item *i)
232 extra_sub_utterance(*
this,i);
243 merge_features(
uroot->features(), root->features());
245 if (inext(root)!= NULL)
252 if (idown(root)!= NULL)
276 items.set_val(
id,est_val(i));
291 if (rel->
head() != NULL)
317 EST_error(
"utterance_merge: items not is same relation");
320 EST_error(
"utterance_merge: items are null");
360 copy_relation(to->insert_after(map_ling_item(inext(from),
slist)),
364 copy_relation(to->insert_below(map_ling_item(idown(from),
slist)),
377 msi = s.val_def(
si->contents(),def);
382 s.add_item(
si->contents(),
msi);
393 for (
EST_Litem *r=s.list.head(); r != 0; r=r->next())
403 if ((p=parent(i,
relname)) == 0)
405 else if (s.present(p->contents()))
406 return map_ling_item(p,s)->as_relation(
relname);
414 if (s.present(i->contents()))
424 if (!sub.relation_present(
relname))
425 sub.create_relation(
relname)->append(
ni);
426 else if ((
np=mapped_parent(i,
relname,s)) != 0)
427 np->append_daughter(
ni);
432 for (d = daughter1(i,
relname); d ; d=inext(d))
433 sub_utt_copy(sub,d,s);
453 EST_read_status v=format_ok;
455 if (((filename ==
"-") ?
ts.open(
cin) :
ts.open(filename)) != 0)
457 cerr <<
"load_utt: can't open utterance input file "
459 return misc_read_error;
465 f.
set(
"filename", filename);
474 EST_read_status
stat=read_error;
480 for(
int n=0; n< EST_UtteranceFile::map.n() ; n++)
482 EST_UtteranceFileType t = EST_UtteranceFile::map.token(n);
487 EST_UtteranceFile::Info *info = &(EST_UtteranceFile::map.info(t));
489 if (! info->recognise)
492 EST_UtteranceFile::Load_TokenStream *
l_fun = info->load;
539 EST_UtteranceFileType t = EST_UtteranceFile::map.token(
save_type);
547 EST_UtteranceFile::Save_TokenStream *
s_fun = EST_UtteranceFile::map.info(t).save;
void set(const EST_String &name, int ival)
const EST_Val & val(const char *name) const
void remove(const EST_String &name)
void set_val(const EST_String &name, const EST_Val &sval)
const EST_Val & f(const EST_String &path) const
int present(const EST_String &name) const
EST_TKVL< EST_String, EST_Val > & relations()
Access to the relation links.
const EST_String S(const EST_String &name) const
const EST_String & name() const
void set_utt(EST_Utterance *u)
void evaluate_item_features()
static EST_String cat(const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty)
int contains(const char *s, int pos=-1) const
Does it contain this substring?
void begin(const Container &over)
Set the iterator ready to run over this container.
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_Features f
Utterance level features.
EST_read_status load(const EST_String &filename)
EST_Relation * relation(const char *name, int err_on_not_found=1) const
get relation by name
bool relation_present(const EST_String name) const
EST_Item * id(const EST_String &n) const
return EST_Item whose id is <parameter>n</parameter>.
EST_write_status save(const EST_String &filename, const EST_String &type="est_ascii") const
EST_Utterance()
default constructor
EST_Features relations
The list of named relations.
void clear()
remove everything in utterance
EST_Relation * create_relation(const EST_String &relname)
create a new relation called <parameter>n</parameter>.
int next_id()
return the id of the next item
void init()
initialise utterance
void clear_relations()
clear the contents of the relations only
void evaluate_all_features()
Evaluate all feature functions in utterance.
void remove_relation(const EST_String &relname)
remove the relation called <parameter>n</parameter>.