Download presentation

Presentation is loading. Please wait.

Published byWinfred Jefferson Modified about 1 year ago

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

2
2 Contents Preliminaries 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
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
4 Preliminaries(2) Context Free Grammar(2) 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
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
6 CYK algorithm(1) Premise G = (N, Σ, P, S) ; a Chomsky normal form CFG with no e-production The input string w = a 1 a 2 …a n Each a i ∈ Σ (1≤i ≤n) The element of the parse table, T ; t ij Purpose of parsing To determine whether string w is in L(G) Input string w is in L(G) ⇔ S is in t 1n

7
7 CYK algorithm(2) Constructing the parse table(1) Input ; w = a 1 a 2 …a n ∈ Σ+ Output ; The parse table T for w such that t ij contains A ⇔ A + ⇒ a i a i+1 …a i+j-1 Method 1 st, t i1 = {A|A→a i ∈ P, 1≤i≤n} 2 nd, 1≤k

8
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 → 5A,S 4 3 S 2 AS 1ASAAS jiji 12345

9
9 CYK algorithm(4) Left parsing from the parse table(1) Input ; 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
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 + ⇒ a i a i+1 …a i+j-1 1 st, if j = 1, the mth production in P is A→a i then output m 2 nd, if j > 1, k(1≤k

11
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 ; 164356263 1: S → AA 6: A → a 4: A → SA 3: S → b 5: A → AS 6: A → a 2: S → AS 6: A → a 3: S → b 5A,S 4 3 S 2 AS 1ASAAS jiji 12345

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

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google