UniMRCP  1.7.0
apt_nlsml_doc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 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 
17 #ifndef APT_NLSML_DOC_H
18 #define APT_NLSML_DOC_H
19 
20 /**
21  * @file apt_nlsml_doc.h
22  * @brief NLSML Result Handling
23  * @remark This is an MRCP version independent and vendor consistent implementation
24  * of the NSLML parser. The interface reflects the NLSML schema defined in
25  * http://tools.ietf.org/html/rfc6787#section-16.1.
26  */
27 
28 #include <apr_xml.h>
29 #include "apt.h"
30 
32 
33 /* Forward declarations */
34 typedef struct nlsml_result_t nlsml_result_t;
35 typedef struct nlsml_interpretation_t nlsml_interpretation_t;
36 typedef struct nlsml_enrollment_result_t nlsml_enrollment_result_t;
37 typedef struct nlsml_verification_result_t nlsml_verification_result_t;
38 typedef struct nlsml_instance_t nlsml_instance_t;
39 typedef struct nlsml_input_t nlsml_input_t;
40 
41 /**
42  * Parse NLSML result
43  * @param data the data to parse
44  * @param length the length of the data
45  * @param pool the memory pool to use
46  * @return the parsed NLSML result.
47  */
48 APT_DECLARE(nlsml_result_t*) nlsml_result_parse(const char *data, apr_size_t length, apr_pool_t *pool);
49 
50 /**
51  * Trace parsed NLSML result (for debug purposes only)
52  * @param result the parsed result to output
53  * @param pool the memory pool to use
54  */
55 APT_DECLARE(void) nlsml_result_trace(const nlsml_result_t *result, apr_pool_t *pool);
56 
57 /*
58  * Accessors of the NLSML <result> element.
59  * Each <result> element may contain one or more <interpretation>, <enrollment-result>,
60  * <verification-result> elements, and an optional <grammar> attribute.
61  */
62 
63 /**
64  * Get first interpretation
65  * @param result the parsed NLSML result which holds the list of interpretation elements
66  */
67 APT_DECLARE(nlsml_interpretation_t*) nlsml_first_interpretation_get(const nlsml_result_t *result);
68 
69 /**
70  * Get next interpretation
71  * @param result the parsed NLSML result which holds the list of interpretation elements
72  * @param interpretation the current interpretation element
73  */
74 APT_DECLARE(nlsml_interpretation_t*) nlsml_next_interpretation_get(const nlsml_result_t *result, const nlsml_interpretation_t *interpretation);
75 
76 /**
77  * Get first enrollment result
78  * @param result the parsed NLSML result which holds the list of enrollment-result elements
79  */
80 APT_DECLARE(nlsml_enrollment_result_t*) nlsml_first_enrollment_result_get(const nlsml_result_t *result);
81 
82 /**
83  * Get next enrollment result
84  * @param result the parsed NLSML result which holds the list of enrollment-result elements
85  * @param enrollment_result the current enrollment-result element
86  */
87 APT_DECLARE(nlsml_enrollment_result_t*) nlsml_next_enrollment_result_get(const nlsml_result_t *result, const nlsml_enrollment_result_t *enrollment_result);
88 
89 /**
90  * Get first verification result
91  * @param result the parsed NLSML result which holds the list of verification-result elements
92  */
93 APT_DECLARE(nlsml_verification_result_t*) nlsml_first_verification_result_get(const nlsml_result_t *result);
94 
95 /**
96  * Get next verification result
97  * @param result the parsed NLSML result which holds the list of verification-result elements
98  * @param verification_result the current verification-result element
99  */
100 APT_DECLARE(nlsml_verification_result_t*) nlsml_next_verification_result_get(const nlsml_result_t *result, const nlsml_verification_result_t *verification_result);
101 
102 /**
103  * Get the grammar attribute of the NLSML result
104  * @param result the parsed result
105  */
106 APT_DECLARE(const char*) nlsml_result_grammar_get(const nlsml_result_t *result);
107 
108 /*
109  * Accessors of the <interpretation> element.
110  */
111 
112 /**
113  * Get first instance
114  * @param interpretation the parsed interpretation element which holds the list of instance elements
115  */
116 APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_first_instance_get(const nlsml_interpretation_t *interpretation);
117 
118 /**
119  * Get next instance
120  * @param interpretation the parsed interpretation element which holds the list of instance elements
121  * @param instance the current instance element
122  */
123 APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_next_instance_get(const nlsml_interpretation_t *interpretation, const nlsml_instance_t *instance);
124 
125 /**
126  * Get input
127  * @param interpretation the parsed interpretation element which may have 0 or 1 input elements
128  */
129 APT_DECLARE(nlsml_input_t*) nlsml_interpretation_input_get(const nlsml_interpretation_t *interpretation);
130 
131 /**
132  * Get interpretation confidence
133  * @param interpretation the parsed interpretation element
134  * @remark the confidence is stored and returned as a float value for both MRCPv2 and MRCPv1
135  */
136 APT_DECLARE(float) nlsml_interpretation_confidence_get(const nlsml_interpretation_t *interpretation);
137 
138 /**
139  * Get interpretation grammar
140  * @param interpretation the parsed interpretation element
141  */
142 APT_DECLARE(const char*) nlsml_interpretation_grammar_get(const nlsml_interpretation_t *interpretation);
143 
144 /*
145  * Accessors of the <instance> and <input> elements.
146  */
147 
148 /**
149  * Get an XML representation of the instance element
150  * @param instance the parsed instance element
151  */
152 APT_DECLARE(const apr_xml_elem*) nlsml_instance_elem_get(const nlsml_instance_t *instance);
153 
154 /**
155  * Suppress SWI elements (normalize instance)
156  * @param instance the parsed instance to suppress SWI sub-elements from
157  */
158 APT_DECLARE(apt_bool_t) nlsml_instance_swi_suppress(nlsml_instance_t *instance);
159 
160 /**
161  * Generate a plain text content of the instance element
162  * @param instance the parsed instance to generate content of
163  * @param pool the memory pool to use
164  */
165 APT_DECLARE(const char*) nlsml_instance_content_generate(const nlsml_instance_t *instance, apr_pool_t *pool);
166 
167 /**
168  * Get an XML representation of the input element
169  * @param input the parsed input element
170  */
171 APT_DECLARE(const apr_xml_elem*) nlsml_input_elem_get(const nlsml_input_t *input);
172 
173 /**
174  * Generate a plain text content of the input element
175  * @param input the parsed input to generate content of
176  * @param pool the memory pool to use
177  */
178 APT_DECLARE(const char*) nlsml_input_content_generate(const nlsml_input_t *input, apr_pool_t *pool);
179 
180 /**
181  * Get input mode
182  * @param input the parsed input element
183  * @remark the input mode is either "speech" or "dtmf"
184  */
185 APT_DECLARE(const char*) nlsml_input_mode_get(const nlsml_input_t *input);
186 
187 /**
188  * Get input confidence
189  * @param input the parsed input element
190  * @remark the confidence is stored and returned as a float value for both MRCPv2 and MRCPv1
191  */
192 APT_DECLARE(float) nlsml_input_confidence_get(const nlsml_input_t *input);
193 
194 /**
195  * Get start of input timestamp
196  * @param input the parsed input element
197  */
198 APT_DECLARE(const char*) nlsml_input_timestamp_start_get(const nlsml_input_t *input);
199 
200 /**
201  * Get end of input timestamp
202  * @param input the parsed input element
203  */
204 APT_DECLARE(const char*) nlsml_input_timestamp_end_get(const nlsml_input_t *input);
205 
207 
208 #endif /* APT_NLSML_DOC_H */
nlsml_enrollment_result_t * nlsml_next_enrollment_result_get(const nlsml_result_t *result, const nlsml_enrollment_result_t *enrollment_result)
const apr_xml_elem * nlsml_instance_elem_get(const nlsml_instance_t *instance)
nlsml_input_t * nlsml_interpretation_input_get(const nlsml_interpretation_t *interpretation)
const apr_xml_elem * nlsml_input_elem_get(const nlsml_input_t *input)
nlsml_instance_t * nlsml_interpretation_next_instance_get(const nlsml_interpretation_t *interpretation, const nlsml_instance_t *instance)
#define APT_END_EXTERN_C
Definition: apt.h:38
nlsml_result_t * nlsml_result_parse(const char *data, apr_size_t length, apr_pool_t *pool)
int apt_bool_t
Definition: apt.h:57
float nlsml_interpretation_confidence_get(const nlsml_interpretation_t *interpretation)
nlsml_instance_t * nlsml_interpretation_first_instance_get(const nlsml_interpretation_t *interpretation)
float nlsml_input_confidence_get(const nlsml_input_t *input)
apt_bool_t nlsml_instance_swi_suppress(nlsml_instance_t *instance)
const char * nlsml_result_grammar_get(const nlsml_result_t *result)
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
const char * nlsml_input_mode_get(const nlsml_input_t *input)
#define APT_DECLARE(type)
Definition: apt.h:53
APR Toolkit Definitions.
const char * nlsml_instance_content_generate(const nlsml_instance_t *instance, apr_pool_t *pool)
nlsml_enrollment_result_t * nlsml_first_enrollment_result_get(const nlsml_result_t *result)
nlsml_verification_result_t * nlsml_first_verification_result_get(const nlsml_result_t *result)
const char * nlsml_input_timestamp_end_get(const nlsml_input_t *input)
nlsml_interpretation_t * nlsml_next_interpretation_get(const nlsml_result_t *result, const nlsml_interpretation_t *interpretation)
nlsml_verification_result_t * nlsml_next_verification_result_get(const nlsml_result_t *result, const nlsml_verification_result_t *verification_result)
const char * nlsml_input_content_generate(const nlsml_input_t *input, apr_pool_t *pool)
const char * nlsml_interpretation_grammar_get(const nlsml_interpretation_t *interpretation)
nlsml_interpretation_t * nlsml_first_interpretation_get(const nlsml_result_t *result)
const char * nlsml_input_timestamp_start_get(const nlsml_input_t *input)
void nlsml_result_trace(const nlsml_result_t *result, apr_pool_t *pool)