Ejemplo n.º 1
0
        public int CountWordInBlog(List <Blog> blogs, string word)
        {
            int    count = 0;
            string text;

            foreach (Blog blog in blogs)
            {
                text = Crawler.ReadTextFrom(blog.BlogLink);
                text = TextProcessor.Preprocess(text);

                count += Regex.Matches(text.ToLower(), word.ToLower()).Count;
            }

            return(count);
        }
Ejemplo n.º 2
0
        public static void UpdateBlogsTags(List <Blog> blogs)
        {
            string text;

            foreach (Blog blog in blogs)
            {
                text = Crawler.ReadTextFrom(blog.BlogLink);
                text = TextProcessor.Preprocess(text);

                List <string> tagsList = new List <string>();
                tagsList = GetTags(text);

                tagsList = tagsList.Where(tag => tag.Length > 2).ToList();


                tagsList.AddRange(blog.Tags);
                tagsList = tagsList.Distinct <string>().ToList();

                FireBaseDatabase.UpdateBlog(blog.Id, "tags", tagsList);
            }
        }
Ejemplo n.º 3
0
        private static void CreateBlogs(Object instance, Type t)
        {
            List <string> tagsList;

            Blog   blog;
            string text;
            string date;

            FieldInfo blogsField = t.GetField("blogs", BindingFlags.Instance
                                              | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);

            Dictionary <string, List <string> > blogs = (Dictionary <string, List <string> >)blogsField.GetValue(instance);

            object[] parametersArray;

            foreach (string key in blogs.Keys)
            {
                foreach (string link in blogs[key])
                {
                    text = "";
                    date = "";

                    tagsList          = new List <string>();
                    blog              = new Blog();
                    blog.LocationName = key;
                    blog.BlogLink     = link;

                    parametersArray = new object[] { link };
                    text            = Crawler.ReadTextFrom(link);

                    tagsList  = GetTags(text);
                    blog.Tags = tagsList;

                    date      = Crawler.ReadDateFrom(link);
                    blog.Date = date;

                    FireBaseDatabase.Insert(blog);
                }
            }
        }