private void execSim() { int docId = Convert.ToInt32(ddlDocs.SelectedValue); d.Index index = new d.Index(d.Helper.INDEX_PATH); d.DocVSSearcher searcher = new d.DocVSSearcher(index, new d.DocsLoader(), new d.CatsLoader()); d.ResultDocument[] results = searcher.Search(docId, 20); StringBuilder sb = new StringBuilder(); if (results != null) { sb.AppendFormat("<p>Displaying <b>20</b> most similar documents:</p><table cellpadding=5 cellspacing=0 border=1>", results.Length); sb.Append("<tr bgcolor=#f1f1f1><td><b>similarity</b></td><td><b>title</b></td></tr>"); int max = Math.Min(20, results.Length); for (int i = 0; i < max; i++) { sb.AppendFormat("<tr><td>{0}</td><td><a href='http://en.wikipedia.org/wiki/{1}'>{1}</a></td></tr>", results[i].Similarity, index.GetURL(results[i].DocId)); } sb.Append("</table>"); } else { sb.Append("<p>Found <b>0</b> results"); } ltrSimResults.Text = sb.ToString(); }
public Tester(d.DocsLoader dLoader, d.CatsLoader cLoader, d.DocCatsLoader dcLoader) { this.dLoader = dLoader; this.cLoader = cLoader; this.dcLoader = dcLoader; Console.WriteLine("Loading index..."); index = new d.Index(d.Helper.INDEX_PATH); searcher = new d.DocVSSearcher(index, dLoader, cLoader); }