UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
apt_nlsml_doc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Id: apt_nlsml_doc.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef APT_NLSML_DOC_H
20 #define APT_NLSML_DOC_H
21 
22 /**
23  * @file apt_nlsml_doc.h
24  * @brief NLSML Result Handling
25  * @remark This is an MRCP version independent and vendor consistent implementation
26  * of the NSLML parser. The interface reflects the NLSML schema defined in
27  * http://tools.ietf.org/html/rfc6787#section-16.1.
28  */
29 
30 #include <apr_xml.h>
31 #include "apt.h"
32 
34 
35 /* Forward declarations */
36 typedef struct nlsml_result_t nlsml_result_t;
37 typedef struct nlsml_interpretation_t nlsml_interpretation_t;
38 typedef struct nlsml_enrollment_result_t nlsml_enrollment_result_t;
39 typedef struct nlsml_verification_result_t nlsml_verification_result_t;
40 typedef struct nlsml_instance_t nlsml_instance_t;
41 typedef struct nlsml_input_t nlsml_input_t;
42 
43 /**
44  * Parse NLSML result
45  * @param data the data to parse
46  * @param length the length of the data
47  * @param pool the memory pool to use
48  * @return the parsed NLSML result.
49  */
50 APT_DECLARE(nlsml_result_t*) nlsml_result_parse(const char *data, apr_size_t length, apr_pool_t *pool);
51 
52 /**
53  * Trace parsed NLSML result (for debug purposes only)
54  * @param result the parsed result to output
55  * @param pool the memory pool to use
56  */
57 APT_DECLARE(void) nlsml_result_trace(const nlsml_result_t *result, apr_pool_t *pool);
58 
59 /*
60  * Accessors of the NLSML <result> element.
61  * Each <result> element may contain one or more <interpretation>, <enrollment-result>,
62  * <verification-result> elements, and an optional <grammar> attribute.
63  */
64 
65 /**
66  * Get first interpretation
67  * @param result the parsed NLSML result which holds the list of interpretation elements
68  */
69 APT_DECLARE(nlsml_interpretation_t*) nlsml_first_interpretation_get(const nlsml_result_t *result);
70 
71 /**
72  * Get next interpretation
73  * @param result the parsed NLSML result which holds the list of interpretation elements
74  * @param interpretation the current interpretation element
75  */
76 APT_DECLARE(nlsml_interpretation_t*) nlsml_next_interpretation_get(const nlsml_result_t *result, const nlsml_interpretation_t *interpretation);
77 
78 /**
79  * Get first enrollment result
80  * @param result the parsed NLSML result which holds the list of enrollment-result elements
81  */
82 APT_DECLARE(nlsml_enrollment_result_t*) nlsml_first_enrollment_result_get(const nlsml_result_t *result);
83 
84 /**
85  * Get next enrollment result
86  * @param result the parsed NLSML result which holds the list of enrollment-result elements
87  * @param enrollment_result the current enrollment-result element
88  */
89 APT_DECLARE(nlsml_enrollment_result_t*) nlsml_next_enrollment_result_get(const nlsml_result_t *result, const nlsml_enrollment_result_t *enrollment_result);
90 
91 /**
92  * Get first verification result
93  * @param result the parsed NLSML result which holds the list of verification-result elements
94  */
95 APT_DECLARE(nlsml_verification_result_t*) nlsml_first_verification_result_get(const nlsml_result_t *result);
96 
97 /**
98  * Get next verification result
99  * @param result the parsed NLSML result which holds the list of verification-result elements
100  * @param verification_result the current verification-result element
101  */
102 APT_DECLARE(nlsml_verification_result_t*) nlsml_next_verification_result_get(const nlsml_result_t *result, const nlsml_verification_result_t *verification_result);
103 
104 /**
105  * Get the grammar attribute of the NLSML result
106  * @param result the parsed result
107  */
108 APT_DECLARE(const char*) nlsml_result_grammar_get(const nlsml_result_t *result);
109 
110 /*
111  * Accessors of the <interpretation> element.
112  */
113 
114 /**
115  * Get first instance
116  * @param interpretation the parsed interpretation element which holds the list of instance elements
117  */
118 APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_first_instance_get(const nlsml_interpretation_t *interpretation);
119 
120 /**
121  * Get next instance
122  * @param interpretation the parsed interpretation element which holds the list of instance elements
123  * @param instance the current instance element
124  */
125 APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_next_instance_get(const nlsml_interpretation_t *interpretation, const nlsml_instance_t *instance);
126 
127 /**
128  * Get input
129  * @param interpretation the parsed interpretation element which may have 0 or 1 input elements
130  */
131 APT_DECLARE(nlsml_input_t*) nlsml_interpretation_input_get(const nlsml_interpretation_t *interpretation);
132 
133 /**
134  * Get interpretation confidence
135  * @param interpretation the parsed interpretation element
136  * @remark the confidence is stored and returned as a float value for both MRCPv2 and MRCPv1
137  */
138 APT_DECLARE(float) nlsml_interpretation_confidence_get(const nlsml_interpretation_t *interpretation);
139 
140 /**
141  * Get interpretation grammar
142  * @param interpretation the parsed interpretation element
143  */
144 APT_DECLARE(const char*) nlsml_interpretation_grammar_get(const nlsml_interpretation_t *interpretation);
145 
146 /*
147  * Accessors of the <instance> and <input> elements.
148  */
149 
150 /**
151  * Get an XML representation of the instance element
152  * @param instance the parsed instance element
153  */
154 APT_DECLARE(const apr_xml_elem*) nlsml_instance_elem_get(const nlsml_instance_t *instance);
155 
156 /**
157  * Suppress SWI elements (normalize instance)
158  * @param instance the parsed instance to suppress SWI sub-elements from
159  */
160 APT_DECLARE(apt_bool_t) nlsml_instance_swi_suppress(nlsml_instance_t *instance);
161 
162 /**
163  * Generate a plain text content of the instance element
164  * @param instance the parsed instance to generate content of
165  * @param pool the memory pool to use
166  */
167 APT_DECLARE(const char*) nlsml_instance_content_generate(const nlsml_instance_t *instance, apr_pool_t *pool);
168 
169 /**
170  * Get an XML representation of the input element
171  * @param input the parsed input element
172  */
173 APT_DECLARE(const apr_xml_elem*) nlsml_input_elem_get(const nlsml_input_t *input);
174 
175 /**
176  * Generate a plain text content of the input element
177  * @param input the parsed input to generate content of
178  * @param pool the memory pool to use
179  */
180 APT_DECLARE(const char*) nlsml_input_content_generate(const nlsml_input_t *input, apr_pool_t *pool);
181 
182 /**
183  * Get input mode
184  * @param input the parsed input element
185  * @remark the input mode is either "speech" or "dtmf"
186  */
187 APT_DECLARE(const char*) nlsml_input_mode_get(const nlsml_input_t *input);
188 
189 /**
190  * Get input confidence
191  * @param input the parsed input element
192  * @remark the confidence is stored and returned as a float value for both MRCPv2 and MRCPv1
193  */
194 APT_DECLARE(float) nlsml_input_confidence_get(const nlsml_input_t *input);
195 
196 /**
197  * Get start of input timestamp
198  * @param input the parsed input element
199  */
200 APT_DECLARE(const char*) nlsml_input_timestamp_start_get(const nlsml_input_t *input);
201 
202 /**
203  * Get end of input timestamp
204  * @param input the parsed input element
205  */
206 APT_DECLARE(const char*) nlsml_input_timestamp_end_get(const nlsml_input_t *input);
207 
209 
210 #endif /* APT_NLSML_DOC_H */