Earley algorithm Earley: introduction Example of Earley algorithm - - PowerPoint PPT Presentation

earley algorithm
SMART_READER_LITE
LIVE PREVIEW

Earley algorithm Earley: introduction Example of Earley algorithm - - PowerPoint PPT Presentation

Earley algorithm Scott Farrar CLMA, University of Washington far- rar@u.washington.edu Earley algorithm Earley algorithm Earley: introduction Example of Earley algorithm Scott Farrar CLMA, University of Washington farrar@u.washington.edu


slide-1
SLIDE 1

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Earley algorithm

Scott Farrar CLMA, University of Washington farrar@u.washington.edu February 1, 2010

1/21

slide-2
SLIDE 2

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Today’s lecture

1

Earley algorithm Earley: introduction Example of Earley algorithm

2/21

slide-3
SLIDE 3

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Top-down parsing

In naive search, top-down parsing is inefficient because structures are created over and over again. Need a way to record that a particular structure has been predicted Need a way to record where the structure was predicted wrt the input

3/21

slide-4
SLIDE 4

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Pros/cons of top-down strategy

√ Never explores trees that aren’t potential solutions, ones with the wrong kind of root node.

4/21

slide-5
SLIDE 5

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Pros/cons of top-down strategy

√ Never explores trees that aren’t potential solutions, ones with the wrong kind of root node. X But explores trees that do not match the input sentence (predicts input before inspecting input).

4/21

slide-6
SLIDE 6

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Pros/cons of top-down strategy

√ Never explores trees that aren’t potential solutions, ones with the wrong kind of root node. X But explores trees that do not match the input sentence (predicts input before inspecting input). X Naive top-down parsers never terminate if G contains recursive rules like X → X Y (left recursive rules).

4/21

slide-7
SLIDE 7

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Pros/cons of top-down strategy

√ Never explores trees that aren’t potential solutions, ones with the wrong kind of root node. X But explores trees that do not match the input sentence (predicts input before inspecting input). X Naive top-down parsers never terminate if G contains recursive rules like X → X Y (left recursive rules). X Backtracking may discard valid constituents that have to be re-discovered later (duplication of effort).

4/21

slide-8
SLIDE 8

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Pros/cons of top-down strategy

√ Never explores trees that aren’t potential solutions, ones with the wrong kind of root node. X But explores trees that do not match the input sentence (predicts input before inspecting input). X Naive top-down parsers never terminate if G contains recursive rules like X → X Y (left recursive rules). X Backtracking may discard valid constituents that have to be re-discovered later (duplication of effort). Use a top-down strategy when you know what kind of constituent you want to end up with (e.g. NP extraction, named entity extraction). Avoid this strategy if you’re stuck with a highly recursive grammar.

4/21

slide-9
SLIDE 9

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Earley algorithm

The Earley Parsing Algorithm: an efficient top-down parsing algorithm that avoids some of the inefficiency associated with purely naive search with the same top-down strategy (cf. recursive descent parser). Intermediate solutions are created only once and stored in a chart (dynamic programming). Left-recursion problem is solved by examining the input. Earley is not picky about what type of grammar it accepts, i.e., it accepts arbitrary CFGs (cf. CKY).

5/21

slide-10
SLIDE 10

Earley Parsing Algorithm (J&M, p. 444)

function Earley-Parse(words,grammar) returns chart Enqueue((γ → •S, [0,0]),chart[0]) for i ← from 0 to Length(words) do for each state in chart[i] do if Incomplete?(state) and Next-Cat(state) is not POS then Predictor(state) elseif Incomplete?(state) and Next-Cat(state) is POS then Scanner(state) else Completer(state) end end return(chart)

slide-11
SLIDE 11

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: the chart

The rationale is to fill in a chart with the solutions to the subproblems encountered in the top-down parsing process. Based on an input string of length n, build a 1D array (called a chart) of length n + 1 to record the solutions to subproblems Chart entries are lists of states, or info about partial solutions. States represent attempts to discover constituents.

7/21

slide-12
SLIDE 12

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Empty Earley chart

Chart[0]:

  • astronomers saw stars with ears

partial solutions ... Chart[1]: astronomers • saw stars with ears partial solutions ... Chart[2]: astronomers saw • stars with ears partial solutions ... Chart[3]: astronomers saw stars • with ears partial solutions ... Chart[4]: astronomers saw stars with • ears partial solutions ... Chart[5]: astronomers saw stars with ears •

Assumed indexing scheme:

  • 0astronomers •1 saw •2 stars •3 with •4 ears•5

8/21

slide-13
SLIDE 13

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: the states

A state consists of:

9/21

slide-14
SLIDE 14

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: the states

A state consists of:

1 a subtree corresponding to a grammar rule

S → NP VP

9/21

slide-15
SLIDE 15

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: the states

A state consists of:

1 a subtree corresponding to a grammar rule

S → NP VP

2 info about progress made towards completing this

subtree S → NP • VP

9/21

slide-16
SLIDE 16

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: the states

A state consists of:

1 a subtree corresponding to a grammar rule

S → NP VP

2 info about progress made towards completing this

subtree S → NP • VP

3 the position of the subtree wrt input

S → NP • VP, [0, 3]

9/21

slide-17
SLIDE 17

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: the states

A state consists of:

1 a subtree corresponding to a grammar rule

S → NP VP

2 info about progress made towards completing this

subtree S → NP • VP

3 the position of the subtree wrt input

S → NP • VP, [0, 3]

4 pointers to all contributing states in the case of a parser

(cf. recognizer)

9/21

slide-18
SLIDE 18

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Setting up the Earley algorithm: dotted rules

Definition

A dotted rule is a data structure used in top-down parsing to record parital solutions towards discovering a constituent. S → •VP, [0, 0] Predict an S will be found which consists of a VP; the S will begin at 0. NP → Det • Nominal, [1, 2] Predict an NP starting at 1; an Det has been found; Nominal is expected next. VP → V NP•, [0, 3] A VP has been found starting at 0 and spanning to 3; the constituents of VP are V and NP.

10/21

slide-19
SLIDE 19

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Dotted rules and corresponding graph

11/21

slide-20
SLIDE 20

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Earley: fundamental operations

Predict sub-structure (based on grammar) Scan partial solutions for a match Complete a sub-structure (i.e., build constituents)

12/21

slide-21
SLIDE 21

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Sample grammar from J&M

S → NP VP NP → NP PP PP → P NP NP → N VP → V NP N → astronomers VP → VP PP N → ears P → with N → stars V → saw N → telescopes

ambiguous, PP attachment

astronomers saw stars with ears

13/21

slide-22
SLIDE 22

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

An extra rule

How to represent progress towards finding an S node? Add a dummy rule to grammar: γ → S This seeds the chart as the base case for recursion.

14/21

slide-23
SLIDE 23

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

An extra rule

How to represent progress towards finding an S node? Add a dummy rule to grammar: γ → • S This seeds the chart as the base case for recursion.

14/21

slide-24
SLIDE 24

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

15/21

slide-25
SLIDE 25

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

Enqueue dummy start state

15/21

slide-26
SLIDE 26

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed

15/21

slide-27
SLIDE 27

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed For each state in chart[i]... processing S0

15/21

slide-28
SLIDE 28

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed if state incomplete and NextCat is not POS, then Predictor procedure Predictor((A → α • B β, [i,j])) for each (B → γ) in Grammar-Rules-For(B,grammar) do Enqueue((B → •γ, [j,j]),chart[j]) end

15/21

slide-29
SLIDE 29

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed if state incomplete and NextCat is not POS, then Predictor procedure Predictor((A → α • B β, [i,j])) for each (B → γ) in Grammar-Rules-For(B,grammar) do Enqueue((B → •γ, [j,j]),chart[j]) end S → NP VP NP → NP PP PP → P NP NP → N VP → V NP N → astronomers VP → VP PP N → ears P → with N → stars V → saw N → telescopes

15/21

slide-30
SLIDE 30

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor

15/21

slide-31
SLIDE 31

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor processing S1

15/21

slide-32
SLIDE 32

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor if state incomplete and NextCat is not POS, then Predictor procedure Predictor((A → α • B β, [i,j])) for each (B → γ) in Grammar-Rules-For(B,grammar) do Enqueue((B → •γ, [j,j]),chart[j]) end S → NP VP NP → NP PP PP → P NP NP → N VP → V NP N → astronomers VP → VP PP N → ears P → with N → stars V → saw N → telescopes

15/21

slide-33
SLIDE 33

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor

15/21

slide-34
SLIDE 34

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor S3 NP → •N [0,0] [] Predictor

15/21

slide-35
SLIDE 35

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor S3 NP → •N [0,0] [] Predictor processing S2... but NP at position [0,0] has already been considered

15/21

slide-36
SLIDE 36

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor S3 NP → •N [0,0] [] Predictor

16/21

slide-37
SLIDE 37

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor S3 NP → •N [0,0] [] Predictor processing S3 ...

16/21

slide-38
SLIDE 38

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor S3 NP → •N [0,0] [] Predictor if state incomplete and NextCat is a POS, then Scanner procedure Scanner((A → α • B β, [i,j])) if B ⊂ POS(word[j]) then Enqueue((B → word[j], [j,j+1]),chart[j+1])

16/21

slide-39
SLIDE 39

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[0]: “• astronomers saw stars with ears”

state ID dotted rule position back pointer

  • peration

S0 TOP → •S [0,0] [] Seed S1 S → •NP VP [0,0] [] Predictor S2 NP → •NP PP [0,0] [] Predictor S3 NP → •N [0,0] [] Predictor Scanner: Add N → astronomers• [0,1] at Chart[0+1]

16/21

slide-40
SLIDE 40

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner

17/21

slide-41
SLIDE 41

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner

17/21

slide-42
SLIDE 42

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner processing S4...else Completer

17/21

slide-43
SLIDE 43

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner procedure Completer((B → γ•, [j,k])) for each (A → α • B β, [i,j]) in chart[j] do Enqueue((A → α B • β, [i,k]), chart[k]) end Which states from Chart[0] require the current constit. to be complete?

17/21

slide-44
SLIDE 44

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer

17/21

slide-45
SLIDE 45

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer processing S5...else Completer

17/21

slide-46
SLIDE 46

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer procedure Completer((B → γ•, [j,k])) for each (A → α • B β, [i,j]) in chart[j] do Enqueue((A → α B • β, [i,k]), chart[k]) end Which states from Chart[0] require the current constit. to be complete?

17/21

slide-47
SLIDE 47

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer

17/21

slide-48
SLIDE 48

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer

17/21

slide-49
SLIDE 49

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer processing S6...Predictor

17/21

slide-50
SLIDE 50

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor

17/21

slide-51
SLIDE 51

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor

17/21

slide-52
SLIDE 52

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor

17/21

slide-53
SLIDE 53

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor processing S7...Predictor

17/21

slide-54
SLIDE 54

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor S10 PP → •P NP [1,1] [] Predictor

17/21

slide-55
SLIDE 55

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor S10 PP → •P NP [1,1] [] Predictor Processing S8...Scanner: Add V → saw• [1,2] at Chart[1+1]

17/21

slide-56
SLIDE 56

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor S10 PP → •P NP [1,1] [] Predictor Processing S9...Predictor, but VP already expanded in Chart[1]

17/21

slide-57
SLIDE 57

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[1]: “astronomers • saw stars with ears”

state ID dotted rule position back pointer

  • peration

S4 N → astronomers• [0,1] [] Scanner S5 NP → N• [0,1] [S4] Completer S6 S → NP • VP [0,1] [S5] Completer S7 NP → NP • PP [0,1] [S5] Completer S8 VP → •V NP [1,1] [] Predictor S9 VP → •VP PP [1,1] [] Predictor S10 PP → •P NP [1,1] [] Predictor Processing S10...Scanner, but no P in input at words[1]

17/21

slide-58
SLIDE 58

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[2]: “astronomers saw • stars with ears”

state ID dotted rule position back pointer

  • peration

18/21

slide-59
SLIDE 59

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[2]: “astronomers saw • stars with ears”

state ID dotted rule position back pointer

  • peration

S11 V → saw• [1,2] [] Scanner

18/21

slide-60
SLIDE 60

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[2]: “astronomers saw • stars with ears”

state ID dotted rule position back pointer

  • peration

S11 V → saw• [1,2] [] Scanner S12 VP → V • NP [1,2] [S11] Completer

18/21

slide-61
SLIDE 61

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[2]: “astronomers saw • stars with ears”

state ID dotted rule position back pointer

  • peration

S11 V → saw• [1,2] [] Scanner S12 VP → V • NP [1,2] [S11] Completer S13 NP → •NP PP [2,2] [] Predictor

18/21

slide-62
SLIDE 62

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[2]: “astronomers saw • stars with ears”

state ID dotted rule position back pointer

  • peration

S11 V → saw• [1,2] [] Scanner S12 VP → V • NP [1,2] [S11] Completer S13 NP → •NP PP [2,2] [] Predictor S14 NP → •N [2,2] [] Predictor

18/21

slide-63
SLIDE 63

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner

19/21

slide-64
SLIDE 64

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner S16 NP → N• [2,3] [S15] Completer

19/21

slide-65
SLIDE 65

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner S16 NP → N• [2,3] [S15] Completer S17 VP → V NP• [1,3] [S11,S16] Completer

19/21

slide-66
SLIDE 66

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner S16 NP → N• [2,3] [S15] Completer S17 VP → V NP• [1,3] [S11,S16] Completer S18 NP → NP • PP [2,3] [S16] Completer

19/21

slide-67
SLIDE 67

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner S16 NP → N• [2,3] [S15] Completer S17 VP → V NP• [1,3] [S11,S16] Completer S18 NP → NP • PP [2,3] [S16] Completer S19 S → NP VP• [0,3] [S5,S17] Completer

19/21

slide-68
SLIDE 68

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner S16 NP → N• [2,3] [S15] Completer S17 VP → V NP• [1,3] [S11,S16] Completer S18 NP → NP • PP [2,3] [S16] Completer S19 S → NP VP• [0,3] [S5,S17] Completer S20 VP → VP • PP [1,3] [S17] Completer

19/21

slide-69
SLIDE 69

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[3]: “astronomers saw stars • with ears”

state ID dotted rule position back pointer

  • peration

S15 N → stars• [2,3] [] Scanner S16 NP → N• [2,3] [S15] Completer S17 VP → V NP• [1,3] [S11,S16] Completer S18 NP → NP • PP [2,3] [S16] Completer S19 S → NP VP• [0,3] [S5,S17] Completer S20 VP → VP • PP [1,3] [S17] Completer S21 PP → •P NP [3,3] [] Predictor

19/21

slide-70
SLIDE 70

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[4]: “astronomers saw stars with • ears”

state ID dotted rule position back pointer

  • peration

S22 P → with• [3,4] [] Scanner

20/21

slide-71
SLIDE 71

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[4]: “astronomers saw stars with • ears”

state ID dotted rule position back pointer

  • peration

S22 P → with• [3,4] [] Scanner S23 PP → P • NP [3,4] [S19] Completer

20/21

slide-72
SLIDE 72

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[4]: “astronomers saw stars with • ears”

state ID dotted rule position back pointer

  • peration

S22 P → with• [3,4] [] Scanner S23 PP → P • NP [3,4] [S19] Completer S24 NP → •NP PP [4,4] [] Predictor

20/21

slide-73
SLIDE 73

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[4]: “astronomers saw stars with • ears”

state ID dotted rule position back pointer

  • peration

S22 P → with• [3,4] [] Scanner S23 PP → P • NP [3,4] [S19] Completer S24 NP → •NP PP [4,4] [] Predictor S25 NP → •N [4,4] [] Predictor

20/21

slide-74
SLIDE 74

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

21/21

slide-75
SLIDE 75

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner

21/21

slide-76
SLIDE 76

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer

21/21

slide-77
SLIDE 77

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer

21/21

slide-78
SLIDE 78

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer

21/21

slide-79
SLIDE 79

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer

21/21

slide-80
SLIDE 80

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer

21/21

slide-81
SLIDE 81

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer S32 NP → NP • PP [2,5] [S29] Completer

21/21

slide-82
SLIDE 82

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer S32 NP → NP • PP [2,5] [S29] Completer S33 VP → V NP• [2,5] [S11,S29] Completer

21/21

slide-83
SLIDE 83

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer S32 NP → NP • PP [2,5] [S29] Completer S33 VP → V NP• [2,5] [S11,S29] Completer S34 NP → NP • PP [2,5] [S29] Completer

21/21

slide-84
SLIDE 84

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer S32 NP → NP • PP [2,5] [S29] Completer S33 VP → V NP• [2,5] [S11,S29] Completer S34 NP → NP • PP [2,5] [S29] Completer S35 S → NP VP• [0,5] [S5,S30] Completer

21/21

slide-85
SLIDE 85

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer S32 NP → NP • PP [2,5] [S29] Completer S33 VP → V NP• [2,5] [S11,S29] Completer S34 NP → NP • PP [2,5] [S29] Completer S35 S → NP VP• [0,5] [S5,S30] Completer S36 S → NP VP• [0,5] [S5,S31] Completer

21/21

slide-86
SLIDE 86

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Chart[5]: “astronomers saw stars with ears •”

state ID dotted rule position back pointer

  • peration

S26 N → ears• [4,5] [] Scanner S27 NP → N• [4,5] [S26] Completer S28 PP → P NP• [3,5] [S19,S27] Completer S29 NP → NP PP• [2,5] [S16,S28] Completer S30 VP → VP PP• [1,5] [S17,S28] Completer S31 VP → V NP• [1,5] [S11,S29] Completer S32 NP → NP • PP [2,5] [S29] Completer S33 VP → V NP• [2,5] [S11,S29] Completer S34 NP → NP • PP [2,5] [S29] Completer S35 S → NP VP• [0,5] [S5,S30] Completer S36 S → NP VP• [0,5] [S5,S31] Completer S37 PP → •P NP [5,5] [] Predictor

21/21

slide-87
SLIDE 87

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Parse 1

22/21

slide-88
SLIDE 88

Earley algorithm Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Earley algorithm

Earley: introduction Example of Earley algorithm

Parse 2

23/21