Example #1
0
        public static async Task <int> PublishTweets([ActivityTrigger] List <TweetProcessingData> tpds, ILogger log)
        {
            log.LogInformation($"A_PublishTweets: Publishing {tpds.Count} tweets.");

            double minScoreBLAlert = TweetAnalysis.GetScoreFromEnv("AZTWITTERSAR_MINSCORE_ALERT", log, 0.1f);

            foreach (var tpd in tpds)
            {
                string slackMsg = "";
                if (tpd.Score > minScoreBLAlert)
                {
                    slackMsg += $"@channel\n";
                }
                slackMsg +=
                    $"{tpd.FullText}\n"
                    + $"Score (v{AzTwitterSarVersion.get()}): {tpd.Score.ToString("F", CultureInfo.InvariantCulture)}, "
                    + $"ML ({tpd.VersionML}): {tpd.ScoreML.ToString("F", CultureInfo.InvariantCulture)}\n"
                    + $"Link: http://twitter.com/politivest/status/{tpd.IdStr}";

                log.LogInformation($"Message: {slackMsg}");
                int sendResult = await SlackClient.PostSlackMessageAsync(log, slackMsg);

                log.LogInformation($"Message posted to slack, result: {sendResult}");
            }

            log.LogInformation($"A_PublishTweets: Done.");

            return(0);
        }
Example #2
0
        public static Tuple <double, PublishLabel, string> GetBusinessLogicScore([ActivityTrigger] string textWithoutTags, ILogger log)
        {
            log.LogInformation("A_GetBusinessLogicScore: Start.");
            string highlightedText;
            double score = TweetAnalysis.ScoreTweet(textWithoutTags,
                                                    out highlightedText);
            double minScoreBL = TweetAnalysis.GetScoreFromEnv("AZTWITTERSAR_MINSCORE", log, 0.01f);

            PublishLabel label = PublishLabel.Negative;

            if (score > minScoreBL)
            {
                label = PublishLabel.Positive;
            }

            log.LogInformation("A_GetBusinessLogicScore: Done.");

            return(new Tuple <double, PublishLabel, string>(score, label, highlightedText));
        }