/// <summary> /// Use text analytics services and detect whether a review is positive or not positive and print out the result to the console /// </summary> static async Task Task1() { var request = client.GetSentimentRequest(); var documents = request.Body.SetEmptyArray("documents"); int i = 0; foreach (string review in ReadReviewsFromJson().Take(10)) { var document = documents.AddEmptyObjet(); document["id"] = (++i).ToString(); document["text"] = review; } DynamicResponse response = await request.SendAsync(); if (response.Status == 200) { foreach (var document in response.Body["documents"].Items) { // NOTE(ellismg): There are quotes around these values in the output because ToString() JSON Serializes the value. Console.WriteLine($"{document["id"]} is {document["sentiment"]}"); } } else { Console.Error.WriteLine(response.Body["error"]); } }
/// <summary> /// Use text analytics services and detect whether a review is positive or not positive and print out the result to the console /// </summary> static async Task Task1() { var request = client.GetSentimentRequest(); var documents = request.Body.SetEmptyArray("documents"); int i = 0; foreach (string review in ReadReviewsFromJson().Take(10)) { var document = documents.AddEmptyObject(); document["id"] = (++i).ToString(); document["text"] = review; } DynamicResponse response = await request.SendAsync(); if (response.Status == 200) { foreach (var document in response.Body["documents"].Items) { Console.WriteLine($"{document["id"]} is {document["sentiment"]}"); } } else { Console.Error.WriteLine(response.Body["error"]); } }