Help me consume the IBM Watson NLU API

Asked

Viewed 185 times

2

Yesterday I watched a video of a guy who consumed Watson’s Natural Language Understanding API (IBM cloud) with JS using Node and he did some pretty cool things with it... On the other hand I’m trying to consume and see the results to do something, but I don’t even know if I’m going the right way because it’s the first time I do something like this and to make it worse there’s no documentation for C#

I’m using the Nugget pack IBM.WatsonDeveloperCloud.Naturallanguageunderstanding.v1

TokenOptions token = new TokenOptions
            {
                IamApiKey = "Minha ApiKey",
                ServiceUrl = "https://gateway.watsonplatform.net/natural-language-understanding/api"
            };

            var nlu = new NaturalLanguageUnderstandingService(token, "2018-12-19");

            var parametros = new Parameters { Text = "I'm Michael Jackson the king of POP"};

            var resultado = nlu.Analyze(parametros);

So far what I’m doing is putting a Breaking Point in "Result" and see what gives and what gives is not good! Results in the following error:

IBM.WatsonDeveloperCloud.Naturallanguageunderstanding.v1.dll: 'One or more errors occurred. (The API query failed with status code Badrequest: Bad Request | x-global-transaction-id: ffea405d5d1cfc0efeae7731 | X-DP-Watson-Tran-ID: gateway02-4272846641 | error: { "error": "no Features specified", "code": 400 })'

  • 1

    The answer of the API is this: "error": "no features specified". You haven’t forgotten something along the way?

  • 1

    I think not, in "parameters" I tried to specify the type of Feature to get only the Keywords, but still came the same answer

1 answer

1


Out of ignorance of mine, I thought the answer was a mistake when in fact I was just implementing in the wrong way.

The API asks for at least one Feature...to be specified. Before posting the doubt on the forum I had already tried to pass a Feature, but I had done it wrong and so the "mistake", so I researched more and passed the Feature the correct way, it worked and stayed that way:

TokenOptions token = new TokenOptions
        {
            IamApiKey = "Minha ApiKey",
            ServiceUrl = "https://gateway.watsonplatform.net/natural-language-understanding/api",
        };

        var nlu = new NaturalLanguageUnderstandingService(token, "2018-12-19");

        Features features = new Features();
        features.Keywords = new KeywordsOptions();

        var parametros = new Parameters { Text = "I'm Michael Jackson", Features = features };

        var resultado = nlu.Analyze(parametros).ResponseJson;

        Console.WriteLine(resultado);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.