Ejemplo n.º 1
0
 private void Rankt_Click(object sender, RoutedEventArgs e)
 {
     if (DocsPostingPath_Box.Text == "")
     {
         System.Windows.MessageBox.Show("Posting files path is wrong.");
     }
     else
     {//case the path files
         postingPath = DocsPostingPath_Box.Text;
         if (!Directory.Exists(postingPath))
         {
             System.Windows.MessageBox.Show("The path for the posting files is not valid\n Please enter a new  path");
         }
         // everything is ok.. should continue
         else
         {
             Searcher searcher = new Searcher(postingPath);
             //Searcher.createRelevateDic();
             Searcher.createStopWordsDic();
             Searcher.ReadDocs();
             ParseQuery.createMonthDic();
             if (Query_Box.Text == "" && FilesPath.Text == "")
             {
                 System.Windows.MessageBox.Show("Please enter Query Or a Path of Files of Quries!");
             }
             else
             {
                 if (Query_Box.Text != "")
                 {
                     query = Query_Box.Text;
                     Dictionary <string, double> QureyScores = searcher.SearchSingleQuery(query, Selectedlanguages, stemmingQuery);
                     string s = "Top 50 Relevance Documents Of The Query: " + query + ":\n";
                     foreach (KeyValuePair <string, double> p in QureyScores)
                     {
                         s = s + p.Key + ": " + p.Value + "\n";
                     }
                     System.Windows.MessageBox.Show(s);
                 }
                 else
                 {
                     pathOfQueries = FilesPath.Text;
                     Dictionary <string, Dictionary <string, double> > QuriesScores = searcher.SearchFileOfQueries(pathOfQueries, Selectedlanguages, stemmingQuery);
                     foreach (KeyValuePair <string, Dictionary <string, double> > dic in QuriesScores)
                     {
                         string s = "Top 50 Relevance Documents Of The Query: " + dic.Key + ":\n";
                         foreach (KeyValuePair <string, double> p in dic.Value)
                         {
                             s = s + p.Key + ": " + p.Value + "\n";
                         }
                         System.Windows.MessageBox.Show(s);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public Dictionary <string, double> SearchSingleQuery(string query, List <string> language, bool stem)
        {
            isStem = stem;
            GetLanguage(language);
            Query q = new Query(query);

            Quries.Add(q);
            ParseQuery pq = new ParseQuery();

            pq.ParseTheQuery(ref q);
            Ranker r = new Ranker();

            r.scoreDocs(ref q);
            Dictionary <string, double> scores = q.GetTop50();

            return(scores);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// searcher of a file with quries
        /// </summary>
        /// <param name="path"></param>
        /// <param name="language"></param>
        /// <param name="stem"></param>
        public Dictionary <string, Dictionary <string, double> > SearchFileOfQueries(string path, List <string> language, bool stem)
        {
            pathOfQuries = path;
            isStem       = stem;
            GetLanguage(language);
            string[] quries;
            try
            {
                string data = System.IO.File.ReadAllText(path);
                quries = data.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            }
            catch (Exception e)
            {
                throw e;
            }
            Thread[] threads = new Thread[quries.Length];
            for (int i = 0; i < quries.Length; i++)
            {
                threads[i] = new Thread((getQuery) =>
                {
                    Query q = new Query(quries[i]);
                    Quries.Add(q);
                    ParseQuery pq = new ParseQuery();
                    pq.ParseTheQuery(ref q);
                    Ranker r = new Ranker();
                    r.scoreDocs(ref q);
                });
                threads[i].Start();
            }
            for (int i = 0; i < quries.Length; i++)
            {
                threads[i].Join();
            }
            Dictionary <string, Dictionary <string, double> > l = new Dictionary <string, Dictionary <string, double> >();

            foreach (Query qu in Quries)
            {
                l.Add(qu.QueryS, qu.GetTop50());
            }
            return(l);
        }