Esempio n. 1
0
        static bool BuildDictionaryFromFile(string filename)
        {
            Dictionary = new PrefixTreeDictionary();
            using (StreamReader inputFile = new StreamReader(filename))
            {
                while (!inputFile.EndOfStream)
                {
                    string word = inputFile.ReadLine().Trim().ToLower();
                    if (!string.IsNullOrEmpty(word))
                    {
                        Dictionary.Add(word);
                    }
                }
            }

            return(Dictionary.Count > 0);
        }
Esempio n. 2
0
        private static PrefixTreeDictionary ParseDictionary(string dictionaryFilename)
        {
            var dictionary = new PrefixTreeDictionary();

            using (var dictionaryFile = new StreamReader(dictionaryFilename))
            {
                while (!dictionaryFile.EndOfStream)
                {
                    string word = dictionaryFile.ReadLine().Trim().ToLower();
                    if (!string.IsNullOrEmpty(word))
                    {
                        dictionary.Add(word);
                    }
                }
            }

            return(dictionary);
        }