예제 #1
0
        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()));
        }
예제 #2
0
 public WordsProvider(IWordsDirectoryProvider wordsDirectoryProvider, IWordsPreprocessor preprocessor)
 {
     wordToFrequency = ReadWords(wordsDirectoryProvider, preprocessor);
 }