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(); }
private void execSearch() { string query = tbxSearch.Text; d.Index index = new d.Index(d.Helper.INDEX_PATH); d.VSSearcher searcher = new d.VSSearcher(index); d.ResultDocument[] results = searcher.Search(query); StringBuilder sb = new StringBuilder(); if (results != null) { sb.AppendFormat("<p>Found <b>{0}</b> relevant documents / displaying top 20:</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"); } ltrSearchResults.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); }
public void run() { Console.WriteLine("Index loading..."); DateTime t1 = DateTime.Now; d.Index index = new d.Index(indexPath); d.VSSearcher vs = new d.VSSearcher(index); DateTime t2 = DateTime.Now; Console.WriteLine("Query: "); string query = Console.ReadLine(); Console.WriteLine("Searching for " + query); d.ResultDocument[] results = vs.Search(query); DateTime t3 = DateTime.Now; TimeSpan diff1 = t2 - t1; TimeSpan diff2 = t3 - t2; Console.WriteLine("load index time: " + diff1.Seconds + "." + diff1.Milliseconds); Console.WriteLine("search time: " + diff2.Seconds + "." + diff2.Milliseconds); if (results != null) { Console.WriteLine(results.Length + " results:"); int max = Math.Min(10, results.Length); for (int i = 0; i < max; i++) { Console.WriteLine("\t" + results[i].DocId + " " + results[i].Similarity + " " + index.GetURL(results[i].DocId)); } } }
static void Main(string[] args) { AggregateTester at = new AggregateTester(0, 10, 1, 10, 100, 10, 5, 10, 1); at.Run(); Hashtable result = new Hashtable(); result.Add(1, true); result.Add(2, true); result.Add(3, true); Hashtable relevant = new Hashtable(); relevant.Add(1, true); relevant.Add(3, true); relevant.Add(5, true); relevant.Add(7, true); relevant.Add(8, true); d.PerformanceCalculator pc = new d.PerformanceCalculator(result, relevant); Console.WriteLine("Precision = " + pc.Precision); Console.WriteLine("Recall = " + pc.Recall); Console.WriteLine("FMeasure = " + pc.FMeasure); d.DocsLoader dl = new d.DocsLoader(); d.CatsLoader cl = new d.CatsLoader(); d.DocCatsLoader dc = new d.DocCatsLoader(cl); int docId = 1; ArrayList al = dc.GetDocCategories(docId); Console.WriteLine(dl.GetDocTitle(docId) + " has " + al.Count + " categories: "); foreach (int catId in al) { Console.WriteLine(" " + cl.GetCategory(catId)); } d.Index index = new d.Index(Helper.INDEX_PATH); d.DocTermItem[] dterms = index.DocTerms(0); SearchVS s = new SearchVS(Helper.INDEX_PATH); s.run(); i.DataLoader dal = new i.DataLoader(Helper.SOURCE_PATH); i.IndexBuilder ib = new i.IndexBuilder(dal, Helper.INDEX_PATH); ib.BuildIndex(); PorterStemmerAlgorithm.PorterStemmer ps = new PorterStemmerAlgorithm.PorterStemmer(); Console.WriteLine(ps.stemTerm("beautify")); TermFilter f = new TermFilter(); f.CreateNewTermsFile(); TermProcessor p = new TermProcessor(); p.CreateTermsFile(); TermDocsProcessor tdp = new TermDocsProcessor(); tdp.CreateTermDocsFile(); tdp.CreateTermDocsFile(); }