• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  SR_GrammarImpl.h  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 #ifndef __SR_GRAMMARIMPL_H
21 #define __SR_GRAMMARIMPL_H
22 
23 
24 
25 #include "ArrayList.h"
26 #include "HashMap.h"
27 #include "SR_Grammar.h"
28 #include "SR_Nametags.h"
29 #include "ESR_ReturnCode.h"
30 #include "ESR_SessionType.h"
31 #include "SR_EventLog.h"
32 #include "SR_Recognizer.h"
33 
34 /* Semproc stuff */
35 #include "SR_SemanticGraph.h"
36 #include "SR_SemanticProcessor.h"
37 
38 
39 
40 #include "simapi.h"
41 
42 /**
43  * SR_Grammar implementation.
44  */
45 typedef struct SR_GrammarImpl_t
46 {
47   /**
48    * Interface functions that must be implemented.
49    */
50   SR_Grammar Interface;
51 
52   /**
53    * Associates a grammar with a Recognizer.
54    *
55    * @param self SR_Grammar handle
56    * @param recognizer The recognizer
57    */
58   // ESR_ReturnCode(*setupAcousticModels)(SR_Grammar* self, SR_AcousticModels* models);
59   ESR_ReturnCode(*setupRecognizer)(SR_Grammar* self, SR_Recognizer* recognizer);
60   /**
61    * Dissociates a grammar from a Recognizer.
62    *
63    * @param self SR_Grammar handle
64    */
65   ESR_ReturnCode(*unsetupRecognizer)(SR_Grammar* self);
66 
67   /**
68    * Legacy CREC syntax.
69    */
70   CA_Syntax* syntax;
71   /**
72    * Recognizer associated with SR_Grammar.
73    */
74   // SR_AcousticModels* models;
75   SR_Recognizer* recognizer;
76 
77   /**
78    * Vocabulary.
79    */
80   SR_Vocabulary* vocabulary;
81 
82   /**
83    * Semantic Graph
84    */
85   SR_SemanticGraph* semgraph;
86 
87   /**
88    * Semantic Processor
89    */
90   SR_SemanticProcessor* semproc;
91 
92   /**
93    * Grammar-specific parameters.
94    */
95   ESR_SessionType* parameters;
96 
97   /**
98    * Event Log reference set internally by regognizer during its association with this grammar
99    */
100   SR_EventLog* eventLog;
101 
102   /**
103    * Event log, logging level.
104    */
105   size_t logLevel;
106 
107   /**
108    * Indicates if the grammar has been activated.
109    */
110   ESR_BOOL isActivated;
111 }
112 SR_GrammarImpl;
113 
114 
115 /**
116  * Default implementation.
117  */
118 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_CompileRule(SR_Grammar* self, const LCHAR* name);
119 /**
120  * Default implementation.
121  */
122 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_AddRuleFromList(SR_Grammar* self, SR_Vocabulary* vocabulary, const LCHAR* name);
123 /**
124  * Default implementation.
125  */
126 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_Compile(SR_Grammar* self);
127 /**
128  * Default implementation.
129  */
130 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_AddRule(SR_Grammar* self, const LCHAR* name, const LCHAR* value);
131 /**
132  * Default implementation.
133  */
134 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_DeleteRule(SR_Grammar* self, const LCHAR* name);
135 /**
136  * Default implementation.
137  */
138 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_ContainsRule(SR_Grammar* self, const LCHAR* name, ESR_BOOL* result);
139 /**
140  * Default implementation.
141  */
142 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_AddWordToSlot(SR_Grammar* self, const LCHAR* slot,
143 																												 const LCHAR* word, const LCHAR* pronunciation,
144 																												 int weight, const LCHAR* tag);
145 /**
146  * Default implementation.
147  */
148 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_ResetAllSlots(SR_Grammar* self);
149 /**
150  * Default implementation.
151  */
152 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_AddNametagToSlot(SR_Grammar* self, const LCHAR* slot,
153 																														const SR_Nametag* nametag, int weight,
154 																														const LCHAR* tag);
155 /**
156  * Default implementation.
157  */
158 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_Create(SR_Grammar** self);
159 /**
160  * Default implementation.
161  */
162 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_Destroy(SR_Grammar* self);
163 /**
164  * Default implementation.
165  */
166 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_Save(SR_Grammar* self, const LCHAR* filename);
167 /**
168  * Default implementation.
169  */
170 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_CheckParse(SR_Grammar* self, const LCHAR* transcription, SR_SemanticResult** result, size_t* resultCount);
171 /**
172  * Default implementation.
173  */
174 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_SetDispatchFunction(SR_Grammar* self, const LCHAR* name, void* userData, SR_GrammarDispatchFunction function);
175 /**
176  * Default implementation.
177  */
178 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_SetParameter(SR_Grammar* self, const LCHAR* key, void* value);
179 /**
180  * Default implementation.
181  */
182 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_SetSize_tParameter(SR_Grammar* self, const LCHAR* key, size_t value);
183 /**
184  * Default implementation.
185  */
186 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_GetParameter(SR_Grammar* self, const LCHAR* key, void** value);
187 /**
188  * Default implementation.
189  */
190 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_GetSize_tParameter(SR_Grammar* self, const LCHAR* key, size_t* value);
191 /**
192  * Default implementation.
193  */
194 // SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_SetupModels(SR_Grammar* self, SR_AcousticModels* models);
195 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_SetupRecognizer(SR_Grammar* self, SR_Recognizer* recognizer);
196 /**
197  * Default implementation.
198  */
199 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_UnsetupRecognizer(SR_Grammar* self);
200 /**
201  * Default implementation.
202  */
203 SREC_GRAMMAR_API ESR_ReturnCode SR_Grammar_SetupVocabulary(SR_Grammar *self, SR_Vocabulary *vocabulary);
204 
205 
206 #endif /* __SR_GRAMMARIMPL_H */
207