Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_features_aux.cc
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 
45 #include "EST_get_function_template.h"
46 
47 defineGetFunction(EST_Features, val, EST_Val, getVal)
48 defineGetFunction(EST_Features, val, EST_String, getString)
49 defineGetFunction(EST_Features, val, float, getFloat)
50 defineGetFunction(EST_Features, val, int, getInteger)
51 VAL_REGISTER_FUNCPTR(pointer, void *)
52 
53 
54 void value_sort(EST_Features &f, const EST_String &field)
55 {
56  int work_to_do = 1;
57  (void)field;
58 
62 
63  float p_score, n_score;
64 
65  while(work_to_do)
66  {
67  work_to_do = 0;
68  for (p.begin(f); p; ++p)
69  {
70  n = p;
71  n++;
72  if (n == 0)
73  break;
74 
75  if (p->v.type() != val_type_feats)
76  {
77  cerr << "Not a features in val\n";
78  break;
79  }
80  p_score = feats(p->v)->F(field, 1.0);
81  n_score = feats(n->v)->F(field, 1.0);
82  if (n_score > p_score)
83  {
84  cout << "swapping\n";
85  e = *p;
86  *p = *n;
87  *n = e;
88  work_to_do = 1;
89  }
90  }
91  }
92 }
93 
94 
95 
96 
97