private static Dictionary <string, int> ReadWords(IWordsDirectoryProvider wordsDirectoryProvider, IWordsPreprocessor preprocessor) { var words = File.ReadLines(wordsDirectoryProvider.WordsDirectory); return(preprocessor .PreprocessWords(words) .GroupBy(word => word) .ToDictionary(wordGroup => wordGroup.Key, wordGroup => wordGroup.Count())); }
public WordsProvider(IWordsDirectoryProvider wordsDirectoryProvider, IWordsPreprocessor preprocessor) { wordToFrequency = ReadWords(wordsDirectoryProvider, preprocessor); }