ADMIN

Microsoft Cognitive Services provides a number of APIs to take advantage of Machine Learning. One of the simplest APIs to use is Sentiment Analysis.

Sentiment Analysis examines one or more text entries and determines whether each text reflects a positive or negative sentiment. It returns a number between 0 and 1: A higher number indicates a more positive sentiment, while a lower number indicates a more negative sentiment.

After you POST this to the URL, you should expect a response that includes JSON. If all goes well, you will receive an HTTP 200 response and the returned JSON will include an array of documents (the same number that you passed in the Request body). Each Response document will contain

id - matching the id of the document in the Request document.

score - A value between 0 and 1. The higher the score, the more positive the sentiment of the text; The lower the score, the more negative the text sentiment.

You may also receive an array of errors. Each error contains the following properties:

id - matching the id of the document in the Request document.

message - a detailed error message.

Below is an sample response JSON body

{"documents": [ {"score": 0.95412,"id": "text01" } ]}

Here is a bit of code to call this API from JavaScript. I am using jQuery's Ajax method and displaying output in a div, like the following: