LING 581: Advanced Computational Linguistics

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Proceedings of the Conference on Intelligent Text Processing and Computational Linguistics (CICLing-2007) Learning for Semantic Parsing Advisor: Hsin-His.
LING 581: Advanced Computational Linguistics Lecture Notes April 23rd.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING 581: Advanced Computational Linguistics Lecture Notes May 5th.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
Compiler Principles Winter Compiler Principles Exercises on scanning & top-down parsing Roman Manevich Ben-Gurion University.
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 10: Compiler I: Syntax Analysis slide 1www.idc.ac.il/tecs.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
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 581: Advanced Computational Linguistics Lecture Notes April 16th.
LING 388: Language and Computers Sandiway Fong Lecture 7.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification.
AN IMPLEMENTATION OF A REGULAR EXPRESSION PARSER
10/13/2015IT 3271 Tow kinds of predictive parsers: Bottom-Up: The syntax tree is built up from the leaves Example: LR(1) parser Top-Down The syntax tree.
Understanding Natural Language
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 6, 10/02/2003 Prof. Roy Levow.
1 Lecture 5: Syntax Analysis (Section 2.2) CSCI 431 Programming Languages Fall 2002 A modification of slides developed by Felix Hernandez-Campos at UNC.
Top Down Parsing - Part I Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Semantically Processing The Semantic Web Presented by: Kunal Patel Dr. Gopal Gupta UNIVERSITY OF TEXAS AT DALLAS.
CPS 506 Comparative Programming Languages Syntax Specification.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Semantics Day 38 LING Computational Linguistics Harry Howard Tulane University.
For Friday Finish chapter 23 Homework –Chapter 23, exercise 15.
Top-down Parsing lecture slides from C OMP 412 Rice University Houston, Texas, Fall 2001.
Parsing — Part II (Top-down parsing, left-recursion removal) Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students.
 Fall Chart 2  Translators and Compilers  Textbook o Programming Language Processors in Java, Authors: David A. Watts & Deryck F. Brown, 2000,
Programming Languages and Design Lecture 2 Syntax Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Overview of Previous Lesson(s) Over View 3 Model of a Compiler Front End.
1 Programming Languages (CS 550) Lecture 2 Summary Mini Language Interpreter Jeremy R. Johnson.
CMSC 330: Organization of Programming Languages Operational Semantics.
Parser: CFG, BNF Backus-Naur Form is notational variant of Context Free Grammar. Invented to specify syntax of ALGOL in late 1950’s Uses ::= to indicate.
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
ADTS, GRAMMARS, PARSING, TREE TRAVERSALS Lecture 13 CS2110 – Spring
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
Compiler Construction Lecture Five: Parsing - Part Two CSC 2103: Compiler Construction Lecture Five: Parsing - Part Two Joyce Nakatumba-Nabende 1.
CS 2130 Lecture 18 Bottom-Up Parsing or Shift-Reduce Parsing Warning: The precedence table given for the Wff grammar is in error.
LING 581: Advanced Computational Linguistics Lecture Notes May 4th.
Introduction to Parsing
Comp 411 Principles of Programming Languages Lecture 3 Parsing
Announcements/Reading
LING 581: Advanced Computational Linguistics
Programming Languages Translator
CS510 Compiler Lecture 4.
More on Lambda Calculus
Natural Language Processing
Parsing with Context Free Grammars
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING 581: Advanced Computational Linguistics
Mini Language Interpreter Programming Languages (CS 550)
ENERGY 211 / CME 211 Lecture 15 October 22, 2008.
ADTs, Grammars, Parsing, Tree traversals
Lecture 7: Introduction to Parsing (Syntax Analysis)
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Introduction to Parsing
Introduction to Parsing
High-Level Programming Language
Chapter 10: Compilers and Language Translation
COP4020 Programming Languages
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

LING 581: Advanced Computational Linguistics Lecture Notes April 19th

Semantic Grammars Use slides from course LING 324 – Introduction to Semantics Simon Frasier University, Prof. F.J. Pelletier http://www.sfu.ca/~jeffpell/Ling324/fjpSlides4.pdf we’re computational linguists, so we’re going to implement the slides

Syntax fjpSlides4.pdf Slide 3

Syntax We already know how to build Prolog grammars See executive summary http://www.swi- prolog.org/pldoc/doc_for?object=section(2,'4.12',swi('/doc/Manual/DCG.html'))

Syntax Step 1: let’s build the simplest possible Prolog grammar for this fjpSlides4.pdf Slide 4

Simplest possible grammar psg1.pl Excluding (2b) from previous slide for the time being … Examples (3), (4) and (5) from two slides back

Syntax Step 2: let’s add the parse tree component to our grammar … Recall: grammar rules can have extra arguments: Parse tree Implement agreement etc.

Syntax Note: on handling left recursion in Prolog grammar rules techniques: use a bottom-up parser rewrite grammar (left recursive -> right recursive – last semester) or use lookahead (today’s lecture) lookahead is a dummy nonterminal that does not contribute to the parse, it is a “guard” that prevents rule from firing unless appropriate lookahead succeeds if it can find a conjunction in the input and marks it (so it can’t find it twice)

Grammar: version 2 psg2.pl

Grammar: version 2

Grammar: version 2 Examples (3), (4) and (5) again from slide 9

Grammar: version 2 Examples (6) and (7) from slide 9 Just syntax, but we'll need to produce a semantic parse (instead)

Semantics We want to obtain a semantic parse for our sentences that we can “run” (i.e. evaluate) against the Prolog database (i.e. situation or possible world). So the semantic parse output should be valid Prolog code (that we can directly call) Prolog language support we'll need: call(Goal) Goal is any query we type at the command line member(X,List) setof(V,Goal,Set) Set is implemented as a list

setof/3 See Prolog built-in: http://www.swi- prolog.org/pldoc/doc_for?object=section(2,'4.29',swi('/doc/Manual/allsolutions.html')) Prolog built-in:

setof/3 Example:

member/2 See http://www.swi-prolog.org/pldoc/man?predicate=member%2F2

Semantics fjpSlides4.pdf Slide 7

Semantics fjpSlides4.pdf Slide 8

Semantics fjpSlides4.pdf Slide 9

Semantics fjpSlides4.pdf Slide 10

Semantics: Implementation Desired implementation: The extra argument returns a Prolog query X that can be evaluated against the current database (situation) Note: we are bypassing the (explicit) construction of the syntax tree Imagine if the Penn Treebank was labeled using a semantic representation

Semantics: Implementation Let’s write the semantic grammar to handle “Jack is hungry” first, let’s introduce a bit of notation (lambda calculus) λ = function λx.x+1 denotes a function that takes an argument x and computes value x+1 (a period separates the argument from the function body) (λx.x+1)(5) means apply 5 to the lambda function substitute 5 in place of x and evaluate answer = 6

Semantics: Implementation Syntax: setof(X,hungry(X),S), member(jack,S) jack setof(X,hungry(X),S)

Semantics: Implementation Semantic grammar:

Semantics: Implementation Semantic grammar: Two possible worlds

Semantics: Implementation More examples of computation: fjpSlides4.pdf Slide 10

Semantics: Implementation More examples of computation:

Semantics: Implementation More examples of computation:

Semantics fjpSlides4.pdf Slide 11

Semantics: Implementation Scope of negation: wide or narrow narrow wide

Grammar: revised sg2.pl