![]() Sentence Parser Sends Tree to Disk |
|---|
TREE DRAWING PRETTY PRINTERS:
COMPARISON ||
NYU VANILLA ||
LEHNER ||
KOSTKO ||
VINCENT

If you have any comments about these workbook
pages, please let us know. Should we place more of these pages on line? Do you
benefit from these pages? If you are a student at NYU, you may help in
developing these pages, see the
HTML Geselschaft.
Your ideas and comments will lead to modifications and improvements.
One of the Prolog programs in the program file work002.txt (work002.zip) is a parser, tree_1(LIST), that will convert the following (a) strings to phrase markers using Lehner's tree drawing program and present the display on the computer screen. This produces an ASCII tree diagram . (If tree_1(X) does not work on your machine, try tree_2(X)).
tree_prn(LIST) converts the (a) strings to phrase markers and writes them to a disk. The screen does not display the tree, but a message appears indicating if the parser was successful, and if successful, what the name of the file is. tree_prn(X) automatically picks the file names. wbfile1 is the first file, wbfile2 is the second, and so on. As long as you remain in Prolog, the numbers will increase. If you quit Prolog and reload the program, work002.pl, then the filenames will restart with the name wbfile1, wbfile2, on up. If you quit Prolog, save your work.
A labeled bracketing of constituents can be difficult to read. A common notation in linguistics is a phrase marker that spreads constituent structure information into two dimensions. These parsing programs produce phrase markers.
The following diagrams shows the screen contents (scriptfile, or screen capture) of what happens when you are using tree_1(X) in SWI-PROLOG on an IBM PC under Windows to parse simple strings to obtain phrase markers. The program also runs in Quintus Prolog.
The English grammar upon which this parser is based is discussed in Workbook 2.1. If you want to parse your own sentences, you may modify the lexicon.
Otherwise:
The program has a tiny lexicon and a simple set of combinatory principles. It is intended as a pedigogical tool for introductory classes intending to show how to encode Chomsky's ideas about generative grammar (particularly the merge operation) into Prolog.





FILENAME: wbfile1
tree_prn([the,woman,sees,under,the,table])
Beginners Workbook in Computational Linguistics
PROGRAM FILE: work002
Prolog Function Name: tree_prn(LIST)
LIST = [the,woman,sees,under,the,table]
s
______|______
/ \
np vp
__|_ ____|___
/ \ / \
det n v pp
| | | ___|___
| | | / \
the woman sees p np
| __|_
| / \
under det n
| |
| |
the table

The basic process involves three applications in Windows:

Using the skills you acquired in the exercises in Workbook 2.1, modify the lexicon of the parser to generate parse trees for these sentences:
Parse these sentences and write the trees to disk.
Using a text editor, write a short essay:
E-mail me the essay with the comment field: Your name, WB Assignment 2.2.
Compose your short essay plus graphics as an HTML Web Page and place it on-line. E-mail me a letter containing the URL with the comment field: Your name, WB Assignment 2.2
