Professional Documents
Culture Documents
Reading: Jay Earley, An Efcient Context-Free Parsing Algorithm Comm. of the ACM vol. 13 (2), pp. 94102
Developed prior to Chart Parsing, rst efcient parsing algorithm for general context-free grammars.
1 11-711 Algorithms for NLP
The algorithm maintains sets of states, one set for each position in the input string (starting from 0) We denote the set for position by
, add to
# #
% &
$
' ( $
( ' $
, then add to
)
!
2 )
1
)
with
$ 0
8
3
$ 0
8
@ 3
2. For 0 do: Process each item in order by applying to it the single applicable operation among:
(b) Completer (adds new items to (c) Scanner (adds new items to 3. If 4. If
1
2 2 1 2
7 5
and
A!
) )
1
$ 0
8
1
3 @
2 9 1
6
20
The original input: The large can can hold the water POS assigned input: art adj n aux v art n art adj n aux v art n $ Parser input:
20 20
CD )H DE )I 0 DE P CD DE
0:
$ 0
@ 3
CD
0
DE
CD CD CD )FG )H )FG )H
0
0 0
1:
0
CD CD
)FG
)H
0
)FG
1:
0
CD
)FG
)H
0
CD
)FG
2:
0
CD
)FG
)H
2:
0
CD
)FG
)H
3:
0
CD
)FG
)H
3:
0
CD
)FG
)H
0 3
CD
DE
DE DE DE )I 0
3
CD P
4:
3
DE
DE
)I
10
4:
3 4
DE
DE
)I
DE DE
DE
)I
4
CD P
5:
4
DE
CD
11
5:
4
DE
CD
5
CD CD CD
)FG
)H
5 5
)H )FG
6:
5
CD CD
)FG
)H
5
)FG
12
6:
5
CD
)FG
)H
5
CD
)FG
7:
5
CD
)FG
13
7:
5 4
CD
)FG
DE DE 3 @
CD
DE )I 0 CD DE
3
0
$ 0
8:
0
3 @
14
Thus
The Scanner and Predictor operations on an item each require constant time The Completer operation on an item adds items of form to , with 0 , so it may require up 1 to time for each processed item
'( $ '
items
&
2
time in
For unambiguous grammars, Earley shows that the completer time operation will require at most Thus time complexity for unambiguous grammars is For some grammars, the number of items in each bounded by a constant
is
These are called bounded-state grammars and include even some ambiguious grammars. For bounded-state grammars, the time complexity of the algorithm is linear
16
At the end - reconstruct parse from the back-pointers To maintain efciency - we must do ambiguity packing
17
18
0:
$ 0
@ 3
CD
0
DE
CD CD CD )FG )H )FG )H
0
0 0
1:
1 1
0
CD CD
)FG
)FG
)H
)FG
0
19
1:
1 1
0
CD
)H
)FG
0
CD
)FG
2:
0
CD
)FG
)H
)H
20
2:
0
CD
)FG
)H
3:
0
3 4
CD
)FG
)H
CD )FG
)H
21
3:
0
CD
)FG
)H
4
)I
0 3
DE
CD
DE DE
DE 0
3
CD P
4:
3
DE
DE
)I
)I
22
4:
3
DE
DE
)I
4
DE DE
DE
)I
4
CD P
5:
4
DE
CD
23
5:
6
)FG
4
CD
DE
5
CD CD CD
)H
5 5
)H )FG
6:
7 7
5
CD CD
)FG
)FG
)H
)FG
5
24
6:
7 7
5
CD
)H
)FG
5
CD
)FG
7:
5
8 9
CD
)FG
CD )FG
25
7:
7 6
10 11 12
9
DE
5 4
CD
)FG
10
3
11
0
10 11 12
9 10
DE
DE DE 3 @
CD
DE
CD
CD )I
DE
$ 0
)I
11
DE
CD
DE
8:
0
3 @
26