示例#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
        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;
        }
示例#3
0
 public SearchQuery getSearchQuery(string rq)
 {
     Model1Container container = new Model1Container();
     return container.SearchQuerySet.Where(query => query.request == rq).Include(query => query.Tweet).Include(query => query.Occurence).First();
 }
示例#4
0
 public List<SearchQuery> getSearchQueries()
 {
     Model1Container container = new Model1Container();
     return new List<SearchQuery>(container.SearchQuerySet);
 }