Пример #1
0
        /// <summary>
        /// This function retrieves all the language models that the user may use by setting the RecognizeModel
        /// public property.
        /// </summary>
        /// <param name="callback">This callback is invoked with an array of all available models. The callback will
        /// be invoked with null on error.</param>
        /// <returns>Returns true if request has been made.</returns>
        public bool GetModels(OnGetModels callback)
        {
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, "/v1/models");

            if (connector == null)
            {
                return(false);
            }

            GetModelsRequest req = new GetModelsRequest();

            req.Callback   = callback;
            req.OnResponse = OnGetModelsResponse;

            return(connector.Send(req));
        }
        /// <summary>
        /// Lists available models for Relations and Entities features, including Watson Knowledge Studio
        /// custom models that you have created and linked to your Natural Language Understanding service.
        /// </summary>
        /// <param name="callback">The OnGetModels callback.</param>
        /// <param name="customData">Optional custom data.</param>
        /// <returns>True if the call succeeds, false if the call is unsuccessful.</returns>
        public bool GetModels(OnGetModels callback, string customData = default(string))
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            GetModelsRequest req = new GetModelsRequest();

            req.Callback = callback;
            req.Data     = customData;
            req.Parameters["version"] = NaturalLanguageUnderstandingVersion.Version;
            req.OnResponse            = OnGetModelsResponse;

            RESTConnector connector = RESTConnector.GetConnector(Credentials, ModelsEndpoint);

            if (connector == null)
            {
                return(false);
            }

            return(connector.Send(req));
        }