Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            DateTime startTime = DateTime.Now;

            PreprocessingUtility.SumWords(folderTextBox.Text, PreprocessingConsts.CategoryFilePattern, folderTextBox.Text + "\\summary.all");
            MessageBox.Show("All done in:" + (DateTime.Now.Subtract(startTime)).ToString());
        }
Exemplo n.º 2
0
        private void button14_Click(object sender, EventArgs e)
        {
            DocumentClass.LoadFromFiles(folderTextBox.Text, PreprocessingConsts.CategoryFilePattern);
            CtfIdfDictionary dictionary      = new CtfIdfDictionary(folderTextBox.Text, folderTextBox.Text + "\\" + PreprocessingConsts.SummaryFileName, 1000);
            String           summaryFilePath = Application.StartupPath + "\\Preprocessing\\" + PreprocessingConsts.SummaryFileName;
            LearningDocInfo  learningDocInfo = new LearningDocInfo(folderTextBox.Text, summaryFilePath);

            PreprocessingUtility.CreateLearningDocumentList(folderTextBox.Text, dictionary, DocumentRepresentationType.TfIdf, learningDocInfo);
            MessageBox.Show("Done");
        }
Exemplo n.º 3
0
        private void button10_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.SelectedPath = Application.StartupPath;
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                Dictionary <int, String> stopWords = PreprocessingUtility.LoadStopWords("Preprocessing\\stopwords.txt");

                DirectoryInfo rootDirInfo = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
                DateTime      startTime   = DateTime.Now;
                foreach (DirectoryInfo sourceDirInfo in rootDirInfo.GetDirectories())
                {
                    PreprocessingUtility.StemDir(sourceDirInfo.FullName, stopWords, null);
                    PreprocessingUtility.SumWords(sourceDirInfo.FullName + "\\stem\\", PreprocessingConsts.StemmedFilePattern, rootDirInfo + "\\" + sourceDirInfo.Name + PreprocessingConsts.CategoryFileExtension);
                }
                //sumowanie kategorii
                PreprocessingUtility.SumWords(folderBrowserDialog1.SelectedPath, PreprocessingConsts.CategoryFilePattern, rootDirInfo + "\\" + PreprocessingConsts.SummaryFileName);

                MessageBox.Show("All done in:" + (DateTime.Now.Subtract(startTime)).ToString());
            }
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            Dictionary <int, String> stopWords = PreprocessingUtility.LoadStopWords("Preprocessing\\stopwords.txt");

            DateTime startTime = DateTime.Now;

            /*
             * DirectoryInfo sourceDir = new DirectoryInfo(folderTextBox.Text);
             * DirectoryInfo destDir = Directory.CreateDirectory(sourceDir.FullName + "\\stem");
             * String destFile;
             * DateTime startTime = DateTime.Now;
             * foreach (FileInfo sourceFile in sourceDir.GetFiles())
             * {
             *  Console.WriteLine("Processing file: " + sourceFile);
             *  destFile = sourceFile.Name + ".stm";
             *  FileConverter.StemFile(sourceFile.FullName,destDir.FullName + "\\" + destFile, stopWords);
             * }
             */
            PreprocessingUtility.StemDir(folderTextBox.Text, stopWords, null);
            MessageBox.Show("All done in:" + (DateTime.Now.Subtract(startTime)).ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stemuje wszystkie pliki w danym katalogu. Nie uwzglêdnia podkatalogów.
        /// Pliki po stemmingu s¹ zapisywane do podkatalogu "stem", który zostaje utworzony.
        /// Wynikowy plk ma nazwê pliku wejœciowego i rozszerzenie ".stm".
        /// </summary>
        /// <param name="sourceDir">Katalog zawieraj¹ce pliki wejœciowe.</param>
        /// <param name="stopWords">Lista "stop words"</param>
        public static void StemDir(String sourceDir, Dictionary <int, String> stopWords, BackgroundWorker bWorker)
        {
            DirectoryInfo sourceDirInfo = new DirectoryInfo(sourceDir);
            DirectoryInfo destDirInfo   = Directory.CreateDirectory(sourceDirInfo.FullName + "\\stem");
            String        destFile;

            foreach (FileInfo sourceFile in sourceDirInfo.GetFiles())
            {
                Console.WriteLine("Processing file: " + sourceFile);
                destFile = sourceFile.Name + PreprocessingConsts.StemmedFileExtension;//".stm";
                PreprocessingUtility.StemFile(sourceFile.FullName, destDirInfo.FullName + "\\" + destFile, stopWords);

                //worer
                if (bWorker != null)
                {
                    if (bWorker.CancellationPending)
                    {
                        return;
                    }
                    bWorker.ReportProgress(1);
                }
            }
        }