1 / 5

A CYK for Any Grammar

A CYK for Any Grammar.

ayala
Download Presentation

A CYK for Any Grammar

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A CYK for Any Grammar grammar G, non-terminals A1,...,AK, tokens t1,....tLinput word: w = w(0)w(1) …w(N-1)wp..q = w(p)w(p+1) …w(q-1)Triple (A, p, q) means: A =>*wp..q , Acan be: Ai, tj, or P = {(w(i),i,i+1)| 0 i < N-1} repeat { choose rule (A::=B1...Bm)G if ((A,p0,pm)P && ((m=0 && p0=pm) || (B1,p0,p1), ...,(Bm,pm-1,pm)  P)) P := P U {(A,p0,pm)} } until no more insertions possible What is the maximal number of steps?How long does it take to check step for a rule? for grammar in given normal form

  2. Strategy for Populating Table • Which order to insert (A, p, q)tuples ? • all orders give correct result • efficiency differs • Left-to-right scan of the input: • derive all A,p for given q • then increase q to q+1 • Consider only productive parse attempts • insert (A,p,q) only if we can prove thatS =>* w0..p-1 A Y (Y is any string of symbols)

  3. Dotted Rules Like Nonterminals X ::= Y1 Y2 Y3 Chomsky transformation is (a simplification of) this: X ::= W123 W123 ::= W12 Y3 W12 ::= W1 Y2 W1 ::= WY1 W ::=  Early parser: dotted RHS as names of fresh non-terminals: X ::= (Y1Y2Y3.)(Y1Y2Y3.) ::= (Y1Y2.Y3) Y3 (Y1Y2.Y3) ::= (Y1.Y2Y3) Y2 (Y1.Y2Y3) ::= (.Y1Y2Y3) Y3 (.Y1Y2Y3) ::= 

  4. Earley Parser - group the triples by last element: S(q)={(A,p)|(A,p,q)P} - dotted rules effectively make productions at most binary

  5. S ::= . e EOF | e . EOF | e EOF . e ::= . ID | ID . | . e – e | e . – e | e – . e | e – e . | . e == e | e . == e | e == . e | e == e .

More Related