next up previous contents index
Next: Parsing with a LexGram Up: Setting up a LexGram Previous: CUF control file(s)

LexGram control information

  The control information for the LexGram system is stated as Prolog facts and commands. It comprises the following types of information.

1.
Test file prefix (optional) Currently, LexGram uses files to interface between the parser and the generator. So, in case, the parse results should be fed into a generator, e.g. in a machine translation scenario, the TestFilePrefix, e.g. /tmp/mytests, has to be set by

 

:- assert( lgi_test_file_prefix('/tmp/mytests/test') ).
This will cause the LexGram parser to write the parse results on files whose names are concatenations of TestFilePrefix, TestId, _, and ReadingNumber, e.g. /tmp/mytests/test1_1 TestId is the first argument of a psent/2 definition, see section 3.1. The default value of ReadingNumber is 1. Make sure that the directory path indicated by the TestFilePrefix really exists. The LexGram system will not create these directories.

The reason why lgi_test_file_prefix/1 should be a dynamic predicate is that other users besides yourself should be able to change the prefix when running your grammar, since they may not be allowed to overwrite your old test files.

2.
Nonterminal abbreviations (optional)

For various pretty printing purposes (e.g. the chart browser, section 4.3.2), it will be convenient if there are abbreviations for the names of nonterminals. You can define abbreviated names for the subtypes of the nonterminal type by defining a Prolog predicate

abbreviated_name(Nonterminal, Abbreviation) .
For example:
abbreviated_name(nonterminal,nt).

3.
Grammar configuration

Since CUF currently does not support modular loading of CUF description files (i.e. the CUF description files of the LexGram vs. the grammar specific ones), there is a special load mimic for LexGram grammars, which requires the following statements.

(a)
lg_description_files(List-of-Description-File-Names).  e.g. lg_description_files([mygrammar]).

This declares the list of files  [mygrammar.cuf] as the CUF description files of your grammar.

(b)
lg_control_files(List-of-Control-File-Names).  (optional)

e.g. lg_control_files([mygrammar]).

This declares the list of files  [mygrammar.ctrl] as the CUF control files of your grammar.

(c)
:- add_dir('.'). resp. :- add_dir('MYGRAMMAR_PATH').

The location of the grammar must be declared explicitly since the CUF configuration file will be created automatically and will be loaded from /tmp. If you use the lg_module/4 predicate (see section 7.2) and load a module from your (top level) grammar directory, you may omit the add_dir/1 command.

4.
LexGram flags

The search space of the parser (or generator) can be constrained (for the price of incompleteness) by restricting the number of traces per phrase. The default is  4, which can be set to some other value, say  5, by the lgflag/1 -command:

:- lgflag(trace_bound,5).


next up previous contents index
Next: Parsing with a LexGram Up: Setting up a LexGram Previous: CUF control file(s)
Esther Koenig-Baumer
6/23/1998