LING 364: Introduction to Formal Semantics Lecture 5 January 26th.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

Prolog programming....Dr.Yasser Nada. Chapter 8 Parsing in Prolog Taif University Fall 2010 Dr. Yasser Ahmed nada prolog programming....Dr.Yasser Nada.
CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.
LING 364: Introduction to Formal Semantics Lecture 24 April 13th.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
Grammars, constituency and order A grammar describes the legal strings of a language in terms of constituency and order. For example, a grammar for a fragment.
1 Grammars and Parsing Allen ’ s Chapters 3, Jurafski & Martin ’ s Chapters 8-9.
LING 364: Introduction to Formal Semantics Lecture 8 February 7th.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING 364: Introduction to Formal Semantics Lecture 10 February 14th.
LING 364: Introduction to Formal Semantics Lecture 9 February 9th.
LING 364: Introduction to Formal Semantics
LING 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 364: Introduction to Formal Semantics Lecture 4 January 24th.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 364: Introduction to Formal Semantics Lecture 11 February 16th.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
LING 364: Introduction to Formal Semantics Lecture 7 February 2nd.
LING 364: Introduction to Formal Semantics Lecture 3 January 19th.
LING 388 Language and Computers Lecture 18 10/30/03 Sandiway FONG.
LING 364: Introduction to Formal Semantics Lecture 13 February 23rd.
1 Introduction: syntax and semantics Syntax: a formal description of the structure of programs in a given language. Semantics: a formal description of.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
Chapter 3: Formal Translation Models
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
Context-Free Grammar CSCI-GA.2590 – Lecture 3 Ralph Grishman NYU.
Models of Generative Grammar Smriti Singh. Generative Grammar  A Generative Grammar is a set of formal rules that can generate an infinite set of sentences.
LING 388: Language and Computers Sandiway Fong Lecture 8.
LING 388: Language and Computers Sandiway Fong 10/4 Lecture 12.
Syntax Nuha AlWadaani.
11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin.
Context Free Grammars Reading: Chap 12-13, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
Computing Science, University of Aberdeen1 CS4025: Grammars l Grammars for English l Features l Definite Clause Grammars See J&M Chapter 9 in 1 st ed,
LING 388: Language and Computers Sandiway Fong Lecture 7.
CSI 3120, Grammars, page 1 Language description methods Major topics in this part of the course: –Syntax and semantics –Grammars –Axiomatic semantics (next.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
GRAMMARS David Kauchak CS159 – Fall 2014 some slides adapted from Ray Mooney.
1 Natural Language Processing Lecture Notes 11 Chapter 15 (part 1)
CS Describing Syntax CS 3360 Spring 2012 Sec Adapted from Addison Wesley’s lecture notes (Copyright © 2004 Pearson Addison Wesley)
NLP. Introduction to NLP Is language more than just a “bag of words”? Grammatical rules apply to categories and groups of words, not individual words.
TextBook Concepts of Programming Languages, Robert W. Sebesta, (10th edition), Addison-Wesley Publishing Company CSCI18 - Concepts of Programming languages.
1 Syntax In Text: Chapter 3. 2 Chapter 3: Syntax and Semantics Outline Syntax: Recognizer vs. generator BNF EBNF.
Context Free Grammars Reading: Chap 9, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Rada Mihalcea.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
Syntax Why is the structure of language (syntax) important? How do we represent syntax? What does an example grammar for English look like? What strategies.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
Semantic Construction lecture 2. Semantic Construction Is there a systematic way of constructing semantic representation from a sentence of English? This.
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Rules, Movement, Ambiguity
Chapter 3 Describing Syntax and Semantics
ISBN Chapter 3 Describing Syntax and Semantics.
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Spring 2006-Lecture 2.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Fall 2005-Lecture 3.
Parsing and Code Generation Set 24. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program,
1 Some English Constructions Transformational Framework October 2, 2012 Lecture 7.
GRAMMARS & PARSING. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program, referred to as a.
NLP. Introduction to NLP #include int main() { int n, reverse = 0; printf("Enter a number to reverse\n"); scanf("%d",&n); while (n != 0) { reverse =
7.2 Programming Languages - An Introduction to Informatics WMN Lab. Hye-Jin Lee.
Welcome to the flashcards tool for ‘The Study of Language, 5 th edition’, Chapter 8 This is designed as a simple supplementary resource for this textbook,
Natural Language Processing Vasile Rus
Chapter Eight Syntax.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Chapter Eight Syntax.
David Kauchak CS159 – Spring 2019
Presentation transcript:

LING 364: Introduction to Formal Semantics Lecture 5 January 26th

Administrivia Reminder: –Homework 1 due on tonight (midnight deadline) –questions? ask now Reading Assignment –Chapter 2: Putting a Meaning Together from Pieces

Last Time Translating English into logical meaning Mary is a student who is a student? student(mary). ?- student(X).

Last Time Goal: –formalize language to the degree we can have systems that can understand and answer questions wrt. possible worlds to do this we have to be able to (1)parse, and (2)assign meaning to the English input demo –|: john is a student. –student(john). –|: mary is a student. –student(mary). –|: mary is a baseball fan. –baseball_fan(mary). –|: who is a student and not a baseball fan? –john. –| ?- go. –|: who is a student and a baseball fan? –mary.

Last Time X-bar phrase structure subject: [ I2 [ NP john] I1 ] VP: is a student copula: is complement of VP: [ NP [ DET a][ N1 student]] (predicate NP) Syntax: –A formal grammar enables us to logically break down a sentence into its constituent parts

Syntactic Structure A formal grammar enables us to logically break down a sentence into its constituent parts X-bar phrase structure specifier of CP: [ CP [ NP who] C1 ] head of CP: C: auxiliary verb is subject: [ I2 [ NP trace] I1 ] subject is coindexed [1] with specifier of CP VP: [ V trace] a student verb (trace) is coindexed [2] with is complement of VP: [ NP [ DET a][ N1 student]]

Phrase Structure Rules Simple rules: SBar → S S → NP VP VP → V NP V → is NP → DET N NP → ProperNoun ProperNoun → John DET → a N → student subject object

Phrase Structure Rules Simple rules: SBar → S S → NP VP VP → V NP V → is NP → DET N NP → ProperNoun ProperNoun → John DET → a N → student subject object –John is a [ pred student] –John [ pred likes] Mary –John is [ pred happy] which is the predicate? –V (main verb: likes) –V aux is (copula carries little meaning) –complement of copula is the predicate Note: –gotta be careful –John is the student

Phrase Structure Rules Rules: SBar → WhNoun Aux S WhNoun → who Aux → is S → NPtrace VP NPtrace →ε VP → Vtrace NP Vtrace →ε NP → DET N DET → a N → student empty subject object plus associations by coindexation between traces and contentful items

Today’s Topics 1.What is a formal grammar? 2.Prolog’s notation for formal grammars –Definite Clause Grammars 3.Discussion of Putting a Meaning Together from Pieces 4.Short Quiz

What is a formal grammar? example NP = Noun Phrase VP = Verb Phrase example –Sentence → NP VP –VP → Verb NP –Verb → took –NP → the man –NP → the book production (or grammar) rule format –LHS → RHS LHS = Left Hand Side → = “expands to” or “rewrites to” RHS = Right Hand Side

What is a formal grammar? example –Sentence → NP VP –VP → Verb NP –Verb → took –NP → the man –NP → the book derivation –top-down (one of many) 1.Sentence 2.NP VP 3.NP Verb NP 4.NP took NP 5.the man took NP 6.the man took the book derivation –top-down (alternative) 1.Sentence 2.NP VP 3.the man VP 4.the man Verb NP 5.the man took NP 6.the man took the book

What is a formal grammar? example –Sentence → NP VP –VP → Verb NP –Verb → took –NP → the man –NP → the book derivation –bottom-up (one of many) 1.the man took the book 2.NP took the book 3.NP Verb the book 4.NP Verb NP 5.NP VP 6.Sentence derivation –bottom-up (alternative) 1.the man took the book 2.the man took NP 3.the man Verb NP 4.the man VP 5.NP VP 6.Sentence

What is a formal grammar? example –Sentence → NP VP –VP → Verb NP –Verb → took –NP → the man –NP → the book this grammar can generate more than one sentence examples –the man took the book –#the book took the man# = semantically odd –other sentences? add new rule –Verb → bought examples –the man took the book –the man bought the book –#the book took the man# = semantically odd –#the book bought the man

What is a formal grammar? example –Sentence → NP VP –VP → Verb NP –Verb → took –NP → the man –NP → the book formally: a grammar contains the following 4 things – a set of non-terminal symbols (N) a set of terminal symbols (T) production rules (P) of the form a designated start symbol (S) example –Non-terminals: {Sentence,VP,NP,Verb} –Terminals: {the,man,book,took} –Start symbol: Sentence –Production rules:set of LHS → RHS rules

Grammar Rules Good news! –Prolog supports grammar rules –it knows how to interpret them (directly) –it can use grammar rules supplied by the user to construct a derivation automatically

Prolog Grammar Rules Prolog’s version of grammar rules: –Definite Clause Grammar (DCG) Prolog ’ s format –terminals and non-terminal symbols begin with lowercase letters e.g. sentence, vp, np, book, took Note: variables begin with an uppercase letter (or underscore) –--> is the rewrite symbol –terminals are enclosed in square brackets to distinguish them from non-terminals (list notation) e.g. [the], [book], [took] –comma (, ) is the concatenation symbol –semicolon ( ; ) is the disjunction symbol –a period (. ) is required at the end of all DCG rules

Prolog Grammar Rules example –Sentence → NP VP –VP → Verb NP –Verb → took –NP → the man –NP → the book Prolog DCG version –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> [the], [man]. –np --> [the], [book]. Important Note –don’t enter these rules into the database using assert/1. –Use a file.

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> [the], [man]. –np --> [the], [book]. query: ?- sentence(S,[]). S = sentence (as a list) [] = empty list i.e. call the start symbol as a predicate and supply two arguments, a list and an empty list

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> [the], [man]. –np --> [the], [book]. example queries ?- sentence([the,man,took,the,book],[]). Yes “the man took the book” is a member of the language generated by the grammar ?- sentence([man,took,the,book],[]). No “man took the book” is not in the grammar “man took the book” is not generated by the grammar

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> [the], [man]. –np --> [the], [book]. other queries ?- sentence([the,man,took,X,book],[]). X = the ?- sentence(S,[]). S = [the, man, took, the, man] ; S = [the, man, took, the, book] ; S = [the, book, took, the, man] ; S = [the, book, took, the, book] ; No

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> [the], [man]. –np --> [the], [book]. notes –np --> [the,man]. OK –np --> [the,book]. OK more grammar det = determiner –np --> det, [man]. –np --> det, [book]. –det --> [the]. –det --> [a].

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> det, [man]. –np --> det, [book]. –det --> [the]. –det --> [a]. query ?- sentence(S,[]). generates 16 different answers for S 2 choices for deta, the 2 choices for head nounman, book total of 4 different choices for NP (a|(the))((man)|(book)) 2 choices for NPas subject, as object total = 4 2 = 16

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> det, [man]. –np --> det, [book]. –det --> [the]. –det --> [a]. query ?- sentence([the,man,took|L],[]). L = [the, man] ; L = [a, man] ; L = [the, book] ; L = [a, book] ; No 4 choices

Prolog Grammar Rules example –sentence --> np, vp. –vp --> verb, np. –verb --> [took]. –np --> det, [man]. –np --> det, [book]. –det --> [the]. –det --> [a]. query ?- sentence([X,man,took,X,book],[]). X = the ; X = a ; No 2 choices

Putting a Meaning Together from Pieces Chapter ties into what we’ve been doing: –driven by syntax –we’re going to compute meaning in parts

Putting a Meaning Together from Pieces 2.2 Incomplete Propositions Shelby barksbarks(shelby). barks???

Putting a Meaning Together from Pieces 2.2 Incomplete Propositions Shelby barksbarks(shelby). barksbarks(X). –predicate –= unsaturated proposition

Putting a Meaning Together from Pieces 2.3 Saturation –Shelby barksbarks(shelby). –barksbarks(X). –Shelbyshelby predication: –relation between predicate barks(X) and its subject shelby –barks is “predicated of” shelby –i.e. barks(X) and X = shelby

Putting a Meaning Together from Pieces 2.4 Compositionality –(discrete) infinity and creativity of language (new phrases) –Principle of Compositionality Meaning(Phrase) = composition of Meaning(SubPart 1 ), Meaning(SubPart 2 ) and so on... –Example: Shelby barks

Putting a Meaning Together from Pieces 2.5 Syntax and Semantics –Principle of Compositionality can be realized in different ways –Theories of Meaning: rule-by-rule theories interpretive theories –Example: What did John sit on? John sat on what(+ Wh-phrase movement)

A different kind of example Think about the meaning of any in: 1.any dog can do that trick 2.I didn’t see any dog 3.*I saw any dog how many meanings does any have? do you see any potential problems for rule- by-rule theories?

A different kind of example Think about the meaning of any in: 1.any dog can do that trick 2.I didn’t see any dog 3.*I saw any dog how many meanings does any have? a)“free choice” any b)negative polarity item (NPI) any

Quiz [5pts] give meaning fragments for: –John –likes Mary –likes –in “John likes Mary” corresponds to likes(john,mary). give syntactic structures for: –who is a student and not a baseball fan? –who is not a baseball fan or a student?