Ejemplo n.º 1
0
        public String Post([FromBody] JObject json)
        {
            res = json;
            String bot_id = json.SelectToken("event.bot_id") != null?json.SelectToken("event.bot_id").ToString() : "";

            if (bot_id == "")
            {
                String            text              = json.SelectToken("event.text").ToString();
                String            channel           = json.SelectToken("event.channel").ToString();
                SentimentResponse sentimentResponse = _aylienService.getSentimentScore(text);
                String            sentiment         = sentimentResponse.polarity;
                if (sentimentResponse.polarity_confidence >= 0.7)
                {
                    string msg      = GetMessageString(ref sentiment);
                    String giphyUrl = _giphyService.GetGiphyUrl(sentiment);
                    String response = _slackService.SendResponseToSlack(channel, giphyUrl, msg);
                    Thread.Sleep(1000);
                    pres = response;
                    return(response);
                }
            }
            pres = "No response as polarity was too low";
            return("No response as polarity was too low");
        }
Ejemplo n.º 2
0
        public void TestSadSentiment()
        {
            AylienSentimentFetch sentimentFetch = new AylienSentimentFetch();

            Assert.AreEqual("negative", sentimentFetch.getSentimentScore("I am Sad Today").polarity);
        }
Ejemplo n.º 3
0
        public void TestHappySentiment()
        {
            AylienSentimentFetch sentimentFetch = new AylienSentimentFetch();

            Assert.AreEqual("positive", sentimentFetch.getSentimentScore("I am Happy Today").polarity);
        }