コード例 #1
0
        /// <summary>
        /// Deletes a collection
        /// </summary>
        /// <param name="collectionName">Name of the collection to delete</param>
        /// <returns>True if successful</returns>
        public async Task <bool> Delete(string collectionName)
        {
            IndicoCustomRequest requestBody = new IndicoCustomRequest(APIKey, collectionName);

            HttpResponseMessage response = null;

            try
            {
                response = await Client.PostAsync(Endpoints.DeleteCollection, IndicoCustomRequest.StringContentFromObject(requestBody));

                HTTPMagic.CheckStatus(response);
                string responseBody = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <SimpleResponse>(responseBody).Results);
            }
            catch (HttpRequestException hre)
            {
                throw new IndicoAPIException(Resources.Application_API_Request_Failure, hre);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Batch explain for a classification collection
        /// </summary>
        /// <param name="collectionName">Name of the custom collection to use for explanation</param>
        /// <param name="examples">Array of strings to get prediction explanations for</param>
        /// <param name="version">API Version</param>
        /// <returns>An array of explanations for each example supplied</returns>
        public async Task <List <PredictionExplanation> > Explain(string collectionName, string[] examples, int version = DEFAULT_VERSION)
        {
            IndicoCustomRequest requestBody = new IndicoCustomRequest(APIKey, collectionName, examples)
            {
                Version = version
            };

            HttpResponseMessage response = null;

            try
            {
                response = await Client.PostAsync(Endpoints.Explain, IndicoCustomRequest.StringContentFromObject(requestBody));

                HTTPMagic.CheckStatus(response);
                string responseBody = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <BatchExplainResponse>(responseBody).Results);
            }
            catch (HttpRequestException hre)
            {
                throw new IndicoAPIException(Resources.Application_API_Request_Failure, hre);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
        }