Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 581: Advanced Computational Linguistics Lecture Notes April 23rd.

Similar presentations


Presentation on theme: "LING 581: Advanced Computational Linguistics Lecture Notes April 23rd."— Presentation transcript:

1 LING 581: Advanced Computational Linguistics Lecture Notes April 23rd

2 Last Time Built a Prolog grammar – g.pl on the webpage TCE: – We'll do this first …

3 Truth Conditions and Values Set-theoretic meaning of "and": – The circle is inside the square and the circle is dark – Mary is a student and a baseball fan – Mary and John bought a book

4 Truth Conditions and Values Terms: – synonymous, contradictory, entailment, presupposition, tautology… Prolog: – Conjunctionp, q. – Disjunctionp ; q. – Negation\+ p. – If-Thenp -> q.(not implication) – If-Then-Elsep -> q ; r. – Unificationp = q(not logical equality)

5 Tautologies http://en.wikipedia.org/wiki/Tautology_(logic) Let’s prove the law of contraposition

6 Propositional Logic Program: plogic3.pl

7 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 http://www.sfu.ca/~jeffpell/Ling324/fjpSlides4.pdf Difference is we’re computational linguists… so we’re going to implement the slides We’ll do the syntax part this lecture, and the semantics next time

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

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

10 Syntax Note: on handling left recursion in Prolog grammar rules techniques: 1.use a bottom-up parser 2.rewrite grammar (left recursive -> right recursive) 3.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) 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)

11 Grammar: version 2 g.pl

12 Grammar: version 2

13 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 should be valid Prolog code (that we can call) We’ll need (built-in) member/2 and setof/3 defined in the following 2 slides (a quick review)

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

15 setof/3 Example:

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

17 Semantics fjpSlides4.pdf Slide 7

18 Semantics fjpSlides4.pdf Slide 8

19 Semantics fjpSlides4.pdf Slide 9

20 Semantics fjpSlides4.pdf Slide 10

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

22 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

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

24 Semantics: Implementation Semantic grammar:

25 Semantics: Implementation Semantic grammar:

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

27 Semantics: Implementation More examples of computation:

28 Semantics: Implementation More examples of computation:

29 Semantics fjpSlides4.pdf Slide 11

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

31 Grammar: version 3 g3.pl

32 Grammar: version 3

33 Evaluation Check our computer implementation on… fjpSlides4.pdf Slide 12


Download ppt "LING 581: Advanced Computational Linguistics Lecture Notes April 23rd."

Similar presentations


Ads by Google