Linguistics 581

Earley Parsing (Sample problems and solutions)


Sample problems (with answers)

There are 4 sample problems below, labeled A, B, C, and D. All are about Earley parsing.

Earley Parsing

A. Explain what gave rise to S25, S26, and S27 for the parser chart in Figure 13.14. Note that the answer isn't just: The predicter put S25, S26, and S27 there. Why does the predictor put S25, S26, and S27 in the chart? What happens at previously created edges that leads to the creation of S25, S26, and S27? Don't be scared to look at the algorithm in Figure 13.13 to get your answer. Answer: S24 is the source of S25, S26, and S27. When S24 is created, it creates a goal of finding a Nom starting at 2. Then the Predictor looks in the grammar to find all the rules for building a Nominal. There are 3 rules. The predictor adds one edge starting and ending at 2 [2,2] for each way of building a Nominal. These are S25, S26, and S27.

B. For this next part, use the following grammar

Start Cat: s

Rules
=====

   np -> det nom
   np -> nom
   np -> np pp

   vp -> v
   vp -> v np

    s -> np vp
    s -> aux np vp

   pp -> p np

  nom -> n

Lexicon
=======

  has    aux
 have    aux
   in      p
  the    det
  dog      n
 park      v
 park      n
 dogs      n
 walk      v
 walk      n

Be an Earley parser. Parse the parse the NP part of:

  • The dogs walk.
This means you only need to complete the chart up to chart[3] (all the edges ending at index 3, the one right after the word landed).

Show the Earley parsing chart in the same format as is used in Figure 13.14. Assign names like S1, S2, ... to all the edges and show them. Organize the edges, as in Figure 13.13, according to what index they end at. You should try to generate the edges in the actual order that the Earley algorithm in Figure 13.13 creates them, but I won't grade that. I will deduct for missing or incorrect edges. (Incorrect means the algorithm wouldn't actually propose such an edge; not that edge does not get used in the final parse).

Here is the answer.

S1 γ → • s [0,0] dummy start state

chart[0]:

S2 s → • np vp [0,0] predictor
S3 s → • aux np vp [0,0] predictor
S4 np → • det nom [0,0] predictor
S5 np → • nom [0,0] predictor
S6 np → • np pp [0,0] predictor
S7 det → the • [0,1] scanner
S8 nom → • n [0,0] predictor

chart[1]:

S9 np → nom • [0,1] completer
S10 nom → • n [1,1] predictor
S11 n → dogs • [1,2] scanner

chart[2]:

S12 nom → n • [1,2] completer
S13 np → nom • [0,2] completer
S14 s → np • vp [0,2] completer
S15 np → np • pp [0,2] completer
S16 vp → • v [2,2] predictor
S17 vp → • v np [2,2] predictor
S18 pp → • p np [2,2] predictor
S19 v → walk • [2,3] scanner

chart[3]:

S20 vp → v • [2,3] completer
S21 vp → v • np [2,3] completer
S22 s → np vp • [0,3] completer
S23 np → • det nom [3,3] predictor
S24 np → • nom [3,3] predictor
S25 np → • np pp [3,3] predictor
S26 gamma → s • [0,3] completer
S27 nom → • n [3,3] predictor

C Explain what gave rise to S23, S24, and S25 for the parser chart above. Note that the answer isn't just: The predicter put S23, S24, and S25 there. Why does the predictor put S23, S24, and S25 in the chart? What happens at previously created edges that leads to the creation of S23, S24, and S25?

Answer: S21 is the source of S23, S24, and S25. When S21 is created, it creates a goal of finding an NP starting at 3. Then the Predictor looks in the grammar to find all the rules for building a NP. There are 3 rules. The predictor adds one edge starting and ending at 3 [3,3] for each way of building an NP. These are S23, S24, and S25.

D Explain what gave rise to S22 for the parser chart above.

Answer: S20 is one of the sources of S22. When S20 is created, it creates a complete VP edge from 2 to 3 [2,3] for the completer to check. The completer then looks for any edge ending at 2 that needs a VP. S14 [0,2] is such an edge. So the completer creates a new edge from 0 to 3 for a complete S, and S22 is that edge.