104 if (hinfo.
ival(
"version") != 2)
106 if (hinfo.
ival(
"version") == 3)
107 EST_warning(
"Loading est utterance format version 3, ladders will not be understood");
110 EST_error(
"utt_load: %s wrong version of utterance format expected 2 (or 3) but found %d",
116 if (ts.
get() !=
"Features")
119 " missing utterance features section" << endl;
125 if (ts.
get() !=
"Stream_Items")
128 " missing Items section" << endl;
132 r = load_all_contents(ts, sitems, max_id);
135 if (ts.
peek() ==
"Streams")
137 cerr <<
"utt.load: streams found in utterance file, " <<
138 "no longer supported" << endl;
146 " missing Relations section" << endl;
150 r = load_relations(ts, u, sitems);
152 if ((r ==
format_ok) && (ts.
get() !=
"End_of_Utterance"))
155 " End_of_Utterance expected but not found" << endl;
187 while (ts.
peek() !=
"End_of_Stream_Items")
193 Sid = ts.
get().string();
199 " Item name not a number: " << Sid << endl;
203 if (
id >= sitems.
length())
211 idval = si->
f.
I(
"id",0);
231 while (ts.
peek() !=
"End_of_Relations")
258 std::streamsize oldprecision = outf.precision(8);
259 std::ios_base::fmtflags oldsetf = outf.setf(ios::fixed, ios::floatfield);
260 std::streamsize oldwidth = outf.width(8);
262 outf <<
"EST_File utterance\n";
263 outf <<
"DataType ascii\n";
264 outf <<
"version 2\n";
265 outf <<
"EST_Header_End\n";
272 outf <<
"Stream_Items\n";
274 v = utt_save_all_contents(outf,utt,sinames);
276 outf <<
"End_of_Stream_Items\n";
279 outf <<
"Relations\n";
283 v = relation(p->v)->save(outf,sinames);
286 outf <<
"End_of_Relations\n";
288 outf <<
"End_of_Utterance\n";
290 outf.precision(oldprecision);
292 outf.width(oldwidth);
313 v = utt_save_all_contents(outf,relation(p->v)->head(),
330 utt_save_ling_content(outf,n,sinames,si_count);
333 utt_save_all_contents(outf,n->
next(),sinames,si_count);
334 utt_save_all_contents(outf,n->
down(),sinames,si_count);
349 outf << si_count <<
" ";
368 status = rel->
load(
"", ts,
"esps");
394 rel = ::relation(p->v);
401 if (hd->
up() || hd->
down())
408 return rel->
save(outf,
"esps", 0);
416 #if defined(INCLUDE_XML_FORMATS) 437 if (fgets(buf, 80, stream) ==
NULL)
439 if (ferror(stream)) {
440 cerr <<
"Error reading xml header" << endl;
444 if (strncmp(buf,
"<?xml", 5) != 0)
448 if (fgets(buf, 80, stream) ==
NULL)
450 if (ferror(stream)) {
451 cerr <<
"Error reading DOCTYPE apml header" << endl;
456 if (strncmp(buf,
"<!DOCTYPE apml", 14) != 0)
461 cerr <<
"Error reading DOCTYPE apml header" << endl;
487 cerr <<
"Error reading xml header" << endl;
494 if (fgets(buf, 80, stream) ==
NULL)
496 if (ferror(stream)) {
497 cerr <<
"Error reading xml header" << endl;
502 if (strncmp(buf,
"<?xml", 5) != 0)
507 cerr <<
"Error reading xml file" << endl;
543 outf <<
"<?xml version='1.0'?>\n";
545 outf <<
"<!DOCTYPE utterance PUBLIC '//CSTR EST//DTD cstrutt//EN' 'cstrutt.dtd'\n\t[\n";
549 outf <<
"\t<!ATTLIST item\n";
550 for (f.
begin(features);
f; ++
f)
554 outf <<
"\t\t" << f->k <<
"\tCDATA #IMPLIED\n";
562 outf <<
"<utterance>\n";
564 outf <<
"<language name='unknown'/>\n";
575 if (hd->
up() || hd->
down())
583 outf <<
"<relation name='"<< rel->
name()<<
"' structure-type='list'>\n";
592 if (p->k !=
"estContentFeature")
593 outf <<
" " << p->k <<
"='" << p->v <<
"'\n";
600 outf <<
"</relation>\n";
607 outf <<
"</utterance>\n";
641 EST_String s(
"Available utterance file formats:\n");
668 {
uff_est, {
"est",
"est_ascii"},
670 #if defined(INCLUDE_XML_FORMATS) 685 #if defined(INSTANTIATE_TEMPLATES) 686 #include "../base_class/EST_TNamedEnum.cc" 692 #if defined(INSTANTIATE_TEMPLATES) 694 #include "../base_class/EST_TSimpleVector.cc" 695 #include "../base_class/EST_TVector.cc" 696 #include "../base_class/EST_Tvectlist.cc"
EST_TokenStream & get(EST_Token &t)
get next token in stream
static EST_write_status save_genxml(SaveUtterance_TokenStreamArgs)
EST_read_status apml_read(FILE *file, const EST_String &name, EST_Utterance &u, int &max_id)
FILE * filedescriptor()
For the people who need the actual description (if possible)
EST_FilePos EST_ftell(FILE *fp)
static EST_read_status read_xml(FILE *file, const EST_String &name, EST_Utterance &u, int &max_id)
void clear()
remove everything in utterance
The file was read in successfully.
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)
void set(const EST_String &name, ssize_t ival)
int ival(const EST_String &rkey, int m=1) const
EST_Val est_val(const EST_Item_featfunc f)
static EST_String options_short(void)
void set_SingleCharSymbols(const EST_String &sc)
set which characters are to be treated as single character symbols
const EST_String filename() const
The originating filename (if there is one)
EST_read_status load(EST_TokenStream &ts)
load features from already opened EST_TokenStream
A specialised hash table for when the key is an EST_String.
#define Instantiate_TVector_T(TYPE, TAG)
EST_Features f
Utterance level features.
EST_Features relations
The list of named relations.
static EST_read_status load_est_ascii(LoadUtterance_TokenStreamArgs)
EST_Features f
General features for this item.
#define NAMED_ENUM_MAX_SYNONYMS
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)
static EST_read_status load_xlabel(LoadUtterance_TokenStreamArgs)
An error occurred while reading.
EST_TKVL< EST_String, EST_Val > relations
The file was not written successfully.
void resize(ssize_t n, int set=1)
ENUM nth_token(int n) const
const char * name(ENUM tok, int n=0) const
INLINE ssize_t length() const
number of items in vector.
const EST_String & name() const
float F(const EST_String &name) const
The file was written successfully.
#define Declare_TNamedEnumI(ENUM, INFO)
EST_Item_Content * contents() const
A valid file was created, but only some of the requested data is in there.
EST_read_status read_est_header(EST_TokenStream &ts, EST_Option &hinfo, bool &ascii, EST_EstFileType &t)
The file exists but is not in the format specified.
Templated Key-Value list. Objects of type EST_TKVL contain lists which are accessed by a key of type ...
int EST_fseek(FILE *fp, EST_FilePos offset, int whence)
#define Instantiate_TNamedEnumI(ENUM, INFO)
EST_Token & peek(void)
peek at next token
static EST_read_status load_apml(LoadUtterance_TokenStreamArgs)
EST_Features & features() const
static EST_write_status save_est_ascii(SaveUtterance_TokenStreamArgs)
EST_write_status save(ostream &outf) const
save features in already opened ostream
void set_quotes(char q, char e)
set characters to be used as quotes and escape, and set quote mode
The file was not written successfully.
#define Declare_TVector_Base_T(TYPE, DEFAULT, ERROR, TAG)
int add_item(const EST_String &key, const V &value, int no_search=0)
Add an entry to the table.
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
Start_TNamedEnumI_T(EST_UtteranceFileType, EST_UtteranceFile::Info, EST_UtteranceFile::map, utterancefile)
INFO & info(ENUM token) const
void begin(const Container &over)
Set the iterator ready to run over this container.
const EST_String pos_description()
A string describing current position, suitable for error messages.
int present(const K &rkey) const
Returns true if key is present.
#define End_TNamedEnumI_T(ENUM, INFO, NAME, TAG)
EST_write_status save(const EST_String &filename, bool evaluate_ff=false) const
int I(const EST_String &path) const
EST_read_status load(const EST_String &filename, const EST_String &type="esps")
static EST_read_status load_genxml(LoadUtterance_TokenStreamArgs)
static EST_String options_supported(void)
static EST_write_status save_xlabel(SaveUtterance_TokenStreamArgs)
int unref_relation(const EST_String &relname)
Utility EST_String Functions header file.