Exemple #1
0
        public bool AllowArticle(NewsArticle newsArticle, string searchTerm, KeyValueStorage storage)
        {
            int days = storage.GetInteger(RecencyNewsFilterSettingsPage.MaxArticleAgeDaysKey,
                                          Int32.Parse(RecencyNewsFilterSettingsPage.MaxArticleAgeDefault));

            return((DateTime.Now - newsArticle.TimePublished) < TimeSpan.FromDays(days));
        }
Exemple #2
0
        public async Task Monitor(IEnumerable <ShareJobResult> results, KeyValueStorage kvs)
        {
            RedditSharpReader reader = new RedditSharpReader(new RedditSettings(kvs));

            foreach (ShareJobResult result in results)
            {
                Post post = await reader.GetPostInfo(result.Url);

                int upvoteThreshold  = kvs.GetInteger(RedditPostMonitorSettingsPage.UpvoteThreshold, 5);
                int commentThreshold = kvs.GetInteger(RedditPostMonitorSettingsPage.CommentTheshold, 5);
                if (post.Upvotes >= upvoteThreshold && post.CommentCount >= commentThreshold)
                {
                    NeedsAttention?.Invoke(this, new NeedsAttentionEventArgs(result,
                                                                             $"{result.Url} needs attention. {post.Upvotes} upvotes, {post.CommentCount} comments"));
                }
                System.Diagnostics.Debug.WriteLine($"upvoteThreshold = {upvoteThreshold}, commentThreshold = {commentThreshold}");
                System.Diagnostics.Debug.WriteLine($"post.Upvotes = {post.Upvotes}, post.CommentCount = {post.CommentCount}");
            }
        }
Exemple #3
0
        public bool AllowArticle(NewsArticle newsArticle, string searchTerm, KeyValueStorage storage)
        {
            if (_predictor.LearningDataCount < 50)
            {
                return(true);
            }
            int  predictedRating = _predictor.Predict(newsArticle);
            int  mimimumRating   = storage.GetInteger(DefaultMinimumRatingKey, DefaultMinimumRating);
            bool allow           = predictedRating >= mimimumRating;

            if (!allow)
            {
                System.Diagnostics.Debug.WriteLine($"\"{newsArticle.Title}\" predicted rated {predictedRating}, needs {predictedRating}");
            }
            return(allow);
        }
        public bool AllowArticle(NewsArticle newsArticle, string searchTerm, KeyValueStorage storage)
        {
            Uri    uri    = new Uri(newsArticle.Url);
            string domain = String.Join(".", TakeLast(uri.Host.Split('.'),
                                                      IsThreePartDomain(uri.Host) ? 3 : 2));

            InitializeDomainRater(storage);

            int minimumMonthlyVisitors = storage.GetInteger(
                DomainRatingNewsFilterSettingsPage.MinimumMonthlyVisitorsKey);

            if (minimumMonthlyVisitors <= 0)
            {
                return(true);
            }

            DomainRating rating = _domainRater.GetDomainRating(domain);

            if (rating.Decision == DomainRatingDecision.Whitelisted)
            {
                return(true);
            }
            else if (rating.Decision == DomainRatingDecision.Blacklisted)
            {
                return(false);
            }

            bool allow = rating.MonthlyVisitors >= minimumMonthlyVisitors;

            if (!allow)
            {
                System.Diagnostics.Debug.WriteLine("Not allowing domain " +
                                                   domain + " " + rating);
            }
            return(allow);
        }