Yliopiston etusivulle In English
Helsingin yliopisto
clt361: Grammar Engineering - lukuvuosi 2009-2010

Yhteystiedot

Nykykielten laitos

PL 24 (Unioninkatu 40)
00014 HELSINGIN YLIOPISTO

Puhelin +358 (09) 1911 (vaihde)
Faksi +358 (09) 191 28313

Context-Free Grammars

  • Make your own working directory (for example, clt361) for the practical work in this course.
  • Make a subdirectory lkb-cfg-1 for this exercise. Copy all the files from ~gwilcock/delphin/lkb/src/data/itfs/g1cfg into your lkb-cfg-1 directory. These files define the different parts (lexicon, types, rules, etc) of a simple context-free grammar. The script file specifies which files need to be loaded.
  • Start LKB, use Load->Complete grammar, and select the script file from your lkb-cfg-1 directory to load the context-free grammar. Parse this dog sleeps. Then try this cat sleeps, which fails because there is no lexical entry for cat.

Editing lexical entries

  • Using Emacs or any text editor, edit the lexicon lexicon.tdl in your lkb-cfg-1 directory. Add a lexicon entry for cat like the entry for dog. Reload the grammar and try parsing this cat sleeps again, which should now be parsed OK.
  • Add lexical entries for that, those, cats, walks, walk. Reload the grammar and try parsing that dog walks, those cats walk.
  • How can you extend the grammar to parse sentences like that dog chased this cat? The NPs that dog and this cat are fine, but you need to add a lexical entry for chased.
  • Add a lexical entry for chased by copying the lexical entry for sleeps, and reload the grammar. Try parsing that dog chased this cat. The grammar still does not allow it, but it does allow that dog chased, which is wrong.

Editing types

  • The point is that sleeps is an intransitive verb that does not take an object NP, and chased is a transitive verb that does take an object NP. So, edit the lexical entry for chased, by changing its CATEG from vp (verb phrase) to vt (verb transitive).
  • Now try reloading the grammar. You get an error message INVALID TYPE VT, because vt is not recognized. This is helpful: you might have simply typed vt by mistake instead of vp. If you want to use vt, you must declare it as a new type in the type hierarchy.
  • Using a text editor, edit the file types.tdl in your lkb-cfg-1 directory. Add a new type declaration for vt by copying the type declaration for vp. Reload the grammar. This time it should load OK.

Editing rules

  • Try parsing that dog chased this cat. The grammar still does not allow it (now it does not allow that dog chased either). The grammar has no way to combine the transitive verb chased with its object this cat to make a verb phrase chased this cat.
  • Using a text editor, edit the file rules.tdl in your lkb-cfg-1 directory. Study the existing rules, and add a new grammar rule that makes a verb phrase (CATEG vp) by combining a transitive verb (CATEG vt) with a following noun phrase (CATEG np).
  • Reload the grammar and try parsing that dog chased this cat again. Now it should be parsed successfully.
© 2006-2010 Graham Wilcock

Hae laitoksen sivuilta:

Laitoksen etusivulle | Tiedekunnan etusivulle | Yliopiston etusivulle

Copyright © 2003-2005 Helsingin yliopisto. Kaikki oikeudet pidätetään.