Edinburgh Speech Tools  2.1-release
EST_features_aux.cc
Go to the documentation of this file.
1  /************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1996,1997 */
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: Richard Caley (rjc@cstr.ed.ac.uk) */
35  /* -------------------------------------------------------------------- */
36  /* Auxiliary functions related to features. */
37  /* */
38  /*************************************************************************/
39 
40 #include "EST_features_aux.h"
41 #include "EST_Features.h"
42 #include "EST_String.h"
43 #include "EST_error.h"
44 
46 
47 using namespace std;
48 
51 defineGetFunction(EST_Features, val, float, getFloat)
52 defineGetFunction(EST_Features, val, ssize_t, getInteger)
53 VAL_REGISTER_FUNCPTR(pointer, void *)
54 
55 
56 void value_sort(EST_Features &f, const EST_String &field)
57 {
58  int work_to_do = 1;
59  (void)field;
60 
64 
65  float p_score, n_score;
66 
67  while(work_to_do)
68  {
69  work_to_do = 0;
70  for (p.begin(f); p; ++p)
71  {
72  n = p;
73  n++;
74  if (n == 0)
75  break;
76 
77  if (p->v.type() != val_type_feats)
78  {
79  cerr << "Not a features in val\n";
80  break;
81  }
82  p_score = feats(p->v)->F(field, 1.0);
83  n_score = feats(n->v)->F(field, 1.0);
84  if (n_score > p_score)
85  {
86  cout << "swapping\n";
87  e = *p;
88  *p = *n;
89  *n = e;
90  work_to_do = 1;
91  }
92  }
93  }
94 }
95 
96 
97 
98 
99 
float getFloat(const EST_Features &f, const EST_String name, float def, EST_feat_status &status)
Return the values as a float.
#define VAL_REGISTER_FUNCPTR(NAME, CLASS)
Definition: EST_Val_defs.h:156
int ssize_t
EST_String getString(const EST_Features &f, const EST_String name, const EST_String &def, EST_feat_status &status)
Return the value as a string.
void begin(Container &over)
Set the iterator ready to run over this container.
int getInteger(const EST_Features &f, const EST_String name, int def, EST_feat_status &status)
Return the values as a float.
Templated Key-Value Item. Serves as the items in the list of the EST_TKVL class.
Definition: EST_TKVL.h:55
getString getInteger void value_sort(EST_Features &f, const EST_String &field)
defineGetFunction(EST_Features, val, EST_Val, getVal) defineGetFunction(EST_Features
f
Definition: EST_item_aux.cc:48
EST_Val getVal(const EST_Features &f, const EST_String name, const EST_Val &def, EST_feat_status &status)
Return the value as an EST_Val.