static void Main(string[] args) { const string wordListPath = "wordlist.txt"; const int hashes = 5; var wordCount = CountWords(wordListPath); var spellchecker = new SpellingChecker(new FNV1aHashAlgorithm(), wordCount, hashes); var fiveLetterWords = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); using (var reader = new StreamReader(wordListPath)) { string word; while ((word = reader.ReadLine()) != null) { word = word.Trim(); spellchecker.Add(word); if (word.Length == 5) { fiveLetterWords.Add(word); } } } using (var reader = new StreamReader(wordListPath)) { try { string word; while ((word = reader.ReadLine()) != null) { Contract.Assert(spellchecker.Check(word)); } } catch (Exception e) { Console.WriteLine(e); } } var stats = new Statistics { Count = 50000 }; stats.Found = GenerateWords(stats.Count, fiveLetterWords).Count(spellchecker.Check); Console.WriteLine("Using {0} hashes, checked {1} words, found {2} collisions", hashes, stats.Count, stats.Found); Console.WriteLine(); Console.WriteLine("Completed, press the Enter key to exit."); Console.ReadLine(); }
static void Main(string[] args) { string input = @"rain spain plain plaint pain main mainly the in on fall falls his was === hte rame in pain fells mainy oon teh lain was hints pliant ==="; InitialData data = new InitialData(input); SpellingChecker checker = new SpellingChecker(data.Words); string fixedText = checker.CheckText(data.Text); Console.WriteLine(fixedText); Console.ReadKey(); }