Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions SpellChecker.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace SpellChecker.Console
{
using System.Collections.Generic;
using System.Linq;

/// <summary>
/// The following are the "requirements" for this project:
Expand Down Expand Up @@ -45,13 +47,37 @@ public static void Main(string[] args)
// first break the sentence up into words,
// then iterate through the list of words using the spell checker
// capturing distinct words that are misspelled
if (sentence == null)
{
return;
}

var distinctListOfWords = sentence.Split(' ').Distinct().ToList();

// use this spellChecker to evaluate the words
var spellChecker = new Core.SpellChecker(new ISpellChecker[]
var spellChecker = new Core.SpellChecker(
new ISpellChecker[]
{
new MnemonicSpellCheckerIBeforeE(), new DictionaryDotComSpellChecker(),
});

var incorrectlySpelledWords = new List<string>();
foreach (var word in distinctListOfWords)
{
if (spellChecker.Check(word) == false)
{
incorrectlySpelledWords.Add(word);
}
}

if (incorrectlySpelledWords.Any())
{
System.Console.Write("The following words are misspelled: " + string.Join(", ", incorrectlySpelledWords));
}
else
{
new MnemonicSpellCheckerIBeforeE(),
new DictionaryDotComSpellChecker(),
});
System.Console.WriteLine("Congratulations, there were no misspellings!");
}
}

}
Expand Down