320 likes | 430 Views
Parse Your Heart Out. May 11 th , 1999. Announcements. Assignment 4 today Matlab manuals Project rough drafts. A Translation Experiment. Rheingold Tries to Revive Brand by Marketing a 'Manly' Beer.
E N D
Parse Your Heart Out May 11th, 1999 CS251: Intro to AI/Lisp II
Announcements • Assignment 4 today • Matlab manuals • Project rough drafts CS251: Intro to AI/Lisp II
A Translation Experiment CS251: Intro to AI/Lisp II
Rheingold Tries to Revive Brand by Marketing a 'Manly' Beer Striving to put the "gold" back in Rheingold, the top executives in charge of reviving the venerable New York beer brand are revamping their marketing efforts with an overhaul that includes a new agency. Rheingold Brewing Co. has hired DeVito/Verdi in New York, an agency known for sharply humorous creative work for advertisers like New York magazine and Office Depot. DeVito/Verdi succeeds Ferrell Calvillo Communications in New York, which handled the account during the brand's initial reintroduction last year. Along with the agency change comes a Web site, www.rheingoldbeer.com, created by Compelling Content, an Internet agency in New York, and an increased focus on male beer drinkers ages 21 to 34. As a result, the ads in year two assume a jocular, hypermasculine tone to promote Rheingold as the brew "for the few real men still left." CS251: Intro to AI/Lisp II NY Times, 5/11/99
Bemühend, das " Gold ", das in Rheingold einzusetzen rückseitig ist, revamping die oberen Leitprogramme verantwortlich für das Wieder beleben der venerable New Yorkbiermarke ihre Marketing-Bemühungen mit einer Überholung, die eine neue Agentur umfaßt. Rheingold, das Co. braut, hat DeVito/Verdi in New York, eine Agentur angestellt, die für scharf humorvolle kreative Arbeit für Inserenten wie New Yorkzeitschrift und Bürodepot bekannt ist. DeVito/Verdi folgt Kommunikationen Ferrell Calvillo mit New York, das das Konto während der Ausgangswiedereinführung der Marke letztes Jahr anfaßte. Zusammen mit Agentur kommt die Änderung eine Web site, www.rheingoldbeer.com, erstellt, indem sie Inhalt, eine Internet-zwingt, Agentur in New York und ein erhöhter Fokus auf männlichem Biertrinkeralter 21 bis 34. Infolgedessen nehmen das ADS in Jahr zwei jocular, hypermasculineton an, um Rheingold als brauen " für die wenigen wirklichen Männer noch zu fördern nach links. " CS251: Intro to AI/Lisp II
Endeavoring, revamping the upper guidance programs responsible for the again the venerable new Yorkbiermarke their marketing efforts with an overhaul, which covers a new agency, animate the " gold ", which is backlateral in Rhine gold to begin. Rhine gold, which brews CO, employed DeVito/Verdi in New York, an agency, which admits for sharply humorous creative work for advertisers like new Yorkzeitschrift and office depot is. DeVito/Verdi follows communications Ferrell Calvillo with New York, which touched the account during the output re-establishment of the label last year. Together with agency the modification a web site, www.rheingoldbeer.com, comes created, by Internet-forcing contents of, one, agency into New York and a increased focus on male beer drunkard age 21 to 34. Consequently the ADS assumes in year two jocular, hypermasculineton, around Rhine gold as brews " for the few real men to promote after still left ", the makeover for the label -- formally dry CS251: Intro to AI/Lisp II
Striving to put the "gold" back in Rheingold, the top executives in charge of reviving the venerable New York beer brand are revamping their marketing efforts with an overhaul that includes a new agency. Rheingold Brewing Co. has hired DeVito/Verdi in New York, an agency known for sharply humorous creative work for advertisers like New York magazine and Office Depot. DeVito/Verdi succeeds Ferrell Calvillo Communications in New York, which handled the account during the brand's initial reintroduction last year. Endeavoring, revamping the upper guidance programs responsible for the again the venerable new Yorkbiermarke their marketing efforts with an overhaul, which covers a new agency, animate the " gold ", which is backlateral in Rhine gold to begin. Rhine gold, which brews CO, employed DeVito/Verdi in New York, an agency, which admits for sharply humorous creative work for advertisers like new Yorkzeitschrift and office depot is. DeVito/Verdi follows communications Ferrell Calvillo with New York, which touched the account during the output re-establishment of the label last year. CS251: Intro to AI/Lisp II NY Times, 5/11/99
Along with the agency change comes a Web site, www.rheingoldbeer.com, created by Compelling Content, an Internet agency in New York, and an increased focus on male beer drinkers ages 21 to 34. As a result, the ads in year two assume a jocular, hypermasculine tone to promote Rheingold as the brew "for the few real men still left." Together with agency the modification a web site, www.rheingoldbeer.com, comes created, by Internet-forcing contents of, one, agency into New York and a increased focus on male beer drunkard age 21 to 34. Consequently the ADS assumes in year two jocular, hypermasculineton, around Rhine gold as brews " for the few real men to promote after still left ", the makeover for the label -- formally dry CS251: Intro to AI/Lisp II NY Times, 5/11/99
Endeavoring, revamping the upper guidance programs responsible for the again the venerable new Yorkbiermarke their marketing efforts with an overhaul, which covers a new agency, animate the " gold ", which is backlateral in Rhine gold to begin. Rhine gold, which brews CO, employed DeVito/Verdi in New York, an agency, which admits for sharply humorous creative work for advertisers like new Yorkzeitschrift and office depot is. DeVito/Verdi follows communications Ferrell Calvillo with New York, which touched the account during the output re-establishment of the label last year. Together with agency the modification a web site, www.rheingoldbeer.com, comes created, by Internet-forcing contents of, one, agency into New York and a increased focus on male beer drunkard age 21 to 34. Consequently the ADS assumes in year two jocular, hypermasculineton, around Rhine gold as brews " for the few real men to promote after still left ", the makeover for the label -- formally dry CS251: Intro to AI/Lisp II
A Little Vocab • Formal language is a set of strings • A string is a set of terminal symbols • Phrase structure: Strings have structure • S, NP, VP • In CFG (BNF), rewrite rules consist of a single nonterminal symbol on the left-hand side CS251: Intro to AI/Lisp II
For Example S NP VP | S Conjunction S NP Pronoun | Noun | Art Noun | NP PP | NP RelClause VP Verb | NP VP | VP Adjective | VP PP | VP Adverb PP Preposition NP RelClause that VP CS251: Intro to AI/Lisp II
The Lexicon Noun stench | breeze | glitter | pit | gold nothing | wumpus | pits Verb is | see | smell | … Adjective Adverb CS251: Intro to AI/Lisp II
More Terms • Lexicon: The terms in the vocabulary • Categories/parts of speech • Noun, verb, adjective, adverb • Article, preposition, conjunction, pronoun CS251: Intro to AI/Lisp II
What’s Wrong with the Grammar We’ve Got? • Overgeneration CS251: Intro to AI/Lisp II
Grammars, Grammars, Everywhere • Chomsky again: Transformational grammar maps from surface structure to deep structure • ATN grammars: Rules are represented in a directed graph • Put it in the lexicon • Lexical functional grammar • Categorial grammar CS251: Intro to AI/Lisp II
Semantic Grammars • Avast ye scurvy dogs, throw the syntax overboard CS251: Intro to AI/Lisp II
Parsing for Fun & Profit CS251: Intro to AI/Lisp II
Parsing from the Top-Down • Start with S, and expand from there • State of the parse • Symbol list is a list of symbols that have resulted from the set of operations applied so far • Use a lexicon cried: V dogs: N, V the: ART CS251: Intro to AI/Lisp II
Revised State • State of parse is now a pair • Symbol list • Position in sentence 1 The 2 cats 3 howled 4 CS251: Intro to AI/Lisp II
A Top-Down Parser • Possibilities list: List of possible states • Current state is the car • Backup states are the cdr • (((N) 2) ((NAME) 1) ((ADJ N) 1)) CS251: Intro to AI/Lisp II
Top-Down Algorithm • 1) Select current state, say C, with car(Possibilities), if C is nil, fail • 2) If C is an empty symbol list and word position is at end, succeed, else: • Generate next possible states: • a) If first symbol on C’s symbol list is a lexical symbol and next word in sentence can be that class then create a new state by removing first symbol and update word position, add it to the possibilities list • b) Not a lexical symbol, then generate a new state for each applicable rule in the grammar and add them all to the possibilities list • Start with initial state ((S) 1) and no backup states CS251: Intro to AI/Lisp II
Parsing is Search • Initial state • Operators • Goal • States • Path cost? CS251: Intro to AI/Lisp II
Depth-first & Breadth-first • Depth-first • Left recursive rules • Breadth-first CS251: Intro to AI/Lisp II
Bottom-up Parsing • Group strings and match them to rules • State would be a symbol list • Start with all the words in the sentence • Successor states • Rewrite a word with lexical categories • Replace RHS sequence by its LHS symbol CS251: Intro to AI/Lisp II
Bottom-up Trouble Have the students in Section 1 of CS 251 take a pop midterm. Have the students in Section 1 of CS 251 taken a pop midterm? CS251: Intro to AI/Lisp II
Keep a Chart • Chart is just a data structure • Track matches in terms of keys • Look for rules that either start with a key, or • Earlier rules that need the key in the current position • What’s on the chart? • All constituents derived from the sentence so far in the parse • Partial matches: Active arcs CS251: Intro to AI/Lisp II
Chart Parsing • Combine an active ac with a completed constituent • Agenda is a list of newly completed constituents CS251: Intro to AI/Lisp II
Chart-Parse (defun chart-parse (words &optional (*grammar* *grammar*)) "See if the string of words can be parsed by the grammar." (let ((chart (make-chart :ends-at (make-array (+ 1 (length words)) :initial-element nil)))) (add-edge (edge 0 0 'S* nil (list (grammar-start-symbol *grammar*))) chart 'initializer) (for v = 0 to (- (length words) 1) do (scanner v (elt words v) chart)) chart)) CS251: Intro to AI/Lisp II
Scanner (defun scanner (j word chart) "Add edges everywhere WORD is expected." (for each cat in (categories-for word *grammar*) do (dprint "scanner:" cat (elt (chart-ends-at chart) j)) (when (member cat (elt (chart-ends-at chart) j) :test #'unify :key #'edge-expects) (add-edge (edge j (+ j 1) cat (list word) nil) chart 'scanner)))) CS251: Intro to AI/Lisp II
Predictor (defun predictor (edge chart) "Add edges saying what we expect to see here." (for each rule in (rewrites-for (op (edge-expects edge)) *grammar*) do (add-edge (edge (edge-end edge) (edge-end edge) (rule-lhs rule) nil (rule-rhs rule)) chart 'predictor))) CS251: Intro to AI/Lisp II
Completer (defun completer (edge chart) "Use this edge to extend any edges in the chart." (for each old-edge in (elt (chart-ends-at chart) (edge-start edge)) do (let ((b (unify (edge-lhs edge) (edge-expects old-edge) (edge-bindings old-edge)))) (when b (add-edge (edge (edge-start old-edge) (edge-end edge) (edge-lhs old-edge) (cons edge (edge-found old-edge)) (rest (edge-remains old-edge)) b) chart 'completer))))) CS251: Intro to AI/Lisp II
Add-Edge (defun add-edge (edge chart &optional reason) "Put edge into chart, and complete or predict as appropriate." (unless (member edge (elt (chart-ends-at chart) (edge-end edge)) :test #'edge-equal) (when (handle-augmentation *grammar* edge) (push edge (elt (chart-ends-at chart) (edge-end edge))) (dprint reason edge);; debugging output (as in ;; Figure 23.4, [p 700]) (if (complete? edge) (completer edge chart) (predictor edge chart))))) CS251: Intro to AI/Lisp II