Example #1
0
        private void execAuthorities()
        {
            float w = Convert.ToSingle(tbxPagerank.Text);

            d.Index            index    = new d.Index(getIndexDir());
            d.VSSearcher       searcher = new d.VSSearcher(index, w);
            d.ResultDocument[] results  = searcher.Search(tbxQuery.Text.Trim());
            if (results != null && results.Length > 0)
            {
                StringBuilder sb = new StringBuilder();

                int            rootSize    = Convert.ToInt32(tbxRoot.Text);
                int            maxParents  = Convert.ToInt32(tbxParents.Text);
                int            maxChildren = Convert.ToInt32(tbxChildren.Text);
                d.AHPageLoader ahl         = new d.AHPageLoader(index, results, rootSize, maxParents, maxChildren);
                d.AHDocument[] authorities = ahl.Authorities;

                int max = Math.Min(authorities.Length, Convert.ToInt32(tbxDisplay.Text));

                sb.AppendFormat("<p style='border-bottom:solid 1px #999999;'>Your search returned <b>{0}</b> results. " +
                                "Displaying the top {1} authorities:</p>", results.Length, max);
                sb.Append("<table style='font-family:Verdana;font-size:10pt;' cellpadding='3' cellspacing='2' width='100%'>");
                sb.Append("<tr bgcolor='#f1f1f1'><td>authority score</td><td>hub score</td><td>document</td></tr>");

                for (int i = 0; i < max; i++)
                {
                    int    docId = authorities[i].DocId;
                    string url   = "http://" + index.GetURL(docId).Replace("%%", "/");
                    sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td><p style='margin-bottom:-10px;'><a style='font-size:11pt;' href='{2}'>{3}</a>",
                                    authorities[i].AuthorityScore, authorities[i].HubScore, url, index.GetTitle(docId));
                    sb.AppendFormat("<p><a style='color:green;font-size:9pt' href='{0}'>{0}</a></td></tr>", url);
                }
                sb.Append("</table>");
                ltrResults.Text = sb.ToString();
            }
            else
            {
                ltrResults.Text = "There were no results";
            }
        }
Example #2
0
        public void run()
        {
            d.VSSearcher vs = new d.VSSearcher(index, 0.6f);

            while (true)
            {
                Console.WriteLine("Query: ");
                string query = Console.ReadLine();
                if (query == "")
                {
                    break;
                }
                d.ResultDocument[] searchResults = vs.Search(query);

                if (searchResults != null && searchResults.Length > 0)
                {
                    d.AHPageLoader ahl         = new d.AHPageLoader(index, searchResults, 50, 20, 20); //if root>100, then bad results
                    d.AHDocument[] authorities = ahl.Authorities;
                    for (int i = 0; i < 20; i++)
                    {
                        Console.WriteLine(" a=" + authorities[i].AuthorityScore + " h=" + authorities[i].HubScore + " " + index.GetURL(authorities[i].DocId));
                    }

                    Console.WriteLine();

                    d.AHDocument[] hubs = ahl.Hubs;
                    for (int i = 0; i < 20; i++)
                    {
                        Console.WriteLine(" a=" + hubs[i].AuthorityScore + " h=" + hubs[i].HubScore + " " + index.GetURL(hubs[i].DocId));
                    }
                }
                else
                {
                    Console.WriteLine("Your search returned 0 results");
                }
            }
        }