//[TestMethod]
        public void CorrectionTest()
        {
            DictionaryManager manager = new DictionaryManager(@"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\dictionaries");
            Dictionary enUs = manager.GetDictionary("en_US");

            enUs.PreloadDictionaries();

            Corrector corrector = new Corrector(new ErrorModel(enUs), new LanguageModel(enUs));

            Stopwatch mistakesTime = Stopwatch.StartNew();
            List<MisspelledWord> mistakes = new List<MisspelledWord>();
            using (FileChecker checker = new FileChecker("testarticle.txt", enUs))
            {
                MisspelledWord error;
                while ((error = checker.GetNextMisspelling()) != null)
                {
                    mistakes.Add(error);
                }
            }
            mistakesTime.Stop();

            Stopwatch correctionTime = Stopwatch.StartNew();
            foreach (MisspelledWord word in mistakes)
            {
                corrector.Correct(word);
            }
            correctionTime.Stop();

            TestContext.WriteLine("Mistakes search time: " + mistakesTime.ElapsedMilliseconds + " ms");
            TestContext.WriteLine("Correction time: " + correctionTime.ElapsedMilliseconds + " ms");
        }
Beispiel #2
0
        public FrequencyCounterTest()
        {
            DictionaryManager manager = new DictionaryManager(@"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\dictionaries");
            Dictionary enUs = manager.GetDictionary("en_US");

            charCounter = new CharFrequencyCounter(enUs.GetAlphabetForErrorModel(true));
            twoCharCounter = new TwoCharFrequencyCounter(enUs.GetAlphabetForErrorModel(true));
        }
Beispiel #3
0
        public MatrixGeneratorTest()
        {
            DictionaryManager manager = new DictionaryManager(@"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\dictionaries");
            Dictionary enUs = manager.GetDictionary("en_US");
            this.alphabetWithSpace = enUs.GetAlphabetForErrorModel(true).ToCharArray();
            this.alphabet = enUs.GetAlphabetForErrorModel().ToCharArray();
            Array.Sort<char>(this.alphabetWithSpace);
            Array.Sort<char>(this.alphabet);

            ErrorListParser parser = new ErrorListParser("test_errors.txt");
            testData = parser.Parse();
        }
Beispiel #4
0
 public Container()
 {
     Settings.InitSettings();
     dictManager = new DictionaryManager(Settings.DictionariesFolder, Settings.CustomDictionariesFolder);
 }
        public void GenerateSampleWordlist()
        {
            DictionaryManager manager = new DictionaryManager(@"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\dictionaries");
            Dictionary enUs = manager.GetDictionary("en_US");
            enUs.PreloadDictionaries();

            /*for (int i = 0; i < enUs.Count; i += 100)
            {
                testWords.Add(enUs[i]);
            }

            FileStream stream = new FileStream("sample.txt", FileMode.Create, FileAccess.Write);
            using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
            {
                foreach (string testWord in testWords)
                {
                    writer.WriteLine(testWord);
                }
            }*/
        }
        //[TestMethod]
        public void LookupTest()
        {
            Stopwatch loadTime = Stopwatch.StartNew();
            DictionaryManager manager = new DictionaryManager(@"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\dictionaries");
            Dictionary enUs = manager.GetDictionary("en_US");
            enUs.PreloadDictionaries();
            loadTime.Stop();

            TestContext.WriteLine("Dictionary load time: " + loadTime.ElapsedMilliseconds + " ms");

            Stopwatch searchTime = Stopwatch.StartNew();
            foreach (string word in testWords)
            {
                enUs.FindWord(word);
            }
            searchTime.Stop();

            TestContext.WriteLine("Search time: " + searchTime.ElapsedMilliseconds + " ms");
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            //NgramParser parser = new NgramParser();
            //parser.ParseNgrams("w2_.txt");

            DictionaryManager manager = new DictionaryManager("gen");
            Dictionary enUs = manager.GetDictionary("cs_CZ");

            //TwoCharFrequencyCounter counter = new TwoCharFrequencyCounter(enUs.GetAlphabetForErrorModel(true));
            //WordFrequencyCounter counter = new WordFrequencyCounter();
            //CharFrequencyCounter counter = new CharFrequencyCounter(enUs.GetAlphabetForErrorModel(true));
            //CorporaReader reader = new CorporaReader(new HCLineParser(), counter);
            //reader.ProcessFile("gen/data_cz/cz_data.txt");
            //counter.Save("gen/cs_CZ/wordFreq.txt");

            //string path = @"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\gen\data_cz"; //@"F:\_dp\english\news";
            //DictionaryGenerator generator = new DictionaryGenerator(enUs, path, "gen/cs_CZ");
            //generator.CalculateFrequences();
            //generator.Save();
            //generator.RunBatch();

            /*ErrorListParser parser = new ErrorListParser("generators/en_errors.txt");
            var data = parser.Parse();

            InsertionsMatrixGenerator generator = new InsertionsMatrixGenerator(enUs.GetAlphabetForErrorModel(true).ToCharArray());
            var matrix = generator.GenerateMatrix(data);
            MatrixExport.ExportMatrix("insertTest.txt", matrix);

            FolderCorrector analyze = new FolderCorrector(enUs, @"C:\dev\git\Pspell\SpellCheckerConsole\bin\Debug\20_newsgroups");
            analyze.CorrectFiles();
            */

            //FileCorrectionHandler handlerTest = new FileCorrectionHandler("gen/data_cz/cz_data.txt", new List<MisspelledWord>());
            //handlerTest.SaveCorrectedAs("gen/temp/cz_data_copy.txt");

            FileHandler handlerTest = new FileHandler("testcs.txt", "testcsFixed2.txt");
            //handlerTest.CopyFile();

            enUs.PreloadDictionaries();

            Corrector corrector = new Corrector(new ErrorModel(enUs), new LanguageModel(enUs), new AccentModel(enUs));

            //Queue<MisspelledWord> mistakes = new Queue<MisspelledWord>();
            using (FileChecker checker = new FileChecker("testcs.txt", enUs))
            {
                MisspelledWord error;
                while ((error = checker.GetNextMisspelling()) != null)
                {
                    //mistakes.Enqueue(error);
                    corrector.Correct(error);

                    if (error.CorrectWord != "")
                    {
                        handlerTest.Push(error);
                    }

                }
            }

            handlerTest.Close();

            //FileCorrectionHandler handler = new FileCorrectionHandler("testcs.txt", mistakes);
            //handler.SaveCorrectedAs("testcsFixed.txt");
            //handler.OverwriteWithCorrections();
        }