Вы находитесь на странице: 1из 3

A Lexical Functional Grammar System in Prolog

Andreas Eisele and Jochen DOrre

Department of Linguistics
University of Stuttgart
West Germany

Abstract grammar implementors in two respects:


i) Using DCGs for parsing (and overcoming the prohibition of
This paper describes a system in PROLOG for the automatic left recursion)
transforination of a grammar, written in LFG formalism, into ii)Profiting from PROLOG's unification mechanism to
a DCG-based parser. It demonstrates the main principles of implement LFG-Unification.
the transformation, the representation of f-structures and
constraints, the treatment of long-distance dependencies,
and left rccursion. Uuification
Finally some problem areas of the system and possibilities
for overcoming them are discussed. LFG is a unification-based grammar formalism. To be more
precise, any defining equation in LFG can be interpreted as
the unification of certaiu f-structures. Unifying two f-
Introduction structures is an operation very similar to set union.
However, unification may fail, if the stuctures contain
In order to intprove our knowledge about natural language, it contradicting values for the same attribute. Otherwise the
is desirable to have a high-level description language which two structures become the same object, which contains the
can be used to test grammars on a computer system, but which information of hoth structures. Consider for example the LFG
is independent of the details of the implementation. For rule
linguists without knowledge of programming languages, a
system for writing and testing grammars on a computer should S -.~ NP VP
be offered. /t sueJ)=$ T==~
At the University of Stuttgart such a system has been imple-
mented in PROLOG, which uses tile formalism of Lexical- and take FS, FNP and FVP as the f-strnctures associated to
Functional Grammar [Kaplan/Bresuan 82] as its description tile S, NP and VP node, respectively. Then the two equations
language. cau be interpreted as the unifications
The system makes it possible for the user to enter grammar
rules and lexical entries directly in the form described in FS U- FVP and FS U [SUBJ = FNP].
[Kaplan/Bresnan 82]. The input is translated into PROLOG
rules, which form a top down parser in defiuite clause The unification of f-structures is also closely related to
grammar style. the unification of PROLOG-Terms, yet there are two important
Equations and constraints associated with a grammar rule are differences: lu f-structures values are identified by labels
evalnated as soon as the rule is used, thus allowing the (the attributes) and their number is potentially unlimited,
rejection of incorrect parses as soon as constraints are whereas in PROLOG-terms the arguments are identified by
violated. their position and their number is fixed. In the following
One of the main problems using DCG grammars - the we show how we can model f-structure unification in PROLOG.
prohibition of using left-recursive grammar rules is We represent partial f-structures as an 'open ended' list of
solved by a conversion to right-recursive rules that does pairs:
not violate the semantics of the functional description. [ A I = V I , A 2 = V2 . . . . . An = Vn I _ ]

where the Ai stand for (atomic) attributes and the Vi for


Main Goals of tile Implementation the values associated to these attributes. These values are
either atomic, terms denoting semantic forms, f-structures
When we started the implementation of our LFG-Sytem we had themselves or tile term 'set(S)' where S stands for an open-
mainly the following tasks in mind: ended llst of f-structures denoting a set.
The unification of two f-structures is evaluated in this
- Independence o f Implementation
representation by inserting into both structures the
The LFG system is meant to be a grammar-writer's tool which
features missing with respect to the other, and then PROLOG-
allows him to ignore completely the details of the
unifying the variables that stand for the rest of the lists.
implementation. Specifically we wanted tile system to be
The values of features which the structures have in common
useful for linguists without any prior knowledge of PROLOG.
have to be unified recursively.
- Complete Coverage o f the L F G - F o r m a l i s m A procedure which performs this action can easily be written
The system should cover all features of LFG as they are in PROLOG* :
stated by [Kaplan/Bresnan 8 2 ] . This means we had to
incorporate the principles of consisteucy, completeness and merge(X,X) :- !.
coherence, inequality, positive and negative existential merge([A=VllRl],F2) :- deI(A=V2,F2,R2),
constraints and long distance dependencies. merge(V1,V2),
merge(R 1,R2).
- F l e x i b l e Environment f o r G r a m m a r Development
To be a really useful tool, the system must allow for
deI(F,[FIX],X) :- !.
testing the grammar fragment and changing it incrementally.
In this point we had to find a good compromise between speed deI(F,[EIX],[EIY]) :- del(F,X,Y).
of parsing and speed of grammar modification.
When called with the f-structures FSI and FS2, the predicate
- Using as much o f P R O L O G as possible 'merge' recursively reduces the attributes in FSI. If an
We wanted to profit from the facilities PROLOG offers for *The ~re,~ment of sets is omitted here for the sake of simplicity.

551
attribute appears also in FS2, 'del' finds its value in FS2 Completeness of f - s t r u c t u r e s is tested by existential
and the two values are unified by the first recursive call constraints on the s u b - s t r u c t u r e s required by the semantic
of 'merge'. If an attribute is unspecified in FS2, 'del' form.
will insert it at the end of the structure as a new We t h i n k that the mere existence of a required s u b - s t r u c t u r e
attribute. Eventually, 'merge' will reach the tail variable is not enough. For example, verb entries often introduce a
of FS1 and instantiate it w i t h exactly the attributes which partial f-structure for the subject by specifying its
appear in FS2 but not in FSI, After successful execution of number. This should not lead to the acceptance of a sentence
'merge' FSI and FS2 contain the same attributes with the without a subject. For that reason we use existential
same values (maybe in d i f f e r e n t order) and tail variables at constraints on the ' p r e d ' of a structure to test if it is
any level are shared. So any further unification a f f e c t i n g there.
one of them will affect the other structure in exactly the
same way. Coherence of an f - s t r u c t u r e is e q u i v a l e n t to negative
existential constraints c o n c e r n i n g all governable functions
Example: The goal (i.e. functions that can appear in semantic forms) that are
merge( [subj = [spec = d e f , not required by its semantic form. Introduction of negative
nu~ = sg, existential constraints for all those attributes, as
pred = glrl described above, would be a correct but inefficient
] RSubj I] solution. Instead we use a special m a r k 'ngf', which closes
[ RI] , an f - s t r u c t u r e for governable functions, i.e. the d e f i n i t i o n
[pred = hand(subj,obj2,obj), of 'merge' is e x t e n d e d b y an additional test that prohibits
tense = present, the insertion of a governable function after the ' n g f ' - m a r k .
subj = [num = sg I RSubj2]
I R2]). Example: the lexical entry

yields the instantiations promised: V, (1' TENSE) PAST =

("i" PRED) = 'PROMISE(( 1' SUBJ) (C OBJ) ('~ VCOMP))'


R1 = [pred = h a n d ( s u b j , o b j 2 , o b j ) , tense = present [ R2] (T VCOMP To) : c +
(t VCOMP suaJ) = ('t SU~J)
RSubj2 = [spec = d e f , pred = g i r t I gSubjl]
is t r a n s f o r m e d to
The fact that the unification is performed by extending both
of the structures and that there is no explicit result is v ( V , Ex_Tests, [PSUBJ, POBJ, PVCOMP[Ex_Tests]) -->
essential when dealing with reentrant structures, i.e. (promised],
embedded structures that can be reached by more than one {merge(V,[tense = past,
path. In the case when such a structure is extended while it pred = promise(subj,obj,vcomp),
is reached by one of the possible paths, an access via a subj = [pred = PSUBJ [ RSUBJ]
d i f f e r e n t path will also reach this extension. ebj = [pred = POBJ [ ] ,
vcemp = [to = 'C*(+,),
pred = PVCOMP,
Treatment of Completeness, Coherence and Constraints subj = [pred = PSUBJ RSUBJ]
I _ ],
In addition to d e f i n i n g equations, which can be m a p p e d onto ngf
the monotonic operation of unification, L F G includes formal I _ l)).
devices, some of w h i c h cannot be treated monotonically, but
need the notion of a 'final' f - s t r u c t u r e [Shieber 85]. More Treatment of Long-Distance Dependencies
concretely, the violation of positive existential
constraints, constraining equations and completeness cannot In order to handle l o n g - d i s t a n c e dependencies correctly, L F G
be checked before the parsing process has finished. provides b o u n d e d d o m i n a t i o n metavariables. The conditions
for proper instantiation given by [ K a p l a n / B r e s n a n 82] have
Existential constraints are treated by inserting the
to be satisfied. They concern:
attribute into the f - s t r u c t u r e , but leaving the associated
- The relation between d o m a i n roots and controllers
value uninstantiated (if it isn't already known). The - The o n e - t o - o n e a s s i g n m e n t between d o m a i n root and
condition that tiffs variable must be instantiated is
eontrollee
stored in a list (Ex Tests) especially for this purpose and - The observance of the crossing limit.
tested after the parse.
Negative existential constraints are treated by assigning Also, b o u n d i n g nodes, i.e. nodes that are excluded from the
the value 'nil' to the attribute. The value 'nil' is control domains of h i g h e r nodes, have to be handled
interpreted as n o n - e x i s t e n c e of the feature and must not correctly.
appear in the g r a m m a r itself.
- Constraining equations can be handled as follows*: S ~ I " s(FS,[np/FNPIC IN],ZnplC OUT],
We introduce a special term 'C'(Value,Mark), where Value is II I " //~t~ ExTestlN,Ex_Test_CUT
- - )
the value d e m a n d e d by the constraining equation and M a r k is \/
NP /// /\\\
uninstantiated. The definition of the unification is
changed, such that a simple value X is treated as a short
form of the term 'C'(X,t). Therefore, any unsatisfied / \
/ x
constraining equation results in an uninstantiated m a r k in / 2 \
the f - s t r u c t u r e and can easily be detected after parsing.
/ x
! \
*this treatraent of constraining equations is due to an idea of Jo Calder / I\ \
(personal communication). It
In our current implementation a more general method is used which also allows NP

both sides of the equation to denote substructures, but which is omitted here Treatment of bounded domination metavariables in two steps
since these cases never occur in realistic grammars.

552
The binding of the bounded domination metavariables consists For a detailed discussion of how this can be achieved for
of two steps. The first step, the identification of the locally left-recursive rules, please refer to [Eisele 85].
domain roots, only depends on the grammar and can be done
during the transforgaation of the grammar rules into PROLOG
clauses. Experience with the System
The main job, the assignment between domain root and
controllee, is performed as follows: We have implemented two versions of the LFG system, both
running on a VAX 11/780. The first version was written by
Each goal has two extra parameters for input and output of a the autlmrs in PROLOG II, using ideas of W.Frey and U.Reyle.
controller list. These lists, which are threaded through all It made use of the built-in predicates 'freeze' and 'dif',
nodes, except the bounding nodes, act as a global stack on which give the possibility of delaying subgoals to optimize
which the controllers are pushed. Each element of the stack the evahmtion of constraints [Eisele 85].
refers to a node which dominates the current goal, and which To improve the flexibility of the user interface, the system
is a domain root. was reimplemented in C-PROLOG by Stefan Schimpf and Andreas
A domain root adds an element to the stack before the parser Eisele. It has been used for the development and testing of
enters its control domain and removes a receipt after the different grammars for fragments of English, German [Netter
domain is left. The element that is pushed consists of the 86] and French, the latter consisting of about 50 grammar
class name (eg. [+wh]) of the controller and its actual rules and more than 200 lexical entries, and turned out to
variable. be a useful tool for this purpose.
If a eontrollee appears, the stack is searched for the first The performance of the system is quite good for simple
element with the same class name (for crossing limit n the grammars with a small amount of nondetermiuism. Using the
first n+l matching elements can be chosen) and replaces it grammar given in [Kaplan/Bresnan 82], parsing the sentence
by a receipt. Now the controUee can use the actual variable
of the controller. "I wondered which violin the sonata is tough for her to play on"
This treatment resembles the hold list device in the ATN
formalism [Winograd 83] a lot, but differs in two important needs about 2.3 seconds cpu time (C-PROLOG interpreter).
aspects. Yet, we don't expect that our system constructs an efficient
By using unification to establish the correspondence parser from an arbitrary grammar mainly for two reasons:
between controller and controllee, information may flow in The complexity of the LFG recognition problem is known to
both directions. be NP-complete [Berwick 82].
A controllee does not cause a pop-operation on the stack, - Our approach to handle nondeterminism by mere backtracking
but a substitution of an element by a receipt. The checking leads to unneccessary duplications of parsing actions.
of the receipt by the domain root ensures that a controllee Whereas the first point is highly questionable as to whether
can only occur within the domain of its domain root. it concerns practical grammars, there are several
possibilities to improve the behaviour of the parser.
As an example, the transformations of LFG rules with Storing intermediate results in a chart could help to
controller and controllee are given: avoid multiple parsing of' the same constituents and would
facilitate error analysis.
N P --, e Explicit representation of ambiguities in f-structures
(instead of a chronological enumeration) would be a step
towards a packaging of local ambiguity.
But in either case, the built-in structure-sharing mechanism
np(Fnp, CLOr CL1, Ex Tests, Ex tests) -->
of PROLOG could not be used as straightforward a way as in
13, our current system and tim definition of unification would
(subst(np/Fnp, rip, CLO, CLI)).
have to be considerably more complex.

S' ~ NP []
References
(t ,:ocus):-$
Aho, A.V. and Ullman, J.D,, "Principles of Compiler Design",
Addison-Wesley, Reading, Mass., 1977.
s bar(Fs_bar, CLO, CL1, Ex_TestsO, ExTests2) -->
np(Fnps [~h/QICLO], [~hICL1], Ex_festsO, Ex_Testsl)~ Berwick, R.C., "Computational Complexity and Lexical-
{merge([q=O, focus=Fnp [3, Fsbar)}, Functional Grammar", ACL Journal, Vol.8, 1982.
s(Fsbar, [np/Fnp], [np], Ex_Testsl, ExTests2).
Eisele, A., "A Lexical Functional Grammar System ill Prolog",
LDV-Forum 2/85.
Treatment of Left Recursion
Kaplan, R.M. and Bresnan, J., "Lexical-Functioual Grammar: A
Definite Clause Grammars do not allow left-recursive grammar Formal System for Grammatical Representation" in "Mental
rules when interpreted by a top-down parser. This is a Representation of Grammatical Relations", Bresnan eds., MIT
serious shortcoming for a natural language system, since Press, 1982
many linguistic phenomena can be most naturally described
with left-recursive rules (coordination, possessive NPs Netter, K., "Getting Things Out Of Order", this volume.
etc.). Sbieber, S.M., "An Introduction to Unification-Based
In the theory of formal languages, there exist several
Approaches to Grammar", Tutorial Session at the 23rd Annual
algorithms to convert a grammar containing left recursion
Meeting of the ACL, Chicago, 1985.
into a weakly equivalent grammar that does not [Aho/Ullman
77]. But in LFG, the c-structures are essential for the
Winograd, T., "Language as a Cognitive Process", Vol. l
correct evaluation of f-structures, so a transformation must
provide a way to get the right interpretation of the Syntax, Addison.-Wesley, Reading, Mass., 1983.
functional description.

553

Вам также может понравиться