Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 581: Advanced Computational Linguistics

Similar presentations


Presentation on theme: "LING 581: Advanced Computational Linguistics"— Presentation transcript:

1 LING 581: Advanced Computational Linguistics
Lecture Notes April 19th

2 Semantic Grammars Use slides from course
LING 324 – Introduction to Semantics Simon Frasier University, Prof. F.J. Pelletier we’re computational linguists, so we’re going to implement the slides

3 Syntax fjpSlides4.pdf Slide 3

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

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

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

7 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.

8 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)

9 Grammar: version 2 psg2.pl

10 Grammar: version 2

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

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

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 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

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

15 setof/3 Example:

16 member/2 See

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 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

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
Syntax: setof(X,hungry(X),S), member(jack,S) jack setof(X,hungry(X),S)

24 Semantics: Implementation
Semantic grammar:

25 Semantics: Implementation
Semantic grammar: Two possible worlds

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: revised sg2.pl 


Download ppt "LING 581: Advanced Computational Linguistics"

Similar presentations


Ads by Google