/// <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); }
/// <summary> /// Creates a new instance of <c>Phrase</c> and sets the <see cref="Intermediate"/> and <see cref="Specifier"/>. /// </summary> /// <param name="specifier">The speicifer phrase.</param> /// <param name="i">The Intermediate phrase.</param> public Phrase(Phrase specifier, Intermediate i) { Specifier = specifier; Intermediate = i; }
/// <summary> /// Creates a new instance of <c>Phrase</c> and sets the <see cref="Intermediate"/> /// </summary> /// <param name="i">The Intermediate phrase.</param> public Phrase(Intermediate i) { Intermediate = i; }