4.4.1 Lexical Rules

Example-based explantaion of the lexical rules.

The combinatorial part of our grammar is connected to the lexicon via the so-called lexical rules. These are the grammar rules that apply to terminal symbols, the actual strings in the input of the parser. They need to call on to the lexicon to check if a string belongs to the syntactic category searched for, and retrieve its semantic representation.

noun(N)--> {lexicon(noun,Sym,Word,_),nounSem(Sym,N)}, Word.

The code that goes with each lexical DCG rule consists of two calls: One to a lexicon/4 predicate, and one to a binary so-called semantic macro (nounSem/2 in the example). The lexicon/4-call does the actual lexical lookup: If it finds Phrase (a list of atoms coming from the input sentence. Most of the time this list will of course contain only one item.) in the category given as first argument, it returns a core semantic representation in Sym. As we shall see below, such a core representation is nothing else than a predicate or constant symbol (hence the variable name Sym). This symbol is then further processed by the semantic macro. In our example, the semantic macro nounSem/2 is used to construct the actual semantic representation for a noun.

Each lexical category is associated with one semantic macro. Using such macros, we can set up the lexicon as well as the lexical rules totally independent from the semantic theory. Note that we're now simply re-doing on the lexical level what we did when we introduced the combine/2-calls to our combinatorial rules: We're factoring out the specific types of structure required by changing semantic formalisms into a (set of) interface predicates. This way, we encapsulate this structure and separate it from all other, more or less static information. And again, to change the semantic formalism we will simply re-implement our interface predicates (i.e. the semantic macros) - that's it.

englishGrammar.pl: View Download

The lexical DCG rules can be found at the bottom of englishGrammar.pl.


Aljoscha Burchardt, Stephan Walter, Alexander Koller, Michael Kohlhase, Patrick Blackburn and Johan Bos
Version 1.2.5 (20030212)