Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_FeatureData.h
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 "EST_Val.h"
44 #include "EST_TVector.h"
45 #include "EST_TList.h"
46 #include "EST_rw_status.h"
47 #include "EST_types.h"
48 #include "EST_Features.h"
49 
50 
53 
54 /** A class for containing arbitrary multi-dimensional feature data.
55 
56 A number of fields are defined in the EST_FeatureData class, each of
57 which represents a measurable quantity, such as height, age or
58 gender. Any number of fields can be defined and each field can take a
59 float, integer or string value. The class holds multiple instances of
60 field values, representing samples taken from a population.
61 
62 Several statistical training, testing and analysis programs use
63 EST_FeatureData as input and output. Member functions exist for
64 comparing fields, extracting given named or numbered fields, can
65 converting appropriate fields to a EST_FMatrix.
66 
67 */
68 
69 
71 private:
72  bool p_sub_fd;
73 
74  void default_vals();
75  void free_internals();
76  void alloc_internals();
77 
78  EST_Features *p_info;
79  EST_FeatureSample &copy(const EST_FeatureSample &a);
80 public:
83 
84  /**@name Information functions */
85  //@{
86 
87  /** set number of samples to be held in object and allocate
88  space for storing them */
89 /*
90  int num_fields() const {return info().num_fields();}
91 
92  //@}
93 
94  EST_Val &a(int field)
95  {return EST_ValVector::a(field);}
96 
97  const EST_Val &a(int field) const
98  {return EST_ValVector::a(field);}
99 
100  EST_Val &a(const EST_String &name)
101  {return EST_ValVector::a(info().field_index(name));}
102 
103  const EST_Val &a(const EST_String &name) const
104  {return EST_ValVector::a(info().field_index(name));}
105 
106  /// const element access operator
107 // const EST_Val &operator () (int sample, const EST_String &field);
108  /// non-const element access operator
109  EST_Val &operator () (const EST_String &field);
110  EST_Val &operator () (int field);
111 
112  EST_FeatureSample &EST_FeatureSample::operator=
113  (const EST_FeatureSample &f);
114 
115  friend ostream& operator << (ostream &st, const EST_FeatureSample &a);
116  //@}
117 */
118 
119 
120 };
121 
122 
124 private:
125  bool p_sub_fd;
126 
127  void default_vals();
128  void free_internals();
129  void alloc_internals();
130 
131 
132  EST_FeatureData &copy(const EST_FeatureData &a);
133 
134  EST_Features info;
135  EST_ValMatrix fd;
136 public:
137  EST_FeatureData();
139  ~EST_FeatureData();
140  EST_Features &ginfo() {return info;}
141 
142  int num_samples() const;
143  int num_features() const;
144 
145  void resize(int num_samples, int num_columns, bool preserve = 1);
146  void resize(int num_samples, EST_Features &f, bool preserve = 1);
147 
148  void set_num_samples(int num_samples, bool preserve=1);
149 
150 /* void extract_features(EST_FeatureData &f, const EST_StrList &fields) const;
151  void extract_features(EST_FeatureData &f, EST_IList &fields) const;
152 */
153 
154  EST_String type(const EST_String &feature_name);
155  EST_StrList values(const EST_String &feature_name);
156 
157  void set_type(EST_String &feature_name, EST_String &type);
158  void set_values(EST_String &feature_name, EST_StrList &values);
159 
160  int update_values(const EST_String &feature_name, int max);
161 
162  int feature_position(const EST_String &feature_name);
163 
164 
165  EST_read_status load(const EST_String &name);
166 
167  EST_write_status save(const EST_String &name,
168  const EST_String &EST_filetype = "") const;
169 
170  EST_Val &a(int sample, int field);
171  EST_Val &a(int sample, const EST_String &name);
172  const EST_Val &a(int sample, int field) const;
173  const EST_Val &a(int sample, const EST_String &name) const;
174 
175  friend ostream& operator << (ostream &st,const EST_FeatureData &a);
176 
177 };
178 
179 
180 #endif /* __EST_FeatureData_H__ */