Ejemplo n.º 1
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.º 2
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);
        }