next up previous contents
Next: TRALE-EXTENSION:Grammars Up: Topological Parsing Previous: TRALE-EXTENSION:Introduction   Contents

Subsections

TRALE-EXTENSION:Running TGC

TGC runs on any computer that has SICStus Prolog version 3.8.7 or higher installed. The compiler also requires the file header.pl. The parsed code needs the file tree.pl for pretty-printing. These files are included in the TGC package, which also contains two sample grammar files--german.pl (for German) and sc.pl (for Croatian/Serbian)--as well as two files containing some test sentences for those grammars.

TRALE-EXTENSION:Compiling Grammars

To run TGC, make sure that the working directory of SICStus Prolog is set to where TGC files reside and then type

| ?- compile(tgc).

at the prompt. The command topo_compile/2 is used to create a file that contains parser code based on an existing grammar file. For example, assuming that the grammar file german.pl exists in the working directory, you may generate the corresponding compiled code for that and keep it in a file called german_c.pl by typing the following command:

| ?- topo_compile('german.pl','german_c.pl').

Note that if you wish to use file extensions, you need to put the file name inside single quotes. This version of the compiler does not add .pl to the end of file names.

During compilation several messages are shown on the screen to inform the user of the states that the program enters or completes. During a normal compilation you should see messages similar to the following:

| ?- topo_compile('german.pl','german_c.pl').
Analyzing german.pl...
Compiling german.pl. Output to be written in german_c.pl...
Compilation complete.

yes
| ?-

In cases of errors or potential problems, warnings and/or error messages may appear at each state. These will be discussed in the following sections in detail.

TRALE-EXTENSION:Using the Parser

You can load the generated parser code into the machine using Prolog's compile/1 command. Parsing is done with the command rec/1, which takes a list of input words in lowercase letters. For example, to parse the sentence `Der mann lauft', type:

| ?- rec([der,mann,lauft]).

The output is a tree diagram for every parse that encompasses the whole input string. For the case of the example above, the output looks like this:

| ?- rec([der,mann,lauft]).


s
|_np
| |_det
| | |_der
| |_nbar
|   |_n
|     |_mann
|_vp
  |_vbar
    |_iv
      |_lauft



yes
| ?-

Should the input string yield no such parse, the compiler returns the message: No full parse and fails. Similarly, in case the parser encounters an unrecognised word, it also notifies the user by an error message and fails. Some examples are presented below:

| ?- rec([der,mann,will,jochen,sehe]).

No full parse.

no
| ?- rec([der,mann,will,jochen,sehrn]).
Can't recognise the word sehrn.

no
| ?-

Another command, time/2 is used to measure the time that it takes to fully process an input string. The number returned shows the processing time in milliseconds. Because this command only measures processing time and does not check for full parses and also because it does not draw any parse trees, you should first make sure that the input string parses using rec/1. An example of time/2 in use is given below:

| ?- time([der,mann,sieht,jochen],T).

T = 10 ? 

yes
| ?-


next up previous contents
Next: TRALE-EXTENSION:Grammars Up: Topological Parsing Previous: TRALE-EXTENSION:Introduction   Contents
TRALE User's Manual