62 #if defined(INSTANTIATE_TEMPLATES) 64 #include "../base_class/EST_TList.cc" 65 #include "../base_class/EST_TKVL.cc" 83 int i =
f.val(
"max_id").Int();
96 for (p.
begin(relations); p; p++)
97 ::relation(p->v)->clear();
109 relations.set_val(n,
est_val(r));
120 if ((p == 0) || (p->
S(
"id",
"0") == n))
138 for (p.
begin(relations); p; p++)
139 for (s = ::relation(p->v)->head(); s; s =
next_item(s))
140 if ((t = item_id(s, n)) != 0)
142 EST_error(
"Could not find item matching id %s\n", (
const char *)n);
150 for (p.
begin(relations); p; p++)
151 ::relation(p->v)->evaluate_item_features();
165 return ::relation(relations.f(name));
169 return ::relation(relations.f(name,
est_val(r)));
176 return relations.present(name);
179 return relation_present(s);
185 if (!relations.present(names(p)))
198 u.
save(st,
"est_ascii");
216 nrel = create_relation(rr->
name());
220 rnode = nrel->
append(map_ling_item(rr->
head(),sisilist));
224 clear_up_sisilist(sisilist);
234 extra_sub_utterance(*
this,i);
251 merge_tree(urel, rel, new_root, root->
next(), items, feature);
258 merge_tree(urel, rel, new_root, root->
down(), items, feature);
298 merge_tree(urel, rel, new_root, rel->
head(), items, feature);
319 EST_error(
"utterance_merge: items not is same relation");
321 if ((utt_root == 0) || (sub_root == 0))
322 EST_error(
"utterance_merge: items are null");
327 utt_root->
set(
"id", root_id);
351 clear_up_sisilist(sisilist);
405 if ((p=
parent(i,relname)) == 0)
428 else if ((np=mapped_parent(i,relname,s)) != 0)
435 sub_utt_copy(sub,d,s);
447 sub_utt_copy(sub,i,sisilist);
449 clear_up_sisilist(sisilist);
457 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
459 cerr <<
"load_utt: can't open utterance input file " 467 f.set(
"filename", filename);
482 if (num_formats <= 0)
484 EST_error(
"There is not a single UtteranceFile format declared \ 485 in EST source code. This should not happen!");
489 for(n=0; n< num_formats ; n++)
498 if (! info->recognise)
506 if (ts.
seek(pos) != 0) {
507 cerr <<
"load utterance: read error." << endl;
511 stat = (*l_fun)(ts, *
this, max_id);
533 outf =
new ofstream(filename);
538 v =
save(*outf,type);
549 EST_String save_type = (type ==
"") ? DEF_FILE_TYPE : type;
555 cerr <<
"Utterance: unknown filetype in saving " << save_type << endl;
563 cerr <<
"Can't save utterances to files type " << save_type << endl;
567 return (*s_fun)(outf, *
this);
574 for( ; phrase; phrase=phrase->
next() ){
578 for( ; word; word=word->
next() ){
582 for( ; syllable; syllable=syllable->
next() ){
586 for( ; phone; phone=phone->next() )
EST_Item * insert_below(EST_Item *li=0)
void clear_relations()
clear the contents of the relations only
EST_Item * next_item(const EST_Item *node)
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
EST_write_status save(const EST_String &filename, const EST_String &type="est_ascii") const
EST_read_status load(const EST_String &filename)
EST_Utterance & operator=(const EST_Utterance &s)
void clear()
remove everything in utterance
The file was read in successfully.
EST_Item * append_daughter(EST_Item *li=0)
const EST_String DEF_FILE_TYPE
EST_Relation * create_relation(const EST_String &relname)
create a new relation called n.
void set_val(const EST_String &name, const EST_Val &sval)
const EST_String name(void)
void set(const EST_String &name, ssize_t ival)
EST_Val est_val(const EST_Item_featfunc f)
bool save(Lattice &lattice, EST_String filename)
void BracketStringtoStrList(EST_String s, EST_StrList &l, EST_String sep)
Convert a EST_String enclosed in a single set of brackets to a EST_StrList by separating tokens in s ...
void close(void)
Close stream.
EST_Item * next_item() const
EST_FilePos tell(void) const
tell, synonym for filepos
bool load(Lattice &lattice, EST_String filename)
ostream & operator<<(ostream &st, const EST_Utterance &u)
EST_Features f
Utterance level features.
void evaluate_all_features()
Evaluate all feature functions in utterance.
EST_read_status Load_TokenStream(LoadUtterance_TokenStreamArgs)
EST_Item * root(const EST_Item *n)
return root node of treeprevious sibling (sister) of n
EST_Features relations
The list of named relations.
void copy_relation(const EST_Relation &from, EST_Relation &to)
EST_Item * as_relation(const char *relname) const
View item from another relation (const char *) method.
ENUM token(VAL value) const
int open(const EST_String &filename)
open a EST_TokenStream for a file.
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)
static EST_TNamedEnumI< EST_UtteranceFileType, Info > map
void set_utt(EST_Utterance *u)
An error occurred while reading.
void err(const char *message, LISP x) EST_NORETURN
const EST_Val & f(const EST_String &path) const
EST_Utterance()
default constructor
const V & val_def(const K &rkey, const V &def) const
value or default
EST_Item * id(const EST_String &n) const
return EST_Item whose id is n.
const EST_String & name() const
EST_FMatrix sub(const EST_FMatrix &a, ssize_t row, ssize_t col)
const EST_String & relation_name() const
The relation name of this particular item.
EST_TKVL< EST_String, EST_Val > & relations()
Access to the relation links.
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_Content * contents() const
Declare_KVL_T(EST_Item_Content *, EST_Item *, KVL_ICP_IP) EST_Utterance
int remove_item(const K &rkey, int quiet=0)
remove key and val pair from list
EST_TVector< T > & copy(EST_TVector< T > a, const EST_TList< T > &in)
Templated Key-Value list. Objects of type EST_TKVL contain lists which are accessed by a key of type ...
EST_Item * insert_after(EST_Item *li=0)
EST_Features & features() const
The file was not written successfully.
int utterance_merge(EST_Utterance &utt, EST_Utterance &extra, EST_String feature)
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
void sub_utterance(EST_Utterance &sub, EST_Item *i)
INFO & info(ENUM token) const
void init()
initialise utterance
void sub_utterance(EST_Item *i)
void begin(const Container &over)
Set the iterator ready to run over this container.
#define Instantiate_KVL_T(KEY, VAL, TAG)
int present(const K &rkey) const
Returns true if key is present.
int next_id()
return the id of the next item
const EST_String S(const EST_String &name) const
EST_Relation * relation(const char *name, int err_on_not_found=1) const
get relation by name
EST_Item * append(EST_Item *si)
bool relation_present(const EST_String name) const
void utt_2_flat_repr(const EST_Utterance &utt, EST_String &flat_repr)
void f_remove(const EST_String &name)
EST_Item * parent(const EST_Item *n)
return parent of n
int seek(int position)
seek, reposition file pointer
EST_Item * daughter1(const EST_Item *n)
return first daughter of n
void remove_relation(const EST_String &relname)
remove the relation called n.
void merge_features(EST_Features &to, EST_Features &from)
EST_write_status Save_TokenStream(SaveUtterance_TokenStreamArgs)
Utility EST_String Functions header file.