示例#1
0
        public void Mine()
        {
            Model1Container container = new Model1Container();
            _query =
                container.SearchQuerySet.Include(searchQuery => searchQuery.Tweet).First(searchQuery => searchQuery.Id == _query.Id);
            //do all here
            _tweets =  new List<Tweet>(_query.Tweet);
            foreach (var tweet in _tweets)
            {

                string[]  w = tweet.text.ToLower().Split(' ');
                foreach (var s in w)
                {
                    if (s.StartsWith("@"))
                    {
                        _refs++;
                    }
                    else if (s.StartsWith("#"))
                    {
                        _hashtags++;
                        AddOrEditHashTags(s);

                    }
                    else
                    {
                        AddOrEdit(s);

                    }
                    _total++;
                }
            }
        }
示例#2
0
 public AnalysedQuery Mine(SearchQuery query)
 {
     //do stuff
     AnalysedQuery analysedQuery = new AnalysedQuery(query);
     analysedQuery.Mine();
     return analysedQuery;
     //return AnalyzedQuery
 }
示例#3
0
        List<Tweet> BasicSearch(string str)
        {
            Search srch;
            SearchQuery qu;
            Model1Container container = new Model1Container();
            container.Configuration.AutoDetectChangesEnabled = false;

            List<Tweet> returnList = new List<Tweet>();
            if(_context.RateLimitRemaining < 50)
            {
                Thread.Sleep(_context.RateLimitReset*1000 + 20000);
            }
            if (container.SearchQuerySet.Any(query => query.request == str))
            {
                qu = container.SearchQuerySet.FirstOrDefault(query => query.request == str);
                srch =
                    (from search in _context.Search
                        where search.Type == SearchType.Search &&
                              search.Query == str &&  search.SearchLanguage == "en" &&
                              search.Count == 100 && search.MaxID == (ulong) qu.lowestId select search)
                .SingleOrDefault();
                qu.lowestId = Int64.Parse(srch.Statuses.Min(status => status.StatusID));
            }
            else
            {
                qu = new SearchQuery();
                srch =
                (from search in _context.Search
                 where search.Type == SearchType.Search &&
                       search.Query == str &&
                       search.Count == 100
                 select search)
                .SingleOrDefault();
                qu.request = str;
                qu.lowestId = Int64.Parse(srch.Statuses.Min(status => status.StatusID));
                container.SearchQuerySet.Add(qu);
            }

            foreach (var entry in srch.Statuses)
            {
                Tweet tweet = new Tweet();
                tweet.lang = entry.Lang;
                tweet.text = entry.Text;
                tweet.user = entry.User.Name;

                tweet.SearchQuery = qu;
                tweet.statusID = entry.StatusID;
                tweet.date = entry.CreatedAt;
                tweet.retweet = entry.Retweeted;
                container.TweetSet.Add(tweet);
                returnList.Add(tweet);
            }
            container.SaveChanges();

            return returnList;
        }
示例#4
0
 public int GetTweetCount(SearchQuery query)
 {
     return query.Tweet.Count;
 }
示例#5
0
 /// <summary>
 /// please feed an eager loaded query with all tweets
 /// </summary>
 /// <param name="query"></param>
 public AnalysedQuery(SearchQuery query)
 {
     _query = query;
     _request = _query.request;
 }