LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11.

Slides:



Advertisements
Similar presentations
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/5.
Advertisements

LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
For Monday Read Chapter 23, sections 3-4 Homework –Chapter 23, exercises 1, 6, 14, 19 –Do them in order. Do NOT read ahead.
LING 581: Advanced Computational Linguistics Lecture Notes April 23rd.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/22.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 3: 8/28.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/21.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/18.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/25.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
LING 388 Language and Computers Lecture 10 10/2/03 Sandiway FONG.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/5.
LING 388: Language and Computers Sandiway Fong Lecture 17: 10/25.
LING/C SC/PSYC 438/538 Midterm 10/11. Instructions It is recommended that you attempt all questions –Submit your answers in one file by to
LING 388: Language and Computers Sandiway Fong Lecture 10: 9/26.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
LING 388 Language and Computers Lecture 9 9/30/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 8.
LING 388: Language and Computers Sandiway Fong 10/4 Lecture 12.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
LING 388: Language and Computers Sandiway Fong Lecture 11.
Grammars and Parsing. Sentence  Noun Verb Noun Noun  boys Noun  girls Noun  dogs Verb  like Verb  see Grammars Grammar: set of rules for generating.
Syntax Directed Translation. Syntax directed translation Yacc can do a simple kind of syntax directed translation from an input sentence to C code We.
LING 388: Language and Computers Sandiway Fong Lecture 17.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
LING 388: Language and Computers Sandiway Fong Lecture 7.
LING/C SC/PSYC 438/538 Lecture 14 Sandiway Fong. Administrivia Midterm – This Wednesday – A bit like doing a homework in real time – Bring your laptop.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 4: 8/30.
LING 388: Language and Computers Sandiway Fong Lecture 30 12/8.
Syntax Analysis The recognition problem: given a grammar G and a string w, is w  L(G)? The parsing problem: if G is a grammar and w  L(G), how can w.
LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/15.
LING/C SC/PSYC 438/538 Lecture 26 Sandiway Fong. Administrivia 538 Presentations – Send me your choices if you haven’t already Thanksgiving Holiday –
LING/C SC/PSYC 438/538 Lecture 12 10/4 Sandiway Fong.
LING 388: Language and Computers Sandiway Fong Lecture 12.
CPS 506 Comparative Programming Languages Syntax Specification.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong. Administrivia Reading Homework – Chapter 3 of JM: Words and Transducers.
Recursive Descent Parsers Lecture 6 Mon, Feb 2, 2004.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Chapter 3 Context-Free Grammars and Parsing. The Parsing Process sequence of tokens syntax tree parser Duties of parser: Determine correct syntax Build.
Top-down Parsing Recursive Descent & LL(1) Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Top-Down Parsing CS 671 January 29, CS 671 – Spring Where Are We? Source code: if (b==0) a = “Hi”; Token Stream: if (b == 0) a = “Hi”; Abstract.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong 1.
LING/C SC/PSYC 438/538 Lecture 18 Sandiway Fong. Adminstrivia Homework 7 out today – due Saturday by midnight.
LING/C SC/PSYC 438/538 Lecture 16 Sandiway Fong. SWI Prolog Grammar rules are translated when the program is loaded into Prolog rules. Solves the mystery.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
LING/C SC/PSYC 438/538 Online Lecture 7 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong. Last Time Talked about: – 1. Declarative (logical) reading of grammar rules – 2. Prolog query: s(String,[]).
Lecture 17: Theory of Automata:2014 Context Free Grammars.
Parsing and Parser Parsing methods: top-down & bottom-up
Top-Down Parsing.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
LING 581: Advanced Computational Linguistics
LING/C SC/PSYC 438/538 Lecture 23 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 25 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 26 Sandiway Fong.
Presentation transcript:

LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11

Administrivia Reminder: –this Thursday –change of venue –instead of class here, please attend the Master’s Seminar at 5pm –presented by the Cognitive Science Program –Speech, Language and Hearing Sciences Building, Rm. 205 –I’ll be giving a research talk (accessible to non- specialists) on treebanks and statistical natural language parsers

Today’s Topics Homework 1 review DCG rules and left vs. right recursion recap adding parse tree output to DCG rules

Homework 1 Review

Question 1: Using Perl and wsj2000.txt –What is the maximum number of consonants occurring in a row within a word? –How many words are there with that maximum number? –List those words –Give your Perl program

Homework 1 Review Question 2: Using your Perl program for Question 1 –modify your Perl program to report the sentence number as well as the word encountered in Question 1 –submit your modified program Example: –676 Pennsylvania –means on line number 676 the word Pennsylvania occurs

Homework 1 Review Question 3: (optional 438/mandatory 538) using Perl and wsj2000.txt –find the words with the longest palindrome sequence of letters as a substring –give your Perl code Example: common has a palindrome sequence of length 2: ommo

Regular Grammars: recap right recursive regular grammar: s --> [b], ays. ays --> [a], a. a --> [a], exclam. a --> [a], a. exclam --> [!]. language: Sheeptalk –baa! –baaa! –ba...a! left recursive regular grammar: s --> a, [!]. a --> firsta, [a]. a --> a, [a]. firsta --> b, [a]. b --> [b]. ?- s([b,a,a,!],[]). Yes ?- s([b,a,!],[]). No ?- s([b,a,a,!],[]). Yes ?- s([b,a,!],[]). Infinite loop

Regular Grammars: recap left recursive regular grammar: s --> a, [!]. a --> firsta, [a]. a --> a, [a]. firsta --> b, [a]. b --> [b]. given Prolog left-to-right, depth-first evaluation strategy: ?- s([b,a,!],[]). enters an infinite loop derivation tree: s a firsta b b a a s a a b b a s a a a b b a mismatch with input

Regular Grammars: recap left recursive regular grammar: s --> a, [!]. a --> firsta, [a]. a --> a, [a]. firsta --> b, [a]. b --> [b]. no re-ordering of the grammar rules will prevent Prolog from looping re-ordered: s --> a, [!]. a --> a, [a]. a --> firsta, [a]. firsta --> b, [a]. b --> [b]. makes things worse! this DCG will make Prolog loop even on grammatical input

Extra Argument: Parse Tree Recovering a parse tree –when want Prolog to return more than just Yes/No answers –in case of Yes, we can compute a syntax tree representation of the parse –by adding an extra argument to nonterminals –applies to all grammar rules (not just regular grammars) Example sheeptalk again DCG: s --> [b], [a], a, [!]. a --> [a]. (base case) a --> [a], a. (recursive case) s a! a a a a b

Extra Argument: Parse Tree Tree: Prolog data structure: –term –hierarchical –allows sequencing of arguments –functor(arg 1,..,arg n ) –each arg i could be another term or simple atom s a! a a a a b s(b,a,a(a,a(a)),!)

Extra Arguments: Parse Tree DCG –s --> [b],[a], a, [!]. –a --> [a]. (base case) –a --> [a], a. (right recursive case) base case –a --> [a]. –a(subtree) --> [a]. –a(a(a)) --> [a]. recursive case –a --> [a], a. –a(subtree) --> [a], a(subtree). –a(a(a,A)) --> [a], a(A). s a! a a a a b s(b,a,a(a,a(a)),!) Idea: for each nonterminal, add an argument to store its subtree

Extra Arguments: Parse Tree Prolog grammar –s --> [b], [a], a, [!]. –a --> [a]. (base case) –a --> [a], a. (right recursive case) base and recursive cases –a(a(a)) --> [a]. –a(a(a,A)) --> [a], a(A). start symbol case –s --> [b], [a], a, [!]. –s(tree) --> [b], a(subtree), [!]. –s(s(b,a,A,!) ) --> [b], [a], a(A), [!]. s a! a a a a b s(b,a,a(a,a(a)),!)

Extra Arguments: Parse Tree Prolog grammar –s --> [b], [a], a, [!]. –a --> [a]. (base case) –a --> [a], a. (right recursive case) Prolog grammar computing a parse –s(s(b,a,A,!)) --> [b], [a], a(A), [!]. –a(a(a)) --> [a]. –a(a(a,A)) --> [a], a(A).

Class Exercise Augment the right recursive regular grammar for Sheeptalk to return a parse tree ?- s(Tree,[b,a,a,!],[]). DCG: s --> [b], ays. ays --> [a], a. a --> [a], exclam. a --> [a], a. exclam --> [!].