Next: Multiple Parses Up: Syntax Previous: Parsers

Returning the Parse Tree

For a parse to be useful we often want to return the parse tree, once we've parsed the sentence. This may then be used by a semantic component, to help determine the meaning of the sentence. [We sometimes do the semantic processing at the same time as the parsing, making this unecessary. Both approaches are sometimes used.]

Anyway, in Prolog we return the parse tree by adding extra arguments to our grammar rules, like the following:


  3  noun_phrase(np(DetTree, NounTree)) --> 
        determiner(DetTree), 
        noun(Num, NounTree).

     noun(noun(banana)) --> [banana].

(The assessed exercise will include adding arguments in this manner and returning parse trees.)


alison@
Fri Aug 19 10:42:17 BST 1994