public WordSolver(IWordList wordList)
        {
            #region Sanity Check
            if (wordList == null)
            {
                throw new ArgumentNullException("wordList", "No word list provided.");
            }
            #endregion

            _wordList = wordList;
            _tree     = _wordList.Build();
        }
Example #2
0
        public PrefixTree Build()
        {
            PrefixTree tree = new PrefixTree();

            string[] lines = File.ReadAllLines(_file.FullName);
            foreach (string line in lines)
            {
                if (line.StartsWith("CUSTOM") || line.StartsWith("BASEWORDS") || line.StartsWith("DEFINITION"))
                {
                    continue;
                }
                else if (line.StartsWith("COMPOUND"))
                {
                    string temp = line.Trim();
                    tree.Insert(temp);
                }
                else
                {
                    tree.Insert(line);
                }
            }
            return(tree);
        }