Beispiel #1
0
        private int AddToDictionary(string documentSource)
        {
            _documentReader.Load(documentSource);

            int    wordsCounter = 0;
            string word         = _documentReader.ReadNextWord();

            while (!string.IsNullOrWhiteSpace(word))
            {
                if (_filters.Any(filter => filter.Skip(word)))
                {
                    word = _documentReader.ReadNextWord();
                    continue;
                }

                foreach (IWordFormatter formatter in _formatters)
                {
                    word = formatter.ApplyFormat(word);
                }

                _documentDictionary.Put(word);

                wordsCounter++;
                word = _documentReader.ReadNextWord();
            }

            return(wordsCounter);
        }