/// <summary>
        /// Recursively builds a phrase structure tree from the given word.
        /// </summary>
        /// <param name="words">The array of words that make up the phrase</param>
        /// <returns>The sentence structured into a hierarchical tree</returns>
        public static Phrase buildTree(string InputPhrase, Lexicon d)
        {
            String[] words = processPhrase(InputPhrase);

            Terminal[] terminals = new Terminal[words.Length];

            for (int i = 0; i < words.Length; i++)
            {
                terminals[i] = new Terminal(words[i], d.lookupCategory(words[i]));
            }

            return merge(terminals);
        }
        public Lexicon(string filePath)
        {
            String[][] csvData = CSV.parseCSV(filePath);

            List<Terminal> definitions = new List<Terminal>();
            foreach (var line in csvData)
            {
                string word = line[0];
                string definition = line[1];

                Terminal d = new Terminal(word, stringtoLexicalCategory(definition));

                definitions.Add(d);
            }

            entries = definitions.ToArray();
        }
        /// <summary>
        /// Recursively creates a phrase structure tree with the given word set and Lexicon.
        /// </summary>
        /// <param name="d">The lexicon with definitions to use</param>
        /// <param name="terminals">The phrase to generate a tree with</param>
        /// <returns>A phrase structure tree representing the hierarchy of structures of the sentence.</returns>
        private static Phrase merge(Terminal[] terminals)
        {
            Terminal leftTerminal = terminals[0];

            // Base case
            if (terminals.Length == 1)
            {
                Intermediate i = new Intermediate(leftTerminal);
                return new Phrase(i);
            }
            else if (terminals.Length == 2)
            {
                switch (terminals[0].Category)
                {
                    case LexicalCategory.Determiner:
                        return new Phrase(new Phrase(new Intermediate(terminals[0])), new Intermediate(terminals[1]));
                }
            }
            Intermediate intermediate = new Intermediate(leftTerminal, merge(terminals.Skip(1).ToArray()));
            return new Phrase(intermediate);
        }
 // Constructor chaining see http://stackoverflow.com/questions/829870/calling-constructor-from-other-constructor-in-same-class
 /// <summary>
 /// Creates a new instance of Intermediate
 /// </summary>
 /// <param name="head">The head of the intermediate phrase</param>
 /// <param name="Complement">The complement phrase to attach</param>
 public Intermediate(Terminal head, Phrase Complement)
     : this(head)
 {
     this.Complement = Complement;
 }
 /// <summary>
 /// Creates a new instance of Intermediate
 /// </summary>
 /// <param name="head">The head of the intermediate phrase</param>
 public Intermediate(Terminal head)
 {
     Head = head;
     setPhraseCategory();
 }