Exemple #1
0
        public IEnumerable <string> FindMatching(string word, string dictPath)
        {
            IDictionaryReader reader = new DictionaryFileReader();
            var dictWords            = reader.ReadDictionary(dictPath)
                                       .Replace("\r", string.Empty)
                                       .Split('\n');

            ITwoWordChecker checker  = new TwoAnagramChecker();
            var             matching = dictWords
                                       .Where(x => checker.checkTwoWords(x, word))
                                       .Where(x => !x.ToUpper().Equals(word.ToUpper()));

            return(matching);
        }
        private async Task <IEnumerable <string> > ParseDictionary()
        {
            DictionaryFileReader dict = new DictionaryFileReader();
            string dictionaryContent  = await dict.ReadDictionaryAsync();

            List <string> words = new List <string>();

            var dictionaryWords = dictionaryContent.Replace("\r", string.Empty).Split('\n');

            foreach (var curLine in dictionaryWords)
            {
                var curWords = curLine.Split("=");
                if (curWords.Length == 2)
                {
                    words.AddRange(curWords);
                }
            }

            return(words);
        }