Sentence Parser Sends Tree to Disk
Chapter 2, Section 2

http://www.nyu.edu/pages/linguistics/workbook/2.2

From: Beginners Workbook in Computational Linguistics

Prof. Ray C. Dougherty
New York University | Linguistics Department
GENERAL || RESEARCH || COURSES || WORKBOOK || FIRST DOT

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.


1. Sending Parse Trees to the Screen or Disk.

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.


2. Computer requirements to run this parser.

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.


3. Graphic: How to Print Trees to Disk.




4. Opening the wbfile# in Desktop Editor




5. Opening the file wbfile# in WordPerfect


6. Inserting the file wbfile# into WWW Documents

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



7. Overview of the Parser to Disk to Editor Process.

The basic process involves three applications in Windows:

  1. You parse a sentence in the Prolog Window using tree_prn(LIST).
  2. Tree_prn(LIST) writes a file wbfile# to the c:\pl directory.
  3. You can open the wbfile# in any text editor, here it is Desktop Editor.


8. Assignment

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:

  1. describe what you did
  2. list the lexicical items
  3. include the parse trees in your essay
  4. eliminate the identification headings added to the ascii files by the program

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


Width bar

Some of the figures are scaled to fill a 1200 x 650 screen.

If you enlarge the browser window, you will be able to read even the small print.

These figures are used in courses at NYU with a computer connected to the WWW and an overhead projector using an overhead/computer attachment. One need not carry overheads, they are on the WWW for use anytime, anywhere.