|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Vocabulary pruning functions for speech recognition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef ASRSVOCMANHWDEVICE_H |
|
24 #define ASRSVOCMANHWDEVICE_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <asrshwdevice.h> |
|
28 #include <nsssispeechrecognitiondatadevasr.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CVocManAlgorithm; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Class for pruning |
|
37 * When the grammar starts to get big, this class can prune |
|
38 * least used rule variants away before adding new rules. |
|
39 * |
|
40 * @lib AsrsVocmanHwDevice.dll |
|
41 * @since ?Series60_version |
|
42 */ |
|
43 class CASRSVocManHwDevice : public CASRSHwDevice |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 */ |
|
50 IMPORT_C static CASRSVocManHwDevice* NewL(); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 IMPORT_C virtual ~CASRSVocManHwDevice(); |
|
56 |
|
57 public: // Functions from base classes |
|
58 |
|
59 /** |
|
60 * From CASRHwDevice |
|
61 * Gets a custom interface |
|
62 * @since 2.8 |
|
63 * @param aInterfaceUid Uid of the interface. |
|
64 * @return Pointer to the interface. Ownership depends on UID. |
|
65 */ |
|
66 TAny* CustomInterface(TUid aInterfaceUid); |
|
67 |
|
68 /** |
|
69 * From CASRHwDevice |
|
70 * Initializes the HW Device |
|
71 * @since 2.8 |
|
72 * @return None |
|
73 */ |
|
74 void InitializeL(); |
|
75 |
|
76 /** |
|
77 * From CASRHwDevice |
|
78 * Clear HW Device's allocated memory |
|
79 * @since 2.8 |
|
80 * @return None |
|
81 */ |
|
82 void Clear(); |
|
83 |
|
84 public: // New functions |
|
85 |
|
86 /** |
|
87 * Use to adapt rule after recognition |
|
88 * @since 2.6 |
|
89 * @param aCorrectRuleVariantID Correctly recognized rule variant |
|
90 * @param aRule Rule including correct variant |
|
91 */ |
|
92 IMPORT_C void AdaptL( const TSIRuleVariantID aCorrectRuleVariantID, |
|
93 CSIRule& aRule ); |
|
94 |
|
95 /** |
|
96 * Use to prune grammar. |
|
97 * @since 2.6 |
|
98 * @param aGrammar Grammar to be pruned |
|
99 * @param aMinNumber Minimum number of items to be pruned |
|
100 * @param aPrunedItems Information which items can be removed |
|
101 * @return ETrue pruning successful, EFalse cannot be pruned |
|
102 */ |
|
103 IMPORT_C TBool Prune( const CSIGrammar& aGrammar, |
|
104 TUint32 aMinNumber, |
|
105 RArray<TSIRuleVariantInfo>& aPrunedItems); |
|
106 |
|
107 /** |
|
108 * Use to determine number of new rule variants |
|
109 * @since 2.6 |
|
110 * @param aGrammar Grammar where new variants should be added to |
|
111 * @param aTargetNRuleVariants Target number of rule variants in the grammar |
|
112 * @param aMaxNRuleVariants Maximum number of rule variants in the grammar |
|
113 * @param aNewRuleScores Score for each new rule |
|
114 * @param aNNRuleVariants Number of rule variants for each rule. |
|
115 * Array must be initialized as maximum number of rule variants per a rule. |
|
116 * @return None |
|
117 */ |
|
118 IMPORT_C void ComputeNRuleVariantsL( const CSIGrammar& aGrammar, |
|
119 const TUint32 aTargetNRuleVariants, |
|
120 const TUint32 aMaxNRuleVariants, |
|
121 const RArray<TUint>& aNewRuleScores, |
|
122 RArray<TUint>& aNNewRuleVariants, |
|
123 TUint32& aNPrune ); |
|
124 public: // Functions from base classes |
|
125 |
|
126 /** |
|
127 * From ?base_class ?member_description. |
|
128 * @since ?Series60_version |
|
129 * @param ?arg1 ?description |
|
130 * @return ?description |
|
131 */ |
|
132 //?type ?member_function( ?type ?arg1 ); |
|
133 |
|
134 protected: // New functions |
|
135 |
|
136 /** |
|
137 * ?member_description. |
|
138 * @since ?Series60_version |
|
139 * @param ?arg1 ?description |
|
140 * @return ?description |
|
141 */ |
|
142 //?type ?member_function( ?type ?arg1 ); |
|
143 |
|
144 protected: // Functions from base classes |
|
145 |
|
146 /** |
|
147 * From ?base_class ?member_description |
|
148 */ |
|
149 //?type ?member_function(); |
|
150 |
|
151 private: |
|
152 |
|
153 /** |
|
154 * C++ default constructor. |
|
155 */ |
|
156 CASRSVocManHwDevice(); |
|
157 |
|
158 /** |
|
159 * By default Symbian 2nd phase constructor is private. |
|
160 */ |
|
161 void ConstructL(); |
|
162 |
|
163 // Prohibit copy constructor if not deriving from CBase. |
|
164 // CASRVocManHwDevice( const CASRVocManHwDevice& ); |
|
165 // Prohibit assigment operator if not deriving from CBase. |
|
166 // CASRVocManHwDevice& operator=( const CASRVocManHwDevice& ); |
|
167 |
|
168 public: // Data |
|
169 // ?one_line_short_description_of_data |
|
170 //?data_declaration; |
|
171 |
|
172 protected: // Data |
|
173 // ?one_line_short_description_of_data |
|
174 //?data_declaration; |
|
175 |
|
176 private: // Data |
|
177 // ?one_line_short_description_of_data |
|
178 CVocManAlgorithm* iVMAlgorithm; |
|
179 |
|
180 // Reserved pointer for future extension |
|
181 TAny* iReserved; |
|
182 |
|
183 }; |
|
184 |
|
185 #endif // ASRSVOCMANHWDEVICE_H |
|
186 |
|
187 // End of File |