Debian Codegraph @

3rdparty/flite_hts_engine/flite/src/utils/cst_val_const.c

raw symbols SCIP
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 2001 */
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 /* CARNEGIE MELLON UNIVERSITY 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 CARNEGIE MELLON UNIVERSITY 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 /* Author: Alan W Black ([email protected]) */
34 /* Date: January 2001 */
35 /*************************************************************************/
36 /* */
37 /* Without a real garbage collector we need some basic constant val */
38 /* to avoid having to create them on the fly */
39 /* */
40 /*************************************************************************/
41 #include "cst_val.h"
42 #include "cst_features.h"
43 #include "cst_string.h"
44
45 DEF_CONST_VAL_STRING(val_string_0,"0");
46 DEF_CONST_VAL_STRING(val_string_1,"1");
47 DEF_CONST_VAL_STRING(val_string_2,"2");
48 DEF_CONST_VAL_STRING(val_string_3,"3");
49 DEF_CONST_VAL_STRING(val_string_4,"4");
50 DEF_CONST_VAL_STRING(val_string_5,"5");
51 DEF_CONST_VAL_STRING(val_string_6,"6");
52 DEF_CONST_VAL_STRING(val_string_7,"7");
53 DEF_CONST_VAL_STRING(val_string_8,"8");
54 DEF_CONST_VAL_STRING(val_string_9,"9");
55 DEF_CONST_VAL_STRING(val_string_10,"10");
56 DEF_CONST_VAL_STRING(val_string_11,"11");
57 DEF_CONST_VAL_STRING(val_string_12,"12");
58 DEF_CONST_VAL_STRING(val_string_13,"13");
59 DEF_CONST_VAL_STRING(val_string_14,"14");
60 DEF_CONST_VAL_STRING(val_string_15,"15");
61 DEF_CONST_VAL_STRING(val_string_16,"16");
62 DEF_CONST_VAL_STRING(val_string_17,"17");
63 DEF_CONST_VAL_STRING(val_string_18,"18");
64 DEF_CONST_VAL_STRING(val_string_19,"19");
65
66 DEF_CONST_VAL_INT(val_int_0,0);
67 DEF_CONST_VAL_INT(val_int_1,1);
68 DEF_CONST_VAL_INT(val_int_2,2);
69 DEF_CONST_VAL_INT(val_int_3,3);
70 DEF_CONST_VAL_INT(val_int_4,4);
71 DEF_CONST_VAL_INT(val_int_5,5);
72 DEF_CONST_VAL_INT(val_int_6,6);
73 DEF_CONST_VAL_INT(val_int_7,7);
74 DEF_CONST_VAL_INT(val_int_8,8);
75 DEF_CONST_VAL_INT(val_int_9,9);
76 DEF_CONST_VAL_INT(val_int_10,10);
77 DEF_CONST_VAL_INT(val_int_11,11);
78 DEF_CONST_VAL_INT(val_int_12,12);
79 DEF_CONST_VAL_INT(val_int_13,13);
80 DEF_CONST_VAL_INT(val_int_14,14);
81 DEF_CONST_VAL_INT(val_int_15,15);
82 DEF_CONST_VAL_INT(val_int_16,16);
83 DEF_CONST_VAL_INT(val_int_17,17);
84 DEF_CONST_VAL_INT(val_int_18,18);
85 DEF_CONST_VAL_INT(val_int_19,19);
86
87 static const int val_int_const_max = 20;
88 static const cst_val * const val_int_const [] = {
89 VAL_INT_0,
90 VAL_INT_1,
91 VAL_INT_2,
92 VAL_INT_3,
93 VAL_INT_4,
94 VAL_INT_5,
95 VAL_INT_6,
96 VAL_INT_7,
97 VAL_INT_8,
98 VAL_INT_9,
99 VAL_INT_10,
100 VAL_INT_11,
101 VAL_INT_12,
102 VAL_INT_13,
103 VAL_INT_14,
104 VAL_INT_15,
105 VAL_INT_16,
106 VAL_INT_17,
107 VAL_INT_18,
108 VAL_INT_19 };
109
110 static const cst_val * const val_string_const [] = {
111 VAL_STRING_0,
112 VAL_STRING_1,
113 VAL_STRING_2,
114 VAL_STRING_3,
115 VAL_STRING_4,
116 VAL_STRING_5,
117 VAL_STRING_6,
118 VAL_STRING_7,
119 VAL_STRING_8,
120 VAL_STRING_9,
121 VAL_STRING_10,
122 VAL_STRING_11,
123 VAL_STRING_12,
124 VAL_STRING_13,
125 VAL_STRING_14,
126 VAL_STRING_15,
127 VAL_STRING_16,
128 VAL_STRING_17,
129 VAL_STRING_18,
130 VAL_STRING_19 };
131
132 const cst_val *val_int_n(int n)
133 {
134 if (n < val_int_const_max)
135 return val_int_const[n];
136 else
137 return val_int_const[val_int_const_max-1];
138 }
139
140 /* carts are pretty confused about strings/ints, and some features */
141 /* are actually used as floats and as int/strings */
142 const cst_val *val_string_n(int n)
143 {
144 if (n < 0)
145 return val_string_const[0];
146 else if (n < val_int_const_max) /* yes I mean *int*, its the table size */
147 return val_string_const[n];
148 else
149 return val_string_const[val_int_const_max-1];
150 }
151
152 #if 0
153 /* This technique isn't thread safe, so I replaced it with val_consts */
154 static cst_features *val_string_consts = NULL;
155
156 const cst_val *val_string_x(const char *n)
157 {
158 const cst_val *v;
159
160 /* *BUG* This will have to be fixed soon */
161 if (val_string_consts == NULL)
162 val_string_consts = new_features();
163
164 v = feat_val(val_string_consts,n);
165 if (v)
166 return v;
167 else
168 {
169 feat_set_string(val_string_consts,n,n);
170 return feat_val(val_string_consts,n);
171 }
172 }
173 #endif