@@ -1239,10 +1239,95 @@ private void OnUpgradeCustomizationResp(RESTConnector.Request req, RESTConnector
1239
1239
}
1240
1240
#endregion
1241
1241
1242
- #region Custom Corpora
1242
+ #region Get Custom Corpora
1243
+ /// <summary>
1244
+ /// This callback is used by the GetCustomCorpora() function.
1245
+ /// </summary>
1246
+ /// <param name="corpora">The corpora</param>
1247
+ /// <param name="data">Optional custom data.</param>
1248
+ public delegate void GetCustomCorporaCallback ( Corpora corpora , string data ) ;
1249
+
1250
+ /// <summary>
1251
+ /// Lists information about all corpora that have been added to the specified custom language model. The information includes the total number of words and out-of-vocabulary (OOV) words, name, and status of each corpus. Only the owner of a custom model can use this method to list the model's corpora.
1252
+ /// Note: This method is currently a beta release that is available for US English only.
1253
+ /// </summary>
1254
+ /// <param name="callback">The callback.</param>
1255
+ /// <param name="language">The language for which custom models are to be returned. Currently, only en-US (the default) is supported.</param>
1256
+ /// <param name="customData">Optional custom data.</param>
1257
+ /// <returns></returns>
1258
+ public bool GetCustomCorpora ( GetCustomCorporaCallback callback , string customizationID , string customData = default ( string ) )
1259
+ {
1260
+ if ( callback == null )
1261
+ throw new ArgumentNullException ( "callback" ) ;
1262
+ if ( string . IsNullOrEmpty ( customizationID ) )
1263
+ throw new ArgumentNullException ( "A customizationID is required to GetCustomCorpora" ) ;
1264
+
1265
+ GetCustomCorporaReq req = new GetCustomCorporaReq ( ) ;
1266
+ req . Callback = callback ;
1267
+ req . Data = customData ;
1268
+ req . CustomizationID = customizationID ;
1269
+ req . OnResponse = OnGetCustomCorporaResp ;
1270
+
1271
+ string service = "/v1/customizations/{0}/corpora" ;
1272
+ RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , string . Format ( service , customizationID ) ) ;
1273
+ if ( connector == null )
1274
+ return false ;
1275
+
1276
+ return connector . Send ( req ) ;
1277
+ }
1278
+
1279
+ private class GetCustomCorporaReq : RESTConnector . Request
1280
+ {
1281
+ public GetCustomCorporaCallback Callback { get ; set ; }
1282
+ public string CustomizationID { get ; set ; }
1283
+ public string Data { get ; set ; }
1284
+ }
1285
+
1286
+ private void OnGetCustomCorporaResp ( RESTConnector . Request req , RESTConnector . Response resp )
1287
+ {
1288
+ Corpora corpora = new Corpora ( ) ;
1289
+ if ( resp . Success )
1290
+ {
1291
+ try
1292
+ {
1293
+ fsData data = null ;
1294
+ fsResult r = fsJsonParser . Parse ( Encoding . UTF8 . GetString ( resp . Data ) , out data ) ;
1295
+ if ( ! r . Succeeded )
1296
+ throw new WatsonException ( r . FormattedMessages ) ;
1297
+
1298
+ object obj = corpora ;
1299
+ r = sm_Serializer . TryDeserialize ( data , obj . GetType ( ) , ref obj ) ;
1300
+ if ( ! r . Succeeded )
1301
+ throw new WatsonException ( r . FormattedMessages ) ;
1302
+ }
1303
+ catch ( Exception e )
1304
+ {
1305
+ Log . Error ( "Speech To Text" , "OnGetCustomCorporaResp Exception: {0}" , e . ToString ( ) ) ;
1306
+ resp . Success = false ;
1307
+ }
1308
+ }
1309
+
1310
+ if ( ( ( GetCustomCorporaReq ) req ) . Callback != null )
1311
+ ( ( GetCustomCorporaReq ) req ) . Callback ( resp . Success ? corpora : null , ( ( GetCustomCorporaReq ) req ) . Data ) ;
1312
+ }
1313
+ #endregion
1314
+
1315
+ #region Delete Custom Corpora
1316
+ #endregion
1317
+
1318
+ #region Add Custom Corpora
1319
+ #endregion
1320
+
1321
+ #region Get Custom Words
1322
+ #endregion
1323
+
1324
+ #region Add Custom Words
1325
+ #endregion
1326
+
1327
+ #region Delete Custom Words
1243
1328
#endregion
1244
1329
1245
- #region Custom Words
1330
+ #region Get Custom Word
1246
1331
#endregion
1247
1332
1248
1333
#region IWatsonService interface
0 commit comments