79 return fd.num_columns();
83 void EST_FeatureData::default_vals()
93 fd.resize(num_samples, fd.num_columns(), preserve);
102 if (num_features > fd.num_columns())
106 i = fd.num_columns();
109 for (; i < num_features; ++i)
110 info.set(
"unnamed_" +
itoString(i),
"<STRING>");
113 fd.resize(num_samples, num_features, preserve);
118 fd.resize(num_samples, f.
length(), preserve);
138 if ((t ==
"<FLOAT>") || (t ==
"<INT>") || (t ==
"<STRING>"))
151 for (i = 0, p.
begin(info); p; ++p, ++i)
155 if (p->k == feature_name)
159 EST_error(
"No such feature %s\n", (
const char *) feature_name);
173 col = feature_position(feature_name);
175 for (i = 0; i < num_samples(); ++i)
176 values.
set(fd.a(i, col).string(), 1);
185 for(p.
begin(values); p; ++p)
189 info.set(feature_name, v);
398 if ((file_type ==
"est") || (file_type ==
""))
406 cerr <<
"Can't save feature data in format \"" << file_type << endl;
423 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
425 cerr <<
"Can't open track file " << filename << endl;
434 cerr <<
"Error reading est header of file " << filename << endl;
440 cerr <<
"Not a EST Feature Data file: " << filename << endl;
444 ns = hinfo.
ival(
"NumSamples");
445 nf = hinfo.
ival(
"NumFeatures");
447 cout <<
"ns: " << ns << endl;
448 cout <<
"nf: " << nf << endl;
453 for (i = 0; i < nf; ++i)
460 cout <<
"value: " << v.
after(
" ") << endl;
463 EST_error(
"No feature definition given for feature %d\n", i);
466 for (i = 0; i < ns; ++i)
469 for (p.
begin(info), j = 0; j < nf; ++j, ++p)
471 if (p->k ==
"<FLOAT>")
472 a(i, j) = atof(ts.
get().string());
473 else if (p->k ==
"<BOOL>")
474 a(i, j) = atoi(ts.
get().string());
475 else if (p->k ==
"<INT>")
476 a(i, j) = atoi(ts.
get().string());
478 a(i, j) = ts.
get().string();
EST_TokenStream & get(EST_Token &t)
get next token in stream
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
int ival(const EST_String &rkey, int m=1) const
void set_SingleCharSymbols(const EST_String &sc)
set which characters are to be treated as single character symbols
EST_StrList values(const EST_String &feature_name)
int feature_position(const EST_String &feature_name)
EST_String itoString(int n)
Make a EST_String object from an integer.
void set(const EST_String &name, int ival)
void resize(ssize_t num_samples, ssize_t num_columns, bool preserve=1)
EST_write_status save_est(const EST_FeatureData &f, const EST_String &filename)
int open(const EST_String &filename)
open a EST_TokenStream for a file.
EST_write_status save(const EST_String &name, const EST_String &EST_filetype="") const
float max(float a, float b)
void set_num_samples(ssize_t num_samples, bool preserve=1)
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...
The file was written successfully.
EST_read_status read_est_header(EST_TokenStream &ts, EST_Option &hinfo, bool &ascii, EST_EstFileType &t)
EST_TVector< T > & copy(EST_TVector< T > a, const EST_TList< T > &in)
void set_quotes(char q, char e)
set characters to be used as quotes and escape, and set quote mode
EST_read_status load(const EST_String &name)
The file was not written successfully.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
ssize_t num_samples() const
ssize_t num_features() const
void begin(const Container &over)
Set the iterator ready to run over this container.
int present(const K &rkey) const
Returns true if key is present.
EST_String after(int pos, int len=1) const
Part after pos+len.
EST_String before(int pos, int len=0) const
Part before position.
EST_Val & a(ssize_t sample, ssize_t field)
EST_String type(const EST_String &feature_name)
Utility EST_String Functions header file.
int update_values(const EST_String &feature_name, int max)
ostream & operator<<(ostream &st, const EST_FeatureData &d)