Exemple #1
0
        public async Task <data.AnalysisResult> SentimentAnalysisAsync(Tweetinvi.Core.Interfaces.ITweet item)
        {
            return(await Task <data.AnalysisResult> .Run(() => {
                if (string.IsNullOrWhiteSpace(item.Text))
                {
                    return new data.AnalysisResult(data.AnalysisResultSentiment.Error);
                }


                var sentiment = FindSentiment(item.Text);

                switch (sentiment)
                {
                case StafordCoreNlpSentimentClass.VeryNegative:
                case StafordCoreNlpSentimentClass.Negative:
                    return new data.AnalysisResult(data.AnalysisResultSentiment.Negative);

                case StafordCoreNlpSentimentClass.Neutral:
                    return new data.AnalysisResult(data.AnalysisResultSentiment.Neutral);

                case StafordCoreNlpSentimentClass.Positive:
                case StafordCoreNlpSentimentClass.VeryPositive:
                    return new data.AnalysisResult(data.AnalysisResultSentiment.Positive);

                default:
                    return new data.AnalysisResult(data.AnalysisResultSentiment.Error);
                }
            }));
        }
        public static string GetTweetAsString(long tweetId)
        {
            string tweetMessage;

            Tweetinvi.Core.Interfaces.ITweet tweet = Tweet.GetTweet(tweetId);
            tweetMessage = tweet.Text;

            return(tweetMessage);
        }
        public static long PostATweetOnAWall(string username, string question)
        {
            Tweetinvi.Core.Interfaces.ITweet newTweet = null;
            if (username != null)
            {
                string tweetText = "@" + username + " " + question;
                newTweet = Tweet.PublishTweet(tweetText);
            }
            else
            {
                throw new NullReferenceException();
            }

            return(newTweet.Id);
        }
        public static long PublishTweet(string tweet_string, long?inReplyToTweetId)
        {
            Tweetinvi.Core.Interfaces.ITweet newTweet = null;
            if (inReplyToTweetId == 0)
            {
                newTweet = Tweet.PublishTweet(tweet_string);
            }
            else
            {
                newTweet = Tweet.PublishTweet(tweet_string, new PublishTweetOptionalParameters {
                    InReplyToTweetId = inReplyToTweetId
                });
            }
            PublishTweetOptionalParameters parameters = new PublishTweetOptionalParameters();

            parameters.InReplyToTweetId = newTweet.Id;

            return(newTweet.Id);
            //            newTweet.
        }