1 /************************************************************************/
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1996,1997 */
6 /* All Rights Reserved. */
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 */
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 */
32 /*************************************************************************/
34 /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
35 /* Date: Tue Jul 29 1997 */
36 /* -------------------------------------------------------------------- */
37 /* Some things useful in modules. */
39 /*************************************************************************/
41 #include "module_support.h"
43 #define CAR6(x) CAR(CDR5(x))
44 #define CDR6(x) CDR(CDR5(x))
45 #define CAR7(x) CAR(CDR6(x))
46 #define CDR7(x) CDR(CDR6(x))
48 #define CDR_to1(X) ((X!=NIL)&&CDR1(X))
49 #define CDR_to2(X) (CDR_to1(X)&&CDR2(X))
50 #define CDR_to3(X) (CDR_to2(X)&&CDR3(X))
51 #define CDR_to4(X) (CDR_to3(X)&&CDR4(X))
52 #define CDR_to5(X) (CDR_to4(X)&&CDR5(X))
53 #define CDR_to6(X) (CDR_to5(X)&&CDR6(X))
54 #define CDR_to7(X) (CDR_to6(X)&&CDR7(X))
57 void unpack_multiple_args(LISP args, LISP &v1, LISP &v2, LISP &v3, LISP &v4)
75 void unpack_multiple_args(LISP args, LISP &v1, LISP &v2, LISP &v3, LISP &v4, LISP &v5)
77 unpack_multiple_args(args, v1, v2, v3, v4);
83 void unpack_relation_arg(EST_Utterance *utt,
85 EST_String &relation_name,
86 EST_Relation *&relation,
90 relation_name = get_c_string(lrel_name);
92 if(utt->relation(relation_name))
93 relation = utt->relation(relation_name);
95 if (type==sat_existing)
98 err("no relation", relation_name);
100 else if (type==sat_new || type==sat_replace)
104 err("relation exists", relation_name);
105 utt->create_relation(relation_name);
107 relation = &(*(utt->relation(relation_name)));
111 void unpack_module_args(LISP args, EST_Utterance *&utt)
115 LISP lutt = CAR1(args);
117 utt = get_c_utt(lutt);
120 err("no utterance given", NIL);
124 void unpack_module_args(LISP args,
126 EST_String &relation1_name, EST_Relation *&relation1, RelArgType type1)
128 unpack_module_args(args, utt);
130 unpack_relation_arg(utt, CDR_to1(args)?CAR2(args):NIL, relation1_name, relation1, type1);
133 void unpack_module_args(LISP args,
135 EST_String &relation1_name, EST_Relation *&relation1, RelArgType type1,
136 EST_String &relation2_name, EST_Relation *&relation2, RelArgType type2
139 unpack_module_args(args, utt);
141 unpack_relation_arg(utt, CDR_to1(args)?CAR2(args):NIL, relation1_name, relation1, type1);
142 unpack_relation_arg(utt, CDR_to2(args)?CAR3(args):NIL, relation2_name, relation2, type2);
145 void unpack_module_args(LISP args,
147 EST_String &relation1_name, EST_Relation *&relation1, RelArgType type1,
148 EST_String &relation2_name, EST_Relation *&relation2, RelArgType type2,
149 EST_String &relation3_name, EST_Relation *&relation3, RelArgType type3
152 unpack_module_args(args, utt);
154 unpack_relation_arg(utt, CDR_to1(args)?CAR2(args):NIL, relation1_name, relation1, type1);
155 unpack_relation_arg(utt, CDR_to2(args)?CAR3(args):NIL, relation2_name, relation2, type2);
156 unpack_relation_arg(utt, CDR_to3(args)?CAR4(args):NIL, relation3_name, relation3, type3);
159 void unpack_module_args(LISP args,
161 EST_String &relation1_name, EST_Relation *&relation1, RelArgType type1,
162 EST_String &relation2_name, EST_Relation *&relation2, RelArgType type2,
163 EST_String &relation3_name, EST_Relation *&relation3, RelArgType type3,
164 EST_String &relation4_name, EST_Relation *&relation4, RelArgType type4
167 unpack_module_args(args, utt);
169 unpack_relation_arg(utt, CDR_to1(args)?CAR2(args):NIL, relation1_name, relation1, type1);
170 unpack_relation_arg(utt, CDR_to2(args)?CAR3(args):NIL, relation2_name, relation2, type2);
171 unpack_relation_arg(utt, CDR_to3(args)?CAR4(args):NIL, relation3_name, relation3, type3);
172 unpack_relation_arg(utt, CDR_to4(args)?CAR5(args):NIL, relation4_name, relation4, type4);
175 void unpack_module_args(LISP args,
177 EST_String &relation1_name, EST_Relation *&relation1, RelArgType type1,
178 EST_String &relation2_name, EST_Relation *&relation2, RelArgType type2,
179 EST_String &relation3_name, EST_Relation *&relation3, RelArgType type3,
180 EST_String &relation4_name, EST_Relation *&relation4, RelArgType type4,
181 EST_String &relation5_name, EST_Relation *&relation5, RelArgType type5
184 unpack_module_args(args, utt);
186 unpack_relation_arg(utt, CDR_to1(args)?CAR2(args):NIL, relation1_name, relation1, type1);
187 unpack_relation_arg(utt, CDR_to2(args)?CAR3(args):NIL, relation2_name, relation2, type2);
188 unpack_relation_arg(utt, CDR_to3(args)?CAR4(args):NIL, relation3_name, relation3, type3);
189 unpack_relation_arg(utt, CDR_to4(args)?CAR5(args):NIL, relation4_name, relation4, type4);
190 unpack_relation_arg(utt, CDR_to5(args)?CAR6(args):NIL, relation5_name, relation5, type5);