public int compareResults(Query query, Dictionary <string, double> qres) { List <KeyValuePair <string, double> > sorted = (from kv in qres orderby kv.Value select kv).ToList(); sorted.Reverse(); List <String> docRes = new List <string>(); int result = 0; for (int i = 0; i < sorted.Count; i++) { docRes.Add(sorted[i].Key); } Console.WriteLine("Query: " + query.getNum(true)); HashSet <String> qOptimal = this.optimalResults[Int32.Parse(query.getNum(true))]; for (int i = 0; i < 50; i++) { //Console.WriteLine(Int32.Parse(query.getNum()) + " 0 " + docRes[i] + " 1 0 r"); if (qOptimal.Contains(docRes[i])) { result++; Console.Write(i + ","); } } Console.WriteLine(" "); return(result); }
// read from queries file and send queries ,one by one // the query need to look like this <top> to </top> public Dictionary <String, List <String> > multipleSearch(String pathOfQureries, bool semantic, string[] cityCheckedByUser) { Dictionary <String, List <String> > toReturn = new Dictionary <string, List <string> >(); // the path from the user String content = File.ReadAllText(pathOfQureries); String[] querySplited = content.Split(new string[] { "<top>" }, StringSplitOptions.RemoveEmptyEntries); if (semantic) { for (int i = 0; i < querySplited.Length; i++) { Query query = new Query(querySplited[i]); toReturn.Add(query.getNum(), semanticSearch(query.getQuery(), query.getRelevant(), cityCheckedByUser)); } } else { for (int i = 0; i < querySplited.Length; i++) { Query query = new Query(querySplited[i]); toReturn.Add(query.getNum(), regularSearch(query.getQuery(), query.getRelevant(), cityCheckedByUser)); } } return(toReturn); }