1 / 37

LING 581: Advanced Computational Linguistics

LING 581: Advanced Computational Linguistics. Lecture Notes April 24th. Administrivia. Today: Interim report from Kristen TCEs Semantic grammars. Semantics. Last time: To get computers to understand sentences, m odel the world,

mendel
Télécharger la présentation

LING 581: Advanced Computational Linguistics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LING 581: Advanced Computational Linguistics Lecture Notes April 24th

  2. Administrivia • Today: • Interim report from Kristen • TCEs • Semantic grammars

  3. Semantics • Last time: • To getcomputers to understand sentences, • model the world, • compute truth conditions, truth values, entailments, presuppositions, tautologies, etc. • propositional logic in Prolog, truth tables • Turing testand Searle’s Chinese room experiment

  4. Propositional Logic Program: plogic3.pl

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

  6. Syntax • fjpSlides4.pdf • Slide 3

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

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

  9. Simplest possible grammar g1.pl Excluding (2b) for the time being

  10. Simplest possible grammar Examples (3), (4) and (5) from two slides back

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

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

  13. Grammar: version 2 g2.pl

  14. Grammar: version 2

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

  16. Grammar: version 2 Examples (6) and (7) from slide 9

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

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

  19. setof/3 • Example:

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

  21. Semantics • fjpSlides4.pdf • Slide 7

  22. Semantics • fjpSlides4.pdf • Slide 8

  23. Semantics • fjpSlides4.pdf • Slide 9

  24. Semantics • fjpSlides4.pdf • Slide 10

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

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

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

  28. Semantics: Implementation • Semantic grammar:

  29. Semantics: Implementation • Semantic grammar:

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

  31. Semantics: Implementation • More examples of computation:

  32. Semantics: Implementation • More examples of computation:

  33. Semantics • fjpSlides4.pdf • Slide 11

  34. Semantics: Implementation • Scope of negation: wide or narrow narrow wide

  35. Grammar: version 3 g3.pl

  36. Grammar: version 3

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

More Related