Skip to content

Instantly share code, notes, and snippets.

@YhorbyMatias
Created September 20, 2018 18:56
Show Gist options
  • Save YhorbyMatias/898bbd109bdf1938c45dc02271f954b2 to your computer and use it in GitHub Desktop.
Save YhorbyMatias/898bbd109bdf1938c45dc02271f954b2 to your computer and use it in GitHub Desktop.
Emotion
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
// The sentiment category defaults to 'GREEN'.
string category = "GREEN";
// Get the sentiment score from the request body.
double score = await req.Content.ReadAsAsync<double>();
log.Info(string.Format("The sentiment score received is '{0}'.",
score.ToString()));
// Set the category based on the sentiment score.
if (score < .3)
{
category = "RED";
}
else if (score < .6)
{
category = "YELLOW";
}
return req.CreateResponse(HttpStatusCode.OK, category);
}
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
// The sentiment category defaults to 'GREEN'.
string category = "GREEN";
// Get the sentiment score from the request body.
double score = await req.Content.ReadAsAsync<double>();
log.Info(string.Format("The sentiment score received is '{0}'.",
score.ToString()));
// Set the category based on the sentiment score.
if (score < .3)
{
category = "RED";
}
else if (score < .6)
{
category = "YELLOW";
}
return req.CreateResponse(HttpStatusCode.OK, category);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment