コード例 #1
0
ファイル: Parse.cs プロジェクト: barbelity/SearchEngine
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="PathData">path to data files</param>
 /// <param name="indexer">instance of indexer</param>
 /// <param name="stemming">yes/no stemming</param>
 public Parse(string PathData, string PathPosting, Indexer indexer, bool stemming)
 {
     d_abNumTerms = new SortedDictionary<string, Term>();
     d_cfTerms = new SortedDictionary<string, Term>();
     d_gmTerms = new SortedDictionary<string, Term>();
     d_nrTerms = new SortedDictionary<string, Term>();
     d_szTerms = new SortedDictionary<string, Term>();
     use_stem = stemming;
     filesPath = PathData;
     _indexer = indexer;
     postingPath = PathPosting;
     StopWords = ReadFile.readStopWords(PathData + @"\stop_words.txt");
     if (!File.Exists(PathPosting + @"\stop_words.txt"))
     {
         File.Copy(PathData + @"\stop_words.txt", PathPosting + @"\stop_words.txt");
     }
     if (months.Count ==0)
     {
         addMonths();
     }
 }
コード例 #2
0
        private void btn_startParsing_Click(object sender, RoutedEventArgs e)
        {
            if (txtbx_filesPath.Text.Length != 0)
            {
                if (!Directory.Exists(txtbx_filesPath.Text))
                {
                    MessageBox.Show("Please enter a valid Data Files path");
                    return;
                }
                filesPath = txtbx_filesPath.Text;
            }
            else
            {
                MessageBox.Show("Please enter Data Files path");
                return;
            }
            if (txtbx_postingPath.Text.Length != 0)
            {
                if (!Directory.Exists(txtbx_postingPath.Text))
                {
                    MessageBox.Show("Please enter a valid Posting Files path");
                    return;
                }
                postingPath = txtbx_postingPath.Text;
            }
            else
            {
                MessageBox.Show("Please enter Posting Files path");
                return;
            }

            try
            {
                File.Create(postingPath + @"\abNumsPosting.txt").Dispose();
                File.Create(postingPath + @"\cfPosting.txt").Dispose();
                File.Create(postingPath + @"\gmPosting.txt").Dispose();
                File.Create(postingPath + @"\nrPosting.txt").Dispose();
                File.Create(postingPath + @"\szPosting.txt").Dispose();
                if (Directory.Exists(postingPath + @"\docs"))
                    Directory.Delete(postingPath + @"\docs");
                Directory.CreateDirectory(postingPath + @"\docs");
            }
            catch (Exception exp)
            {

                return;
            }

            btn_startParsing.IsEnabled = false;
            btn_loadPosting.IsEnabled = false;
            indexer = new Indexer(postingPath);
            ranker.postingPath = postingPath;
            parser = new Parse(filesPath, postingPath, indexer, cb_Stemmeing.IsChecked.Value);
            parser.ModelChanged += vModelChanged;
            Thread thread = new Thread(new ThreadStart(parser.startParsing));
            thread.Start();
            btn_runQuery.IsEnabled = true;
            btn_runQueryFile.IsEnabled = true;
        }
コード例 #3
0
        private void btn_loadPosting_Click(object sender, RoutedEventArgs e)
        {
            if (txtbx_postingPath.Text.Length != 0)
            {
                if (!Directory.Exists(txtbx_postingPath.Text))
                {
                    MessageBox.Show("Please enter a valid Posting Files path");
                    return;
                }

                postingPath = txtbx_postingPath.Text;
            }
            else
            {
                MessageBox.Show("Please enter Posting Files path");
                return;
            }
            indexer = new Indexer(postingPath, true);
            ranker.postingPath = postingPath;
            btn_startParsing.IsEnabled = false;
            btn_loadPosting.IsEnabled = false;
            btn_runQuery.IsEnabled = true;
            btn_runQueryFile.IsEnabled = true;
            MessageBox.Show("Posting was loaded from file");
        }