Esempio n. 1
0
        // POST: /Graph/search
        public JsonResult Search(string search)
        {
            try
            {
                IEnumerable <Tweetinvi.Models.ITweet> tweets = null;
                if (search != null)
                {
                    tweets = SearchTweets.Search(search, 1000);
                    foreach (var twit in tweets)
                    {
                        Models.Tweet T = new Models.Tweet();
                        T.tweet = twit;

                        T.sentiment = Sentiment.Analyse(twit.FullText);
                        list_of_tweets.Add(T);
                    }
                    Tweets instance = Tweets.getInstance();
                    instance.tweets     = list_of_tweets;
                    instance.searchTerm = search;
                    var temp = Json(Analysis.GetPackages(instance));
                    return(temp);
                }
                else
                {
                    return(Json("search is null"));
                };
            }
            catch (Exception e)
            {
                return(Json(e));
            }
        }
Esempio n. 2
0
        public JsonResult statsJson()
        {
            Tweets           instance = Tweets.getInstance();
            List <statModel> stats    = new List <statModel>();

            foreach (var t in instance.tweets)
            {
                bool hasGeo = false;
                if (t.tweet.Place != null || t.tweet.Coordinates != null)
                {
                    hasGeo = true;
                }

                if (t.tweet.CreatedBy.FollowersCount < 10000)
                {
                    stats.Add(new statModel(t.tweet.CreatedBy.CreatedAt,
                                            t.tweet.CreatedBy.FollowersCount,
                                            t.tweet.CreatedBy.FriendsCount,
                                            t.tweet.Hashtags.Count,
                                            hasGeo,
                                            t.tweet.UserMentions.Count,
                                            t.sentiment));
                }
            }

            var orderedstats = stats.OrderBy(statModel => statModel.followerCount);

            return(Json(orderedstats));
        }
Esempio n. 3
0
        public static Package BubbleChart(Tweets tweets)
        {
            List <String>      commonwords = Sentiment.ReadFile(System.IO.Directory.GetCurrentDirectory() + @"\wwwroot\Data\Used.txt");
            List <bubbleModel> bubbles     = new List <bubbleModel>();
            List <string>      wordlist    = new List <string>();
            List <int>         wordcount   = new List <int>();
            Tweets             instance    = Tweets.getInstance();

            foreach (var t in instance.tweets)
            {
                var           fixedInput = Regex.Replace(t.tweet.Text, "[^a-zA-Z0-9% _]", string.Empty);
                List <string> splitted   = fixedInput.Split(' ').ToList();
                foreach (var s in splitted)
                {
                    var wordpos = wordlist.IndexOf(s);
                    if (wordpos == -1)
                    {
                        wordlist.Add(s);
                        wordcount.Add(1);
                    }
                    else
                    {
                        wordcount[wordpos]++;
                    }
                }
            }

            for (var i = 0; i < wordlist.Count; i++)
            {
                if (wordcount[i] > 10 && !commonwords.Contains(wordlist[i].ToLower()) && !wordlist[i].Contains("http"))
                {
                    bubbles.Add(new bubbleModel(wordlist[i], wordcount[i]));
                }
            }
            string  txt     = "This is a bubble chart (read: word cloud) of words most commonly seen in your search results.";
            Package package = new Package();

            package.data  = bubbles;
            package.text  = txt;
            package.title = "Word Use in Tweets Containing " + tweets.searchTerm;
            return(package);
        }
Esempio n. 4
0
 public JsonResult timejson()
 {
     return(Json(Analysis.HashtagOverTime(Tweets.getInstance(), Tweets.getInstance().searchTerm)));
 }
Esempio n. 5
0
 public ActionResult FavoriteHashtags()
 {
     return(Json(Analysis.FavoriteHashtags(Tweets.getInstance(), Tweets.getInstance().searchTerm)));
 }
Esempio n. 6
0
 public ActionResult commonTags()
 {
     return(Json(Analysis.commonTags(Tweets.getInstance(), Tweets.getInstance().searchTerm).ToJson()));
 }
Esempio n. 7
0
 public JsonResult Images()
 {
     return(Json(Analysis.Images(Tweets.getInstance())));
 }
Esempio n. 8
0
 public JsonResult bubbleChartJson()
 {
     return(Json(Analysis.BubbleChart(Tweets.getInstance())));
 }