• No results found

Head Driven Bidirectional Parsing: A Tabular Method

N/A
N/A
Protected

Academic year: 2020

Share "Head Driven Bidirectional Parsing: A Tabular Method"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

H e a d - D r iv e n Bid ir ect iona l Parsing: A T a b u la r Me th od

Giorgio Satta (0)(°°), Oliviero Stock (°°)

(°) University di Padova, via Belzoni 7, 35131 Padova, Italy (°°) Istituto per la Ricerca Scientifica e Tecnologica, 38050 Povo, Trento, Italy

1.

Introduction

Tabular m ethods for context-free language analysis [Graham and Harrison, 1976, Graham et al., 1980], and in particular Earley's A lgorithm [Earley, 1970], can be considered a major reference for natural language parsing. Even if independently co n ceiv ed , Earley's A lgorithm constitutes the basis for Chart parsing [Kay, 1980, Kaplan, 1973].

One basic aspect o f known tabular m ethods, i.e. that the analysis p roceedes m onodirectionally, is a relevant lim itation, that, although reasonable for artificial languages, seem s reductive for natural language. A strong reason for a bidirectional approach within natural language analysis is that m odem theories o f grammar em phasize the role o f a particular elem ent inside each constituent (phrase), called the head; this elem ent carries categorial as w ell as thematic information about other elements within the constituent. It turns out that the acceptability and the general skeleton o f each constituent, crucially depend on such information. More concretely, a number o f possible partial interpretations would be pruned out earlier, on the basis o f functional information attached to the head, resulting in greater efficiency.

Som e recent works in the framework o f Chart parsing [Steel and D e R oeck, 1987, Stock et al., 1989] have pointed out the importance o f bidirectionality for natural language analysis. Another work that deals with som e form o f bidirectionality [B ossi et a l ., 1983] can be found in the form al language literature, though the an alysis given there presupposes Chom sky normal form grammars.

In this paper w e shall introduce a tabular method coinceived for bidirectional context- free parsing, discuss som e o f its relevant properties and through an exam ple give an idea o f how the algorithm works.

2. D e f i n i t i o n s

A ssum e a context-free grammar G =(N , E, P, S), where N is the finite set o f all non­ terminal sym bols, Z is the set o f terminal sym bols, P is a finite set o f productions, and S e N is the start sym bol. L(G) represents the language generated by the grammar G. The productions in P are numbered from 1 to IPI1, and are all o f form D p- » C p j ... Cp ^ ) ,

1

The notation IPI here indicates the cardinality o f set P.

(2)

.where k is a function defined over the set { 1 ... IP!} and that takes values in the set Z* (the set o f positive integers). In the follow ing, the natural number p often w ill be used instead o f the production associated with it. Without loss o f generality, here it is assumed that the grammar G is in e - f r e e form (see [A ho and U llm an, 1972:147]); a more general formulation o f the algorithm does not lead to the loss o f the properties shown here.

A function x is defined over the set { 1...IPI} and it takes values in Z+. This function indicates, for every production p in P, a position in the right-hand side o f the production, occu p ied by a sym bol in N u l . This position is called the h ea d p o s itio n , and the corresponding sym bol is said to be in the head position for production p. Every time, during the analysis, a sym bol is recognized that is in head position for some production p , the presence o f the symbol D p relative to production p is then locally hypothesized

DEFINITION 2.1

A s t a t e is d efin ed to be any quadruple [p, I d o t , r d o t , m ] , w ith l< p ^ lP I , 0< ld o t< rd ot< K (p ), m e { Im, rm ).

The component p indicates the corresponding production in P; the components Idot and r d o t represent tw o distinct positions, one after the other, in the right-hand side o f

production p . The com ponent m is a simple indicator m - l m indicates that the value o f Idot cannot be further diminished, even if greater than zero, while m - r m indicates that the

value o f r d o t cannot be increased further, even if it is less than 7z(p). N ote that, by definition, one lim itation excludes the other. The value is used for the indicator m in the absence o f both the lim itations just described. The use o f the index m, as it w ill be show n, prevents the duplication o f “partial analyses” for substrings o f w. Every state j= [p , Idot, r d o t, m] may be understood to be a partial analysis relative to production p , for w hich the constituents Cpjdot+1 ... Cp/dot* belonging to the right-hand side, have been recognized. In the follow ing, for convenience, the states w ill often be referred to in these terms. The sym bol Is denotes the set o f all states.

DEFINITION 2.2

The function F is defined as follows: F: N u l - ^ )

F (X )= {5= [p , Idot, ld o t + 1, -] I X=Cp ldol+1, x (p )= ld o t+ 1}.

The set F(X) therefore contains all the states indicating partial analyses o f productions in which the sym bol X occupies the head position.

DEFINITION 2.3

An equivalence relation Q,in Isx l s is defined so that for two generic states s=[p, Idot, r d o t , m] and j ' = [ p \ Idot', r d o t ', m rj, sQ§' holds if and only if p - p \ I d o t - l d o t ' and

r d o t= r d o t \

(3)

3. T h e A l g o r i t h m

A r e c o g n iz e r is an algorithm capable o f accepting a generic string w e L(G) for a particular grammar o f interest G. In all other cases, the string w is refused. A p a r s e r , instead, is an algorithm that can solve the problem o f whether or not w belongs to L(G) and is also able to indicate the possible derivation trees2 for every w e L(G). In this section, a recognizer algorithm for context-free languages is presented. The use o f a sim ple algorithm able to reconstruct the derivation trees by interpreting the recognition matrix T (see for exam ple [Graham et Harrison 1983]) is sufficient to obtain a parser algorithm.

The algorithm uses a matrix T o f size (rt+ l)x(n + l); each com ponent fy o f this matrix takes values in the set Is), and is initialized with as empty set. The presentation o f the recognition algorithm is preceded by a schematic illustration o f the computation involved.

The algorithm inserts into the recognition matrix T each state s that indicates a partial analysis p reviously obtained for the generic substring jWj. There is a one to one correspondence between the indicies o f the analyzed substring jWj and the indices o f the com ponent ry, in which state s has been inserted. The algorithm then processes each state, com bining it with nearby states in an effort to extend the portions o f the string dominated by these states. When the analysis relative to a particular state is com pleted (for both the right and left sides), if the constituent obtained is in a head position for som e production p in P, a new partial analysis for the production p itself is inserted into matrix T. Note that the algorithm straightforwardly separates the problem o f the com bination o f different states from the problem o f control. The algorithm in fact does not specify the order in which the different states must be considered, nor in which order every single state must be expanded in the tw o opposing sides. To that end, the algorithm uses a variable A which takes values in the set ^(IsxN xN ).

ALGORITHM 3.1

G iven a context-free grammar G =(N , E, P, S) in e-free form, let w = a \ ... a n, n>0 , be an input string. D evelop a recognition matrix T, o f size (n + l)x (r t+ l), w hose com ponents fy are coindexed from 0 to n for both sides.

b e g i n

1. f o r i in {1 .. n) d o 2. f or s in F(a.) d o

3. add triple e = ( s , M , /) to set A only if s Q s q d o e s n o t h o l d f or a n y t r ip l e e q = ( s q ,

i - l , i)

4. w h i l e A not em pty d o

2 A derivation tree D associated with a string L(G), is a labeled tree formed by all the productions used in the derivation ofw, representing the correct hierarchic order.

(4)

5. extract any elem ent e= (s, i , j ) from the set A and insert state s in fg ; apply each o f the follo w in g procedures, in any order, to element e :

left-expander(e),

right-expander(e),

left-completer(e),

right-completer(e),

trigger(e);

6

. if s=[p, 0, n(p), m]<= tQ n, for som e p e P such that D p=S

7. then output(true)

8

. else output(error)

e n d .

The five procedures mentioned above are described in the following.

PROCEDURE 3.1 Left-expander

P recondition The procedure is applied only when e - { s , iyJ) with s=[p, Idot, rd o t, m],

ldot>

0

, m *lm .

Description The follow ing two cases are possible.

C a s e 1: Cpj dole N . For every s ' = [ p \ 0, Kip'), /'</, such that D p'=Cpldot, the state s ”=[p, Id ot-1, r d o t, -] is created and the triple e '= (s ”, i \ j ) is in sen ed in set A, only if j"Q^q does not hold for any state in or for any triple £q=(5q, i \ j ) in A. If at least one state s ’ is found with the above properties, set m - r m in s.

C a s e 2: C p ^ e l . If Cp ^cjot=ai, the state s'=[p, l d o t - \ y r d o t, -] is created and the

triple e '= (s \ i - 1, j ) is in sen ed into set A, only if j'C&q does not hold for any state s in t{ j or for any triple ^q=(

5

q, i - l , j ) in A. If C ^ ^ Q= a{, set m=rm in

5.

This procedure is applied only if state s can be extended leftward (ldot>0) and only if it has not already been extended rightward that is, if it is not subsum ed to the right by a more updated state. There are tw o cases, depending upon whether the left-hand expansion sym bol is a terminal sym bol or not. If Cp ldol is a non-terminal sym bol, the

search proceeds to the left o f state j, to any state s' (adjacent), that corresponds to a com pleted analysis r d o t’= n ( p r)) o f a constituent usable by state s (Dp.=Cpjdot)* If su ccessfu l, the analysis is extended in correspondence with state s, including the constituent found nearby; state s then is marked with m - r m, sin ce this has been subsum ed on the left by a more updated state. If Cp Jdol is, instead, a terminal sym bol, and if C an extension o f the analyses corresponding to state s is made, including the terminal sym bol a ^ Still, state s is marked with m - r m for the same reasons as in

Case 1. Furthermore, note that Procedure 3.1 never duplicates the triples in A, nor the states belonging to the same com ponent o f recognition matrix T.

(5)

PROCEDURE 3.2 Right-expander

Precondition The procedure is applied only when e - { s , i , j ) with s - [ p , Idot, rdot, m\,

rdot<n(p), m*rm.

Description There are the following two cases.

C a s e 1: C p rdo[+

1

e N . For every 5'=[/?', 0, K (p '), m']<= t. j ’> j , such that D ,=C j ,, state s"=[p, Idot, r d o t + l , -] is created and triple e '= (s '\ i j ' ) is inserted

p p,raot+i ^

into set A, only if j"C£q does not hold for any state sq in t^, or for any triple eq=Csq, i j l in A. If at least one state s' has been found with the properties described above, set m -lm in s.

Case 2: Cp rdot+1e I . If Cp rdot+1=aj+1, the state s'= [p, Idot, r d o t+ l, -] is created and the triple e ' = ( s \ i j + l ) is inserted in A, only if .s'Q?q does not hold for any state s q in

riJ + r 15 c P,idot= a j + r set m = lm in s

-This procedure is symmetric to the left-expander procedure, so the explanation is omitted.

PROCEDURE 3.3 Left-completer

Precondition The procedure is applied only when e - { s , / ,/) , with J=[p, 0 ,

7

i(p), m].

D e s c r ip tio n For every s'=[p', Idot', rdot', tj. /'</, rd o t'c iip " ), m'^rm. such that Dp=Cp. rdot’+ r state I d o l’, r d o t ’+

1

, -] is created and the triple e '- { s " , i \ j ) is inserted in set A only if s"Q$q does not hold for any state in r-,j or for any triple e = (jq, i \ j ) in A. Furthermore, set m '- lm for every s' found.

This procedure is applied w henever the analysis o f a constituent D p has been com pleted through a state s=[p, 0, Kip), m]. It proceeds by searching leftward o f state j for any adjacent state s' that has not yet been subsumed to the left (m'*rm) and is able to “ex p an d ” state

5 CDp= C p. rdot.+1). If su ccessfu l, an ex ten sio n o f the analysis

corresponding to s' is carried out, including the constituent D p. State s' is then marked with m - lm , since it has now been subsumed on the right by a more updated state. Again, note that the procedure never duplicates triples in A, nor states belonging to the same component o f the recognition matrix T.

PROCEDURE 3.4 Right-completer

Precondition The procedure is applied only when e - ( s , i , j ), with s - [ p , 0, n (p), m].

D e s c r ip tio n For every s ' - [ p \ Idot', r d o t ', m ^ e f y . , / > / , ldot'> 0, m W m , such that D =C , , . , state s"=[p, ld o t' - \ , r d o t \ -] is created and the triple e '= (s", i j 9) is inserted

p p ,laot ^ '

in set A only if .y"C&q does not hold true for any state s q in or for any triple eq=(>yq, y") in A. Furthermore, set m - r m for every s' found.

This procedure is sym metric to the le ft-com p leter procedure, so the explanation is omitted.

(6)

PROCEDURE 3.5 Trigger

Precondition The procedure is applied only when e - ( s , i,j) , with j=[p, 0, K(p), m\.

D escription For every s e F(D p), insert the triple e=(s, i, j) in set A only if sQ?q does

not hold for any state s q in t[j or for any triple eq=(sq, i, j ) in A.

The procedure is applied whenever the analysis o f a particular constituent has been com pleted and this constituent occupies the head position in some production p. In this case a new state corresponding to a partial analysis for production p is created, including the head. Once again, note that the procedure never duplicates triples in A, nor states belonging to the same component of the recognition matrix T.

4. Some Formal Properties of the Algorithm

In this section the most interesting properties o f Algorithm 3.1 are stated. For a formal proof o f what follow s refer to [Satta and Stock, 1989b]. Four major properties have been grouped under Invariant 4.1 below. Note that soundness and com pleteness for Algorithm 3.1 follow straightforwardly from statements (i) and (ii) in Invariant 4.1.

INVARIANT 4.1

*

( i ) s = [ p , I d o t , r d o t , m ] e ti j o n l y i / C p ldot+1 ... Cp rdot => a i+1 ... a j , i < j ,

ldot+ 1 <x{p)<rdor,

(H) C p^dot+i-.Cp^ot => i<j, Idot +1 < x (p )< rd ot only if a quadruple h = [h \,

hi, /

13, h4\, hq>0, 1^7<4 exists such that s = [ p , ld o t- h \, rdot-^h^, m ]e ti_h3j+h^

(Hi) s= [p , Idot, rdot, lm \e only ifs'= [p , Idot, r d o t + \ , tx \'yf > j \

(iv) s = [ p , Idot, r d o t, r m ] e r,j only i f s = [ p , Idot-1, r d o t, m ] e f < i.

A lgorithm 3.1 allow s the extension o f a state to both the left and right sides. This possibility, if not carefully controlled, can lead to the duplication o f an analysis, in the fo llo w in g w ay. If a state s , relative to a partial analysis for a constituent Cs , is independently extended to both sides, it w ould lead to the introduction o f tw o partially overlapping states, s' and s ' \ for the same analysis. The com pletion o f s' and 5" then w ould lead to the duplication o f constituent Cs- The algorithm presented here uses the index m, associated with each state, so as to avoid partial overlapping for tw o (partial) analyses o f the same constituent. Formally, we define the partial overlapping relation as fo llo w s.

DEFINITION 4.1 Partial Overlapping Relation

T w o states s = [ p , I d o t, r d o t, m ] e ry and 5 = [ p , I d o t’, r d o t \ t[' j ’ are p a r t i a l l y o v e r la p p e d (s ‘D sr) iff /< /'< /< /, ld o t< ld o t’< r d o t< r d o t\ and, furthermore, s subsum es the

same constituents Cpjdot'+l—Cpjciot subsumed in s ’.

N ote that for tw o states s = [ p , I d o t, r d o t, m ] and J = [ p , I d o t’, r d o t \ m *] such that s(Ds\ it alw ays holds that Idot'<z(p)<rdot. The follow ing theorem can now be stated.

(7)

THEOREM 4.1

Algorithm 3.1 never generates two states s and s' such that sUs'.

The follow ing result regards space and time com plexity for Algorithm 3.1. Such a result is intended for a Random Access Machine model o f computation.

t h e o r e m 4.2

Algorithm 3.1 requires an amount o f space 0 ( n 2) and an amount o f time 0(rc3), where

n is the length o f the input string.

5. A B r i e f E x a m p l e

In order to have an insight into A lgorithm 3.1, an exam ple regarding a sim ple computation is given here. Assum e an unambiguous context-free grammar G =(N , I , P, S), where N = (S , A, B }, L = {a , b, c, d, e ) , and P is the production set given as follows:

1

: S —» A a , x (l)= 2 ,

7

t ( l ) =

2

;

2

: S -> B b , l(2 )= 2 , tt(2)=2; 3: A - » c A c , t(3)=2, 7T(3)=3; 4: A —> d , X (4)=l, 7t(4)=l; 5: B —> c B c , t(5 )= 2 , ti(5)=3;

6:

B - » e , x (6) = l,

7

t(6) = l.

From Definition 2.2 it follow s that:

F(A ) = {[3, 1 , 2 , - ] } ; F(B) = {[5, 1 , 2 , - ] } ; F(a) = {[1, 1 , 2 , - ] } ; ¥( b) = {[2, 1 , 2 , - ] } ; F(*f) = {[4, 0,

1

, - ] } ; F(e) = {[6, 0,

1

, - ] } ; F(S) = F(c) =

0

.

A run o f A lgorithm 3.1 on the string w = c c e c c b is sim plified by the follo w in g steps (the order o f application for the five procedures at line 5 is chosen at random).

1

) ^ i= [6,

0

,

1

, -] is inserted in

^ 3 and S

2= [2>

1

*

2

, - ] is inserted in rj

5

, by line 3;

2

) ^3= [5,

1

,

2

, - ] is inserted in f2 3 by the trigger procedure;

3)

54= [5, 0, 2, -] is inserted in

and m is set to rm in state

53, by Case 2 o f

the left-expander procedure;

4) J5= [5, 0, 3, -] is inserted in f1>4and m is set to Im in state s4 , by Case 2 o f the right-expander procedure;

5)

5

6= [5

, 1 , 2 , - ] is inserted in r1>4 by the trigger procedure;

6)

j

7=[5, 1 , 3 , - ] is inserted in

and m is set to Im in state by Case 2 o f the right-expander procedure;

7)

5g=[5

, 0, 3, -] is inserted in ^ and m is set to rm in state s-j, by Case 2 o f the left-expander procedure;

(8)

8) ^ - [ 5 , 1,2, - ] is inserted in r0,5 by the trigger procedure;

9)

5

io = [

2

, 0, 2, -] is inserted in fQ

,6 an<^ m *s set

t0 rm

state by the right-completer procedure;

1 0)

the algorithm outputs true and then stops.

Note how the setting o f the m components in states

53 and 55 prevents the expansion of

partial analysis at both sides. Though not shown here, in more com plicated cases the setting o f the m components permits the left-completer procedure to combine a state s with the “leftward largest” partial analyses that are adjacent to the left o f s, preventing once more partial analysis duplication (vice versa for the right-completer procedure).

Finally, note that in the above example Algorithm 3.1 has constructed 10 states, while a run o f the classic method o f Earley on the same string would have constructed 25 states. Furthermore, by defining x(p)= 1, l<p<lPI, Algorithm 3.1 m im ics the left-corner strategy as stated in [Wir£n, 1987], resulting in the construction o f 17 states for the same analysis.

6. Fi nal R e m a r k s

This paper discusses a parsing algorithm that extends bidirectionally the classic tabular m ethods for context-free language analysis. The algorithm is given for e-free form context-free grammars, but it is not difficult to extend it to the general case, for exam ple by em ploying the same technique used in [Graham et al. 1980] in the treatment o f empty categories.

With respect to natural language parsing, the presented tabular m ethod is com patible with the w ell known “A ctive Chart Parsing” technique, as pointed out in [Satta and Stock 1989a]. Finally, the extension to Earley's A lgorithm proposed in [Shieber 1985] for parsing com plex-feature-based formalisms, could be equally applicable to the presented approach.

R e f e r e n c e s

[A ho and U llm an, 1972] A ho, A. V ., and J. D. U llm an. The T h eo ry o f P a rsin g , T ra n sla tion , an C om piling, vol. 1, Prentice-H all, E n glew ood C liffs, N ew Jersey,

1972.

[B o ssi e t a l ., 1983] B o ssi, A ., N . C occo, and L. C olussi. A divide-and-conquer ap­ proach to general context-free parsing. Information Processing Letters, 16 - pp. 203- 208, 1983.

[Earley, 1970] Earley, J. An Efficient Context-Free Parsing Algorithm. Communications o f the A C M , 13(2), pp. 9 4 -1 0 2, 1970.

[Graham and Harrison, 1976] Graham, S. L., and M. A. Harrison. Parsing o f General C ontext Free Languages. A d va n ces in C o m p u ters , pp. 77 -1 8 5 , A cadem ic Press, N ew York, 1976.

[Graham e t a l ., 1980] Graham, S. L., M. A. Harrison, and W. L. R uzzo. An Improved Context-Free Recognizer. A C M T oplas, 2(3), pp. 415-46 2, 1980.

[Kaplan, 1973] Kaplan, R. M. A General Syntactic Processor. In: (R. R ustin, ed) N a tu ra l L a n g u a g e P r o c e s s in g , pp. 193-241, A lgorithm ics Press, N ew York, N ew York, 1973.

(9)

[Kay, 1980] Kay, M. Algorithm Schemata and Data Structures in Syntactic Processing. Tecnical Report CSL-80 Xerox-PARC, Palo Alto, California, 1980.

[Satta and Stock, 1989a] Satta, G., and O. Stock. Formal Properties and Implementation o f Bidirectional Chans. Proceedings o f the 11th International Joint Conference on Artificial Intelligence, Detroit, Michigan, 1989.

[Satta and Stock, 1989b] Satta, G., and O. Stock. Bidirectional Context-Free Language Parsing within a tabular approach, submitted for publication.

[Shieber, 1985] Shieber, S. M. U sing Restriction to Extend Parsing Algorithm s for C om plex-Feature-B ased Form alism s. Proceedings o f the 2 3 rd Conference o f the Association f o r Computational Linguistics, Chicago, Illinois, 1985.

[Steel and De Roeck, 1987] Steel, S. and A. De Roeck. Bidirectional Chart Parsing. Proceedings o f AISB-87, Edinburgh, Scotland, 1987.

[Stock et al., 1989] Stock, O., R. Falcone, and P. Insinnamo. Bidirectional Charts: a Potential Technique for Parsing Spoken Natural Language. Computer Speech and Language, 3, 1989.

[Wiren, 1987] Wiren, M. A Comparison o f Rule-Invocation Strategies in Context-Free Parsing. Proceedings o f the 3rd Conference o f the European Chapter o f the A sso cia ­ tion f o r Computational Linguistics, Copenhagen, Denmark, 1987.

References

Related documents

Thermal responses and limits were determined by integrating information from various levels of biological organization, including the expression of Hsp70 and Hsp90, the

In this paper, in terms of the curvature and the torsion, (resp., the mean curvature), we give necessary and su ffi cient conditions for nonharmonic Legendre curves (resp.,

We discuss the uniqueness problem of meromorphic functions sharing one value and obtain two theorems which improve a result of Xu and Qu and supplement some other results earlier

[18] , Linear Representations of Partially Ordered Sets and Vector Space Categories, Algebra, Logic and Applications, vol. Zhang, eds.), Beijing Normal University Press, Beijing,

O’Regan, “Existence theory for single and multiple solutions to singular positone boundary value problems,” Journal of Diff erential Equations, vol.. O’Regan, “A note on

The beginning levels of the participating mothers were gathered by the researcher using “The Measurement Instrument Implementing Process of the Teaching Steps of Self-care Skills”

permits the elapsed time for a given route segment to be. interpolated from an array of data for segments of

A recent survey asked a variety of experts to identify the most important environmental risks related to hydraulic fracturing operations, experts agreed that well venting during