Beispiel #1
0
        public PageWord(String page, string word, int location)
        {
            using (PageDBContext pc = new PageDBContext())
            {
                Page temp_page = null;
                Word temp_word = null;
                PageWord page_word_query = null;

                temp_page = new Page(page);
                temp_word = new Word(word);

                try
                {
                    page_word_query = pc.PageWord.First(pw => pw.WordID == temp_word.WordID && pw.PageID == temp_page.PageID && Location == location);
                }
                catch (InvalidOperationException iex)
                { }

                if (page_word_query == null)
                {
                    this.Location = location;
                    this.PageID = temp_page.PageID;
                    this.WordID = temp_word.WordID;
                    pc.PageWord.Add(this);
                    pc.SaveChanges();
                }
                else
                {
                    this.WordID = page_word_query.WordID;
                    this.PageWordID = page_word_query.PageWordID;
                    this.PageID = page_word_query.PageID;
                    this.Location = page_word_query.Location;
                }
            }
        }
Beispiel #2
0
        public Link(Page from, Page to)
        {
            using (PageDBContext pc = new PageDBContext())
            {
                Link query = null;
                try
                {
                    query = pc.Link.First(l => l.FromPage == from.PageID && l.ToPage == to.PageID);
                }
                catch (InvalidOperationException iex)
                { }

                if (query == null)
                {
                    this.FromPage = from.PageID;
                    this.ToPage = to.PageID;
                    pc.Link.Add(this);
                    pc.SaveChanges();
                }
                else
                {
                    this.FromPage = query.FromPage;
                    this.ToPage = query.ToPage;
                    this.LinkID = query.LinkID;
                }
            }
        }
Beispiel #3
0
        public void SaveEntity()
        {
            PageDBContext pc = new PageDBContext();
            Page temp_page;
            temp_page = new Page(URL, ExtractedTitle);
            List<Page> temp_page_list = new List<Page>();
            for (int i = 0; i < LINKS.Count(); i++)
            {
                Page another_temp_page;
                another_temp_page = new Page(LINKS[i]);
                new Link(temp_page, another_temp_page);
            }

            StringBuilder s_builder = new StringBuilder(ExtractedHeaders);
            s_builder.Append(ExtractedParagraphs);
            s_builder.Append(ExtractedDivs);
            s_builder.Append(ExtractedLinksText);
            string[] words = s_builder.ToString().Split(new char[] { ' ', '\n', '.', ',', '\'', '(', ')', ':', '/', '\\', '[', ']', '\"' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < words.Length; ++i)
            {
                new PageWord(URL, words[i].ToLower(), i + 1);
            }
        }
Beispiel #4
0
 public SearchResults(Page res_page, float score)
 {
     this.ResultPage = res_page;
     this.Score = score;
 }