public static async Task Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req,
                                     [ApiHubTable(connection: "azureSQL", TableName = "TweetTextScore")] ITable <JObject> outputTable,
                                     TraceWriter log)
        {
            string jsonContent = await req.Content.ReadAsStringAsync();

            dynamic data      = JsonConvert.DeserializeObject(jsonContent);
            var     tweetText = data.TweetText.ToString();
            var     user      = data.UserDetails.UserName.ToString();

            //Call shared code to score the tweet text
            var score = await new EvaluateText().ScoreTextSentiment(tweetText);
            // Create new score entity as JObject
            var tweetScore = new JObject {
                new JProperty("Username", user),
                new JProperty("TweetText", tweetText),
                new JProperty("TextSentimentScore", score)
            };

            //Store the text score record in the database
            await StoreOutput.StoreOutputSQL(tweetScore, outputTable, log, "TweetText");

            log.Info($"Scored tweet: {tweetText}, " +
                     $"user: {user}, sentiment score: {score}");
        }
Beispiel #2
0
        public static async Task Run(
            [BlobTrigger("documents/{name}", Connection = "blobStorageConnection")] Stream myBlob,
            [ApiHubTable(connection: "azureSQL", TableName = "DocumentTextScore")] ITable <JObject> outputTable,
            string name, TraceWriter log)
        {
            var blobContent = new StreamReader(myBlob).ReadToEnd();

            //Call shared code to score the tweet text
            var textScore = await new EvaluateText().ScoreTextSentiment(blobContent);

            // Create new score entity as JObject
            var documentScore = new JObject {
                new JProperty("DocumentName", name),
                new JProperty("TextSentimentScore", textScore)
            };

            //Store the text score record in the database
            await StoreOutput.StoreOutputSQL(documentScore, outputTable, log, "DocumentName");

            log.Info($"Document scoring function processed a text file \"{name}\" and returned a score of {textScore}");
        }