10.5.7 Running the Program

We've already seen a first run of our semantically annotated DCG, and we've now implemented a module for -conversion. So let's plug them together in a driver predicate go/0 to get our first real semantic construction system.

We've already seen a first run of our semantically annotated DCG, and we've now implemented a module for -conversion. So let's plug them together in a driver predicate go/0 to get our first real semantic construction system:

go :-
        readLine(Sentence),
        resetVars,
        s(Formula,Sentence,[]),
        nl, print(Formula),
        betaConvert(Formula,Converted),
        nl, print(Converted).

This predicate first converts the keyboard input into a list of Prolog atoms. Next, it does some cleaning up that is needed to manage the creation of variable names during lexicon retrieval (see Section 10.5.3). Then it uses the semantically annotated DCG from semanticDCG.pl and tries to parse a sentence.

Next, it prints the unreduced -expression produced by the DCG. Finally, the -expression is -converted by our predicate betaConvert/2 and the resulting formula is printed out, too.

Note: In order to get a nice printout of semantic representations, the definitions for the operators used in them have to be consulted on top-level. So in order to run the program, do the following at a Prolog prompt:

1 ?- [semconOperators],[runningLambda].
% semconOperators compiled 0.00 sec, 400 bytes
%   semconOperators compiled into semconHelpers 0.00 sec, 216 bytes
%  semconHelpers compiled into semconHelpers 0.00 sec, 7,232 bytes
%   semconOperators compiled into betaConversion 0.00 sec, 216 bytes
%  betaConversion compiled into betaConversion 0.00 sec, 1,628 bytes
%   semconOperators compiled into runningLambda 0.00 sec, 216 bytes
%  semanticDCG compiled into runningLambda 0.00 sec, 4,092 bytes
%  semconOperators compiled into runningLambda 0.00 sec, 0 bytes
% runningLambda compiled into runningLambda 0.01 sec, 14,184 bytes
 
Yes
2 ?- go.
 
>

Code For This Chapter

Here's a listing of the files needed:

semanticDCG.pl: View Download

The semantically annotated DCG.

runningLambda.pl: View Download

The driver predicate.

betaConversion.pl: View Download

-conversion.

semconOperators.pl: View Download

Definitions of operators used in semantic representations

semconHelpers.pl: View Download

Auxiliary predicates.

simplifiedEng.pl: View Download

Simplified version of ourEng.pl from Chapter 8. Used in the exercises.


Kristina Striegnitz, Patrick Blackburn, Katrin Erk, Stephan Walter, Aljoscha Burchardt and Dimitra Tsovaltzi
Version 1.2.5 (20030212)