Download presentation

Presentation is loading. Please wait.

1
**The Cocke-Younger-Kasami Algorithm***

Chung, Sei Kwang *Alfred Aho, Jeffrey Ullman의 “The Theory of Parsing, Translation, and Compiling”과 인터넷을 참고하여 작성되었습니다.

2
**Contents Preliminaries CYK algorithm Context Free Grammar**

Chomsky Normal Form Dynamic Programming CYK algorithm Purpose of parsing Premise Constructing the parse table Left parsing from the parse table

3
**Preliminaries(1) Context Free Grammar(1) Grammar**

Notation ; G = (N, Σ, P, S) N ; a finite set of non-terminal symbols Σ ; a finite set of terminal symbols P ; a finite subset of (N∪Σ)*N(N∪Σ)*×(N∪Σ)* @ Production : (α, β) ∈ P will be written α → β S ; the start symbol in N

4
**Preliminaries(2) Context Free Grammar(2) Chomsky Normal Form CFG**

G ; if each production in P is of the form A → α , where A is in N and α is in (N∪Σ)* Chomsky Normal Form Production can be 1 of 2 formats A → α A → BC @ e – production ; ex) 00A1 → 001 (∵A → e ∈ P )

5
**Preliminaries(3) Dynamic Programming Optimal substructure**

Solution of problem = Σ Solution of subproblem Overlapping subproblem X = S1 + S2 S1 = T1 + T2 + T3 S2 = T2 + T3 + T4 T2, T3 overlapped Recording solutions to reduce calculation Reuse the recorded solutions

6
**CYK algorithm(1) Premise Purpose of parsing**

G = (N, Σ, P, S) ; a Chomsky normal form CFG with no e-production The input string w = a1a2…an Each ai ∈ Σ (1≤i ≤n) The element of the parse table, T ; tij Purpose of parsing To determine whether string w is in L(G) Input string w is in L(G) ⇔ S is in t1n

7
**CYK algorithm(2) Constructing the parse table(1)**

Input ; w = a1a2…an ∈ Σ+ Output ; The parse table T for w such that tij contains A ⇔ A +⇒ aiai+1…ai+j-1 Method 1st, ti1 = {A|A→ai ∈ P, 1≤i≤n} 2nd, 1≤k<j, tij = {A|for some k, A→BC ∈ P, B is in tik, C is in ti+k, j-k} 3rd, repeat 2nd step until 1≤i≤n, 1≤j≤n-i+1

8
**CYK algorithm(3) Constructing the parse table(2) Example**

Input string; abaab(n=5) Productions; S→AA|AS|b A→SA|AS|a Parse table → 5 A,S 4 3 S 2 A 1 j i

9
**CYK algorithm(4) Left parsing from the parse table(1) Input ; Output ;**

A Chomsky normal form CFG G = (N, Σ, P, S) Numbered productions Input string w The parse table Output ; a left parse for w or the signal “error”

10
**CYK algorithm(5) Left parsing from the parse table(2)**

Method ; A recursive routine gen(i,j,A); generate a left parse corresoding to the derivation A +⇒ aiai+1…ai+j-1 1st, if j = 1, the mth production in P is A→ai then output m 2nd, if j > 1, k(1≤k<j) is the smallest integer, A→BC ∈P then output m

11
**CYK algorithm(6) Left parsing from the parse table(3) Example Input ;**

w = abaab Numbered productions 1. S → AA 2. S → AS 3. S → b 4. A → SA 5. A → AS 6. A → a Output ; 1: S → AA 6: A → a 4: A → SA 3: S → b 5: A → AS 2: S → AS 5 A,S 4 3 S 2 A 1 j i

12
**Thank you for listening.**

경청해주셔서 감사합니다. 설은 가족과 함께 행복하게 보내세요.

Similar presentations

Presentation is loading. Please wait....

OK

CONVERTING TO CHOMSKY NORMAL FORM

CONVERTING TO CHOMSKY NORMAL FORM

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on medical tourism in india Ppt on brand marketing group Ppt on magnetic field lines Ppt on product design and development Ppt on number system for class 5 Ppt on natural resources for class 8 Download ppt on teamviewer Ppt on hybrid solar lighting system Ppt on nitrogen cycle and nitrogen fixation is a process Ppt on gunn diode