示例#1
0
        public async Task <TweetAnalizedModel> GetSentimentAnalysisForTweetWithoutComments(ITweet tweet)
        {
            if (tweet.Text == null)
            {
                throw new ArgumentException("No text");
            }

            var sentimentAnalysis = await _sentimentService.GetSentimentAnalysisForTextAsync(tweet.Text);

            return(new TweetAnalizedModel()
            {
                TweetText = tweet.Text,
                SentimentObjectModel = sentimentAnalysis,
                Username = tweet.CreatedBy.Name,
                Latitude = tweet.CreatedBy.GeoEnabled ? tweet.Coordinates.Latitude : 0,
                Longitude = tweet.CreatedBy.GeoEnabled ? tweet.Coordinates.Longitude : 0
            });
        }
        public async Task <IActionResult> GetSentiment([FromBody] SentimentObjectModel text)
        {
            var result = await _setimentService.GetSentimentAnalysisForTextAsync(text.Text);

            return(Ok(result));
        }