Edinburgh Speech Tools  2.1-release
EST_FeatureData.h
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* */
34 /* Author : Paul Taylor */
35 /* ------------------------------------------------------------------- */
36 /* EST_Date Class header file */
37 /* */
38 /*************************************************************************/
39 
40 #ifndef __EST_FeatureData_H__
41 #define __EST_FeatureData_H__
42 
43 #include <cstddef>
44 #include "EST_Val.h"
45 #include "EST_TVector.h"
46 #include "EST_TList.h"
47 #include "EST_rw_status.h"
48 #include "EST_types.h"
49 #include "EST_Features.h"
50 
51 
54 
55 /** A class for containing arbitrary multi-dimensional feature data.
56 
57 A number of fields are defined in the EST_FeatureData class, each of
58 which represents a measurable quantity, such as height, age or
59 gender. Any number of fields can be defined and each field can take a
60 float, integer or string value. The class holds multiple instances of
61 field values, representing samples taken from a population.
62 
63 Several statistical training, testing and analysis programs use
64 EST_FeatureData as input and output. Member functions exist for
65 comparing fields, extracting given named or numbered fields, can
66 converting appropriate fields to a EST_FMatrix.
67 
68 */
69 
70 
72 private:
73  /*bool p_sub_fd;*/
74 
75  void default_vals();
76  void free_internals();
77  void alloc_internals();
78 
79  EST_Features *p_info;
81 public:
84 
85  /**@name Information functions */
86  //@{
87 
88  /** set number of samples to be held in object and allocate
89  space for storing them */
90 /*
91  int num_fields() const {return info().num_fields();}
92 
93  //@}
94 
95  EST_Val &a(int field)
96  {return EST_ValVector::a(field);}
97 
98  const EST_Val &a(int field) const
99  {return EST_ValVector::a(field);}
100 
101  EST_Val &a(const EST_String &name)
102  {return EST_ValVector::a(info().field_index(name));}
103 
104  const EST_Val &a(const EST_String &name) const
105  {return EST_ValVector::a(info().field_index(name));}
106 
107  /// const element access operator
108 // const EST_Val &operator () (int sample, const EST_String &field);
109  /// non-const element access operator
110  EST_Val &operator () (const EST_String &field);
111  EST_Val &operator () (int field);
112 
113  EST_FeatureSample &EST_FeatureSample::operator=
114  (const EST_FeatureSample &f);
115 
116  friend ostream& operator << (ostream &st, const EST_FeatureSample &a);
117  //@}
118 */
119 
120 
121 };
122 
123 
125 private:
126  /*bool p_sub_fd;*/
127 
128  void default_vals();
129  void free_internals();
130  void alloc_internals();
131 
132 
134 
135  EST_Features info;
136  EST_ValMatrix fd;
137 public:
138  EST_FeatureData();
140  ~EST_FeatureData();
141  EST_Features &ginfo() {return info;}
142 
143  ssize_t num_samples() const;
144  ssize_t num_features() const;
145 
146  void resize(ssize_t num_samples, ssize_t num_columns, bool preserve = 1);
147  void resize(ssize_t num_samples, EST_Features &f, bool preserve = 1);
148 
149  void set_num_samples(ssize_t num_samples, bool preserve=1);
150 
151 /* void extract_features(EST_FeatureData &f, const EST_StrList &fields) const;
152  void extract_features(EST_FeatureData &f, EST_IList &fields) const;
153 */
154 
155  EST_String type(const EST_String &feature_name);
156  EST_StrList values(const EST_String &feature_name);
157 
158  void set_type(EST_String &feature_name, EST_String &type);
159  void set_values(EST_String &feature_name, EST_StrList &values);
160 
161  int update_values(const EST_String &feature_name, int max);
162 
163  int feature_position(const EST_String &feature_name);
164 
165 
166  EST_read_status load(const EST_String &name);
167 
168  EST_write_status save(const EST_String &name,
169  const EST_String &EST_filetype = "") const;
170 
171  EST_Val &a(ssize_t sample, ssize_t field);
172  EST_Val &a(ssize_t sample, const EST_String &name);
173  const EST_Val &a(ssize_t sample, ssize_t field) const;
174  const EST_Val &a(ssize_t sample, const EST_String &name) const;
175 
176  friend ostream& operator << (ostream &st,const EST_FeatureData &a);
177 
178 };
179 
180 
181 #endif /* __EST_FeatureData_H__ */
EST_write_status
INLINE ssize_t num_columns() const
number of items in vector.
Definition: EST_TVector.h:247
bool save(Lattice &lattice, EST_String filename)
EST_String values
friend std::ostream & operator<<(std::ostream &st, const EST_TVector< T > &m)
print out vector.
Definition: EST_TVector.h:310
bool load(Lattice &lattice, EST_String filename)
int ssize_t
const T & a(ssize_t n) const
Definition: EST_TVector.h:269
EST_Features & ginfo()
float max(float a, float b)
Definition: EST_cluster.cc:143
void resize(ssize_t n, int set=1)
Definition: EST_TVector.cc:196
EST_TVector< T > & copy(EST_TVector< T > a, const EST_TList< T > &in)
f
Definition: EST_item_aux.cc:48
EST_TVector< EST_Val > EST_ValVector
EST_read_status
Template vector.
Definition: EST_TVector.h:145
void set_values(const T *data, int step, int start_c, int num_c)
Get and set values from array.
Definition: EST_TVector.cc:126
EST_TMatrix< EST_Val > EST_ValMatrix