[Previous] [Up]
Go backward to Implementing CFGs in Prolog
Go up to Context Free Grammars And How To Implement Them In Prolog

Exercises

  1. The grammar discussed in the example above can be found in ~avk/Temp/grammar.pl. Extend it to include rules corresponding to
    np -> det, noun
    vp -> verb, pp
    pp -> prep, np
    Add (more) lexicon rules for determiners, nouns, verbs and prepositions to the grammar. Use your grammar to see if strings that you make up from the words are grammatical.
  2. Add some more rules for VPs. How would you write a phrase structure rule where the LHS rewrites as three symbols on the RHS? Try to write rules for give, as in give John a bird and give the bird to John.
  3. Try generating sentences from the grammar (use the query s(X), hitting ; to see the various combinations). What do you think?

<a.von.klopp@bangor.ac.uk>

[Previous] [Up]