NT: non-terminal T: terminal * A ===> B a derivation of B from A using >=1 rule Check mark (CM): a conforming rule X: non-conforming rule Conforming rules are NT --> NT NT or NT --> T 1. OG = {Rules in original grammar} G = {Check rules in the OG} Q = {X rules in the original grammar} Below, "add" means add the rule to NewG if it is CM; add it to the Q, if it is still X Assume sensible coding of the queue (ME: we don't need all the gory details to understand the algorithm) (NOTE to me: these are sets, so the CAN'T have duplicates) 2. For each rule in Q: NT -> mixture of NT, T Remove from Q E.g. INF-VP --> to VP add: INF-VP --> TO VP TO --> to 3. NT --> NT is called a "unit production" (UP) * For each A ===> B where all the rules are UPs in Q Let {gamma} be all gamma such that B --> gamma is in Q U G (*Note for me: Q + NewG are all the rules in the original grammar but with the terminals replaced in rules in step 2 *) add: A --> gamma for all gamma in {gamma} Once all the UPs in a chain are processed, remove them from Q Our grammar: NP --> Pronoun {gamma} = {I, she, me} add: NP --> I|She|me NP --> ProperNoun, Nominal --> Noun similar. Stop and look at the grammar to see where we are. Continuing: * S ===> verb {gamma} = {book, include, prefer} add: S --> book|include|prefer * VP ===> verb {gamma} = {book,include,prefer} add: VP --> book|include|prefer * S ===> VP {gamma} = {Verb, VerbNP,VerbNPPP,VerbPP,VPPP} add: S --> Verb already taken care of (SAY SOMETHING LIKE: you could handle this in different ways in the actual code. One would be to add it to Q; it would be processed again; but the grammar is a set of rules, so it doesn't hurt to add duplicates. Or, you could order how you process the rules in a smart way.) S --> VerbNP CM S --> Verb NP PP X (SAY - added to Q for further processing below) S --> Verb PP CM S --> VP PP CM Stop and look at the grammar The Q now only has NT --> NT NT gamma where gamma is one or more NT (right?) (4) For each rule A --> BC gamma in Q: (A, B, C are NTs; gamma is one or more NT) add: X --> BC (X is a new NT; BC are the leftmost NTs) A --> Xgamma (NOTE: as above, if A --> Xgamma CM, put in G; if not, put it on Q and keep processing) E.g.: A --> BCDE add: X --> BC CM A --> XDE X A --> XDE add: XX --> XD CM A --> X1 E CM Our grammar: S --> Verb NP PP (from step (3)) add: X2 --> Verb NP CM S --> X2 PP CM S --> Aux NP VP add: X1 --> Aux NP CM S --> X1 VP CM Done!