-
-
Save YhorbyMatias/898bbd109bdf1938c45dc02271f954b2 to your computer and use it in GitHub Desktop.
Emotion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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