예제 #1
0
        private void Search(object sender, RoutedEventArgs e)
        {
            if (!DataLoaded)
            {
                outlog.Content = "加载数据中,请稍后";
                return;
            }


            outlog.Content = "搜索中,请稍后";
            ListView1.Items.Clear();
            GetTimeElapsed();

            List <string> words = Splitter.GetWords(inputBox.Text);

            List <int> results  = GetRawSearchResult(wordsManager, words);
            List <int> wordidxs = wordsManager.GetWordsIndex(words);

            results = Rank.SortResult(wordsManager, results, wordidxs, 0.005);

            foreach (int id in results)
            {
                var item = DisplayItem.GetDisplayItem(reader, id);
                ListView1.Items.Add(item);
            }


            this.outlog.Content = String.Format("找到 {0} 条搜索结果,耗时 {1:F3} s", results.Count, GetTimeElapsed());
        }
예제 #2
0
        static void Main(string[] args)
        {
            //LaunchSpider("http://www.nwpu.edu.cn");

            DBReader reader = new DBReader();

            reader.ReadDBIndex();

            reader.ReadDBContent();

            //CalculateArgument(reader);

            WordsManager wordsManager = new WordsManager();

            wordsManager.LoadFromLocal();

            Rank.LoadFromLocal();

            Console.WriteLine("初始化完成");

            while (true)
            {
                string text = Console.ReadLine();
                if (text.ToLower() == "exit")
                {
                    break;
                }

                List <string> words = Splitter.GetWords(text);

                List <int> results  = GetRawSearchResult(wordsManager, words);
                List <int> wordidxs = wordsManager.GetWordsIndex(words);

                results = Rank.SortResult(wordsManager, results, wordidxs, 0.001);

                Console.WriteLine(String.Join("\n", reader.PageIdx2Description(results)));
            }
        }