1 / 39

LING 581: Advanced Computational Linguistics

LING 581: Advanced Computational Linguistics. Lecture Notes May 1 st. Administrivia. Today: R eport from Kristen on your data Semantic grammars contd. (No homework). Semantic Grammars. Using slides from course LING 324 – Introduction to Semantics

zona
Download Presentation

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 May 1st

  2. Administrivia • Today: • Report from Kristen on your data • Semantic grammars contd. • (No homework)

  3. Semantic Grammars • Using slides from course • LING 324 – Introduction to Semantics • Simon Frasier University, Prof. F.J. Pelletier • http://www.sfu.ca/~jeffpell/Ling324/fjpSlides4.pdf

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

  5. Grammar: syntax Syntax

  6. Grammar: syntax

  7. Grammar: syntax Examples from 3 slides ago

  8. Grammar: syntax

  9. 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 will be a Prolog goal • Used two predicates: • member(X,Set) • setof(X,p(..X..),Set) • Sets are represented by Prolog lists

  10. Semantics • fjpSlides4.pdf • Slide 7

  11. Semantics • fjpSlides4.pdf • Slide 8

  12. Semantics • fjpSlides4.pdf • Slide 9

  13. Semantics • fjpSlides4.pdf • Slide 10

  14. Semantics: Implementation • Desired implementation: The extra argument (X) is 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

  15. Semantics: Implementation Examples of computation: • fjpSlides4.pdf • Slide 10

  16. Semantics • fjpSlides4.pdf • Slide 11

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

  18. Grammar: semantics

  19. Grammar: semantics

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

  21. There is so much more • But alas, we are almost out of time…

  22. Quantifiers • Example: • every baby walks • for all individuals X, baby(X) -> walks(X) more formally • [NP every baby] [VP walks] • λP.[∀X.[baby(X) -> P(X)]](walks) • ∀X.[baby(X) ->walks(X)] • how do we define the expression every_baby(P)? • (Montague-style) • every_baby(P) is shorthand for • for all individuals X, baby(X) -> P(X) • -> : if-then (implication : logic symbol) • written another way (lambda calculus-style): • λP.[∀X.[baby(X) -> P(X)]] • ∀: for all (universal quantifier: logic symbol)

  23. Quantifiers • how do we define this Prolog-style? • Example: • every baby walks • [NP every baby] [VP walks] • λP.[∀X (baby(X) -> P(X))](walks) • ∀X (baby(X) ->walks(X)) • Possible World (Prolog database, defined in a file): • :- dynamic baby/1. (allows us to modify the baby database online) • baby(a). baby(b). • walks(a). walks(b). walks(c). • individual(a). individual(b). individual(c). • What kind of query would you write? • One Possible Query (every means there are no exceptions): • ?- \+ (baby(X), \+ walks(X)). (NOTE: may need a space between \+ and ( here) • Yes (TRUE) • ?- baby(X), \+ walks(X). • No • ?- assert(baby(d)). • ?- baby(X), \+ walks(X). • X = d ; • Yes Using no exception idea that ∀X P(X) is the same as ¬∃X ¬P(X) ∃= “there exists” (quantifier) (implicitly: all Prolog variables are existentially quantified variables)

  24. Recall: Truth Tables • De Morgan’s Rule • ¬(P∨Q) = ¬P∧¬Q ¬(PvQ)=T only when both P and Q are F Hence, ¬(PvQ) is equivalent to ¬P∧¬Q ¬P∧¬Q=T only when both P and Q are F

  25. Conversion into Prolog Note: \+ (baby(X), \+walks(X)) is Prolog for ∀X (baby(X) -> walks(X)) Steps: • ∀X (baby(X) -> walks(X)) • ∀X (¬baby(X) v walks(X)) • (since P->Q = ¬PvQ, see truth table) • ¬∃X ¬ (¬baby(X) v walks(X)) • (since ∀X P(X) = ¬∃X ¬P(X), no exception idea) • ¬∃X (baby(X) ∧¬walks(X)) • (by De Morgan’s rule, see truth table from last slide) • ¬(baby(X) ∧¬walks(X)) • (can drop ∃X since all Prolog variables are basically existentially quantified variables) • \+ (baby(X) ∧ \+walks(X)) • (\+ = Prolog negation symbol) • \+ (baby(X), \+walks(X)) • (, = Prolog conjunction symbol)

  26. Quantifiers • how do we define this Prolog-style? • Example: • every baby walks • [NP every baby] [VP walks] • λP.[∀X.[baby(X) -> P(X)]](walks) • ∀X.[baby(X) ->walks(X)] • Another situation (Prolog database): • :- dynamic baby/1. • :- dynamic walks/1. • Does ?- \+ (baby(X), \+ walks(X)). still work? • Yes because • ?- baby(X), \+ walks(X). • No • cannot be satisfied

  27. Quantifiers • how do we define the expression every_baby(P)? • (Montague-style) • every_baby(P) is shorthand for • λP.[∀X.baby(X) -> P(X)] • (Barwise & Cooper-style) • think directly in terms of sets • leads to another way of expressing the Prolog query • Example: every baby walks • {X: baby(X)} set of all X such that baby(X) is true • {X: walks(X)} set of all X such that walks(X) is true • Subset relation (⊆) • {X: baby(X)} ⊆{X: walks(X)} the “baby” set must be a subset of the “walks” set

  28. Quantifiers (Barwise & Cooper-style) • think directly in terms of sets • leads to another way of expressing the Prolog query • Example: every baby walks • {X: baby(X)} ⊆{X: walks(X)} the “baby” set must be a subset of the “walks” set • How to express this as a Prolog query? • Queries: • ?-setof(X,baby(X),L1). L1 is the set of all babies in the database • ?-setof(X,walks(X),L2). L2 is the set of all individuals who walk Need a Prolog definition of the subset relation. This one, for example: subset([],_). subset([X|L1],L2) :- member(X,L2), subset(L1,L2). member(X,[X|_]). member(X,[_|L]) :- member(X,L).

  29. True for world: • baby(a). baby(b). • walks(a). walks(b). walks(c). L1 = [a,b] L2 = [a,b,c] ?- subset(L1,L2) is true • False for world: • baby(a). baby(b). baby(d). • walks(a). walks(b). walks(c). L1 = [a,b,d] L2 = [a,b,c] ?- subset(L1,L2) is false Quantifiers • Example: every baby walks • {X: baby(X)} ⊆ {X: walks(X)} the “baby” set must be a subset of the “walks” set • Assume the following definitions are part of the database: subset([],_). subset([X|_ ],L) :- member(X,L). member(X,[X|_ ]). member(X,[ _|L]) :- member(X,L). • Prolog Query: • ?-setof(X,baby(X),L1), setof(X,walks(X),L2), subset(L1,L2).

  30. Quantifiers • Example: every baby walks • (Montague-style) ∀X (baby(X) -> walks(X)) • (Barwise & Cooper-style) {X: baby(X)} ⊆ {X: walks(X)} • how do we define every_baby(P)? • (Montague-style)λP.[∀X (baby(X) -> P(X))] • (Barwise & Cooper-style) {X: baby(X)} ⊆ {X: P(X)} • how do we define every? • (Montague-style) λP1.[λP2.[∀X (P1(X) -> P2(X))]] • (Barwise & Cooper-style) {X: P1(X)} ⊆ {X: P2(X)}

  31. Quantifiers • how do we define the expression every? • (Montague-style) λP1.[λP2.[∀X (P1(X) -> P2(X))]] • Let’s look at computation in the lambda calculus... • Example: every man likes John • WordExpression • every λP1.[λP2.[∀X (P1(X) -> P2(X))]] • man man • likes λY.[λX.[ X likes Y]] • John John • Syntax: [S [NP [Q every][N man]][VP [V likes][NP John]]]

  32. Quantifiers • Example: [S [NP [Q every][N man]][VP [V likes][NP John]]] • WordExpression • every λP1.[λP2.[∀X (P1(X) -> P2(X))]] • man man • likes λY.[λX.[ X likes Y]] • John John • Logic steps: • [Q every][N man]] λP1.[λP2.[∀X (P1(X) -> P2(X))]](man) • [Q every][N man]] λP2.[∀X (man(X) -> P2(X))] • [VP [V likes][NP John]] λY.[λX.[ X likes Y]](John) • [VP [V likes][NP John]] λX.[ X likes John] • [S [NP [Q every][N man]][VP [V likes][NP John]]] • λP2.[∀X (man(X) -> P2(X))](λX.[ X likes John]) • ∀X (man(X) -> λX.[ X likes John](X)) • ∀X (man(X) -> [ X likes John])

  33. Quantifiers: Montague-style Previous slide: • Syntax: [S [NP [Q every][N man]][VP [V likes][NP John]]] • Semantics: ∀X (man(X) -> [ X likes John]) • Semantics (Prolog): \+ (man(X), \+likes(X,john))

  34. Generalized Quantifiers Part 2: Barwise-Cooper-style • Syntax: [S [NP [Q every][N man]][VP [V likes][NP John]]] • Semantics: {X: man(X)} ⊆ {X: likes(X,John)} • Prolog : setof(X,man(X),S1), setof(X,likes(X,john),S1), subset(S1,S2).

  35. Other Quantifiers • Other quantifiers can also be expressed using set relations between two predicates: Example: no: {X: P1(X)} ∩ {Y: P2(Y)} = ∅ ∩ = set intersection ∅ = empty set no man smokes {X: man(X)} ∩ {Y: smokes(Y)} = ∅ should evaluate to true for all possible worlds where there is no overlap between men and smokers men smokers

  36. Other Quantifiers • Other quantifiers can also be expressed using set relations between two predicates: Example: some: {X: P1(X)} ∩ {Y: P2(Y)} ≠∅ ∩ = set intersection ∅ = empty set some men smoke {X: man(X)} ∩ {Y: smokes(Y)} ≠ ∅ men smokers

  37. we’ve mentioned that names directly refer here is another idea… Conjunction X and Y both X and Y have to be of the same type in particular, semantically... we want them to have the same semantic type what is the semantic type of every baby? Example every baby and John likes ice cream [NP[NP every baby] and [NP John]] likes ice cream every baby likes ice cream {X: baby(X)} ⊆ {Y: likes(Y,ice_cream)} John likes ice cream ??? ⊆ {Y: likes(Y,ice_cream)} John ∈ {Y: likes(Y,ice_cream)} want everything to be a set (to be consistent) i.e. want to state something like ({X: baby(X)} ∪{X: john(X)}) ⊆ {Y: likes(Y,ice_cream)} note: set union (∪) is the translation of “and” Names as Generalized Quantifiers

  38. animal dog Keeshond Downwards and Upwards Entailment (DE & UE) • Quantifier every has semantics • {X: P1(X)} ⊆ {Y: P2(Y)} • e.g. every woman likes ice cream • {X: woman(X)} ⊆ {Y:likes(Y,ice_cream)} • Every is DE for P1 and UE for P2 • Examples: • (25) a. Every dog barks • b. Every Keeshond barks (valid) • c. Every animal barks (invalid) • semantically, “Keeshond” is a sub-property or subset with respect to the set “dog” animal dog Keeshond

  39. make noise barks barks loudly Downwards and Upwards Entailment (DE & UE) • Quantifier every has semantics • {X: P1(X)} ⊆ {Y: P2(Y)} • e.g. every woman likes ice cream • {X: woman(X)} ⊆ {Y:likes(Y,ice_cream)} • Every is DE for P1 and UE for P2 • Examples: • (25) a. Every dog barks • d. Every dog barks loudly (invalid) • c. Every dog makes noise (valid) • semantically, “barks loudly” is a subset with respect to the set “barks”, which (in turn) is a subset of the set “makes noise” make noise barks loud

More Related