PSG Web Laboratory

Torbjörn Lager 2002 

PSG Web Laboratory is designed as an aid for students to explore context-free phrase structure grammars for natural language. It helps the student to understand the relationship between grammars, strings and trees, and the notions of syntactic ambiguity and recursion. For an immediate demonstration of what the program does, click the Analyse button in the frame to the left. Then try the Generate button. Then go ahead and edit the grammar and/or the input string to your heart's delight!

IMPORTANT: You may need to install the Adobe SVG Viewer 3.0. PSG Web Laboratory works well in Internet Explorer. Probably also in other browsers, as long as they support SVG.

Elementa i generativ grammatik - the cover PSG Web Laboratory is 100% compatible with the formalism used in the textbook "Elementa i generativ grammatik" written by Björn Beskow, Torbjörn Lager and Joakim Nivre, and published by Studentlitteratur AB in Lund, Sweden. This book is only available in Swedish, but the formalism is simple enough to be compatible with most of what is out there. Please consult the bibliography for a short list of other relevant books.

Phrase Structure Grammars

Natural language phrases (and formulas in most formal languages) have both a linear order and a hierarchical structure. These properties can be described by means of context-free phrase structure rules. Such rules have the form:

C -> C1 C2 ... Cn 

and are to be read as follows: A phrase of the category C can consist of words or phrases of the subordinate categories C1, C2, ... and Cn, appearing in that order.

A phrase structure grammar consists of a set of rules and a set of lexical entries. The rules describe the possible modes of combination of the words. Suppose we let S stand for sentence, NP for noun phrase, VP for verb phrase, N for noun, V for verb, A for adjective, and DET for determiner. We can then write a set of simple rules as follows:

S -> NP VP
NP -> DET N 
VP -> V NP

and a lexicon as follows:

DET: a 
N: student 
N: grammar 
A: large 
V: writes

The rules together with the lexicon form a grammar which can parse for example the following sentences:

a student writes a grammar
a grammar writes a student

By means of parentheses we can mark a certain category as optional. The rule for NP above could be changed into the following:

NP -> DET (A) N 

This grammar can parse all of the above sentences plus a number of others, for example:

a student writes a large grammar

We can also mark a number of categories as alternatives. This is useful, for example, when a sentence can be modified either by an adverb (ADV) or a prepositional phrase (PP):

S -> NP VP {ADV, PP}

It also gives us the option of using a more compact notation for the lexicon:

N: {student, grammar}

Nesting of option and alternative is possible, as in:

S -> NP VP ({ADV, PP})
NP -> DET ((ADV) A) N 

This has been a very brief introduction to phrase structure grammar. For a more thorough presentation the reader is referred to the existing literature on the subject, for example to the books listed in the bibliography.

Technical Information

PSG Web Laboratory has been implemented in a combination of the Oz programming language, JavaScript, HTML, CSS, and Scalable Vector Graphics (SVG). Unfortunately, the reliance on SVG means that it currently only works in Internet Explorer using the Adobe ASV plugin. However, SVG is a W3C standard which many browsers can be expected to support in the near future.

Acknowledgements

The original PSG Laboratory was written for the Apple Macintosh by Björn Beskow, Joakim Nivre and myself back in 1995. It is still available from http://www.ling.gu.se/~li

Bibliography

Many textbooks on linguistics contain a chapter on the basics of phrase structure grammar. Here is a short list:

  1. Bach, E. (1974) Syntactic Theory. New York: Holt, Rinehart and Winston.
  2. Beskow, B., Lager, T. & Nivre, J. (1996) Elementa i generativ grammatik. Lund: Studentlitteratur. (In Swedish)
  3. Borsley, R. D. (1991) Syntactic Theory. London: Edward Arnold.
  4. Thomas, L. (1993) Beginning Syntax. Oxford: Blackwell.