More -Calculus Lexical Semantics LING 571 Deep Processing - - PowerPoint PPT Presentation

more calculus lexical semantics
SMART_READER_LITE
LIVE PREVIEW

More -Calculus Lexical Semantics LING 571 Deep Processing - - PowerPoint PPT Presentation

More -Calculus Lexical Semantics LING 571 Deep Processing Techniques for NLP October 30, 2019 Shane Steinert-Threlkeld 1 Announcements HW5: readme: be detailed! What problems you ran into (e.g. agreement), how you solved


slide-1
SLIDE 1

More λ-Calculus
 Lexical Semantics

LING 571 — Deep Processing Techniques for NLP October 30, 2019 Shane Steinert-Threlkeld

1

slide-2
SLIDE 2

Announcements

  • HW5:
  • readme: be detailed!
  • What problems you ran into (e.g. agreement), how you solved them, and

exhibit of the solution

  • HSPG-style subcategorization extra credit: yes, but with max 100 points
  • We will drop your lowest score when calculating final grades. But you still

need to do all the assignments!

2

slide-3
SLIDE 3

Ambiguity of the Week

  • Derivative of an alleged Groucho Marx-ism:
  • In the US, a woman gives birth every fifteen minutes.
  • We must find her and put a stop to it.
  • Thank you scope ambiguity! (Not the same as attachment ambiguity.)

3

slide-4
SLIDE 4

Roadmap

  • More Lambdas
  • Learning Semantic Parsers
  • Lexical Semantics
  • Motivation & Definitions
  • Word Senses
  • Tasks:
  • Word sense disambiguation
  • Word sense similarity
  • Distributional Similarity

4

slide-5
SLIDE 5

Creating Attachments

5

Det → ‘Every’ { λP.λQ.∀x P(x) ⇒ Q(x) } Noun → ‘flight’ { λx.Flight(x) } Verb → ‘arrived’ {λy.∃eArrived(e) ∧ ArrivedThing(e, y)} VP → Verb { Verb.sem } Nom → Noun { Noun.sem } S → NP VP { NP.sem(VP.sem) } NP → Det Nom { Det.sem(Nom.sem) }

“Every flight arrived”

slide-6
SLIDE 6

6

slide-7
SLIDE 7
  • 7

NP → Det.sem(NP.sem) λP.λQ.∀xP(x) ⇒Q(x)(λy.Flight(y)) λQ.∀xλy.Flight(y)(x) ⇒Q(x) λQ.∀xFlight(x) ⇒Q(x)

slide-8
SLIDE 8

8

slide-9
SLIDE 9

9

slide-10
SLIDE 10
  • 10

λQ.∀xFlight(x) ⇒Q(x)(λz.∃eArrived(e) ∧ ArrivedThing(e, z)) ∀xFlight(x) ⇒λz.∃eArrived(e) ∧ ArrivedThing(e, z)(x) ∀xFlight(x) ⇒∃eArrived(e) ∧ ArrivedThing(e, x)

slide-11
SLIDE 11

11

slide-12
SLIDE 12

More λ-Calculus

12

slide-13
SLIDE 13

Target Representations

13

slide-14
SLIDE 14

Common Nouns

  • λx.Restaurant(x) → ‘restaurant’
  • Somewhat similar to the NNP construction
  • λ var.Predicate(var)
  • But common nouns represent relations, rather than constants
  • Meaning of the noun encoded in the predicate
  • Relate the concept of the noun to a particular instance of variable

14

slide-15
SLIDE 15

Negation

  • “No vegetarian restaurant serves meat.”
  • ¬(∃xVegetarianRestaurant(x) ∧ Serves(x,Meat))
  • “All vegetarian restaurants do not serve meat.”
  • ∀x VegetarianRestaurant(x)⇒¬Serves(x,Meat)
  • These are semantically equivalent!
  • ¬[IF P, THEN Q] ⇔ P AND NOT Q
  • For NLTK, use the hyphen/minus character: ‘-‘

15

slide-16
SLIDE 16

‘John booked a flight’

  • Target representation:
  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

16

slide-17
SLIDE 17

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

17

S → NP VP {NP.sem(VP.sem)}

slide-18
SLIDE 18

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

18

S → NP VP {NP.sem(VP.sem)}

slide-19
SLIDE 19

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

19

S → NP VP {NP.sem(VP.sem)} NNP → ‘John’ {λX.X(John)} NP → NNP {NNP.sem} VP → Verb NP {Verb.sem(NP.sem)}

slide-20
SLIDE 20

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

20

S → NP VP {NP.sem(VP.sem)} NNP → ‘John’ {λX.X(John)} NP → NNP {NNP.sem} VP → Verb NP {Verb.sem(NP.sem)}

slide-21
SLIDE 21

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

21

S → NP VP {NP.sem(VP.sem)} NNP → ‘John’ {λX.X(John)} NP → NNP {NNP.sem} VP → Verb NP {Verb.sem(NP.sem)}

slide-22
SLIDE 22

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

22

NP → Det NN {Det.sem(NN.sem)}

slide-23
SLIDE 23

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

23

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)}

slide-24
SLIDE 24

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

24

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) }

slide-25
SLIDE 25

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

25

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) }

slide-26
SLIDE 26

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

26

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) }

slide-27
SLIDE 27

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

27

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) }

slide-28
SLIDE 28

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

28

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) }

slide-29
SLIDE 29

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

29

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) }

slide-30
SLIDE 30

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

30

NP → Det NN {Det.sem(NN.sem)} NN → ‘flight’ {λx.Flight(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) } ‘a flight’ { λQ.∃x Flight(x) ∧ Q(x) }

slide-31
SLIDE 31

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

31

VP → Verb NP {Verb.sem(NP.sem)} ‘a flight’ { λQ.∃x Flight(x) ∧ Q(x) }

slide-32
SLIDE 32

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

32

VP → Verb NP {Verb.sem(NP.sem)} ‘a flight’ { λQ.∃x Flight(x) ∧ Q(x) }

slide-33
SLIDE 33

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

33

VP → Verb NP {Verb.sem(NP.sem)} ‘a flight’ { λQ.∃x Flight(x) ∧ Q(x) }

  • Verb → ‘booked’

{λW.λz.W(λy.∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,y))}

slide-34
SLIDE 34

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

34

Verb.sem(NP.sem) λW.λz.W(λy.∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,y))(λQ.∃x Flight(x) ∧ Q(x)) λz.(λQ.∃x Flight(x) ∧ Q(x))(λy.∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,y)) λz.∃x Flight(x) ∧ (λy.∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,y))(x) λz.∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,x)

slide-35
SLIDE 35

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

35

S VP.sem(John) ‘booked a flight' λz.∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,x)

slide-36
SLIDE 36

‘John booked a flight’

  • ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x))

36

S VP.sem(John) ‘booked a flight' λz.∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,x) λz.∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,x)(John) ∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e,John) ∧ BookedThing(e,x)

slide-37
SLIDE 37

‘John booked a flight’

37

Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) } Det → ‘every’ { λP.λQ.∀x P(x) ⇒ Q(x) } NN → ‘flight’ {λx.Flight(x)} Verb → ‘booked’ {λW.λz.W(λy.∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,y))} NNP → ‘John’ {λX.X(John)} NP → NNP {NNP.sem} NP → Det NN {Det.sem(NN.sem)} S → NP VP {NP.sem(VP.sem)} VP → Verb NP {Verb.sem(NP.sem)}

slide-38
SLIDE 38

‘John booked no flight’

  • ¬(∃x Flight(x) ∧ (∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x)))
  • ∀xFlight(x) ⇒ ¬(∃eBooked(e) ∧ Booker(e, John) ∧ BookedThing(e, x)

38

slide-39
SLIDE 39

‘John booked no flight’

39

Det → ‘no’ { λP.λQ.¬∃x P(x) ∧ Q(x) | λP.λQ.∀x P(x) ⇒ ¬Q(x)} Det → ‘a’ { λP.λQ.∃x P(x) ∧ Q(x) } Det → ‘every’ { λP.λQ.∀x P(x) ⇒ Q(x) } NN → ‘flight’ {λx.Flight(x)} Verb → ‘booked’ {λW.λz.W(λy.∃eBooked(e) ∧ Booker(e,z) ∧ BookedThing(e,y))} NNP → ‘John’ {λX.X(John)} NP → NNP {NNP.sem} NP → Det NN {Det.sem(NN.sem)} S → NP VP {NP.sem(VP.sem)} VP → Verb NP {Verb.sem(NP.sem)}

slide-40
SLIDE 40

Other Lambda Calculus

40

slide-41
SLIDE 41

Adjectives

  • Similar to nouns, but with an extra conjunction and dummy predicate:
  • “red” = λP λx(red(x) ∧ P(x))
  • Any issues?
  • Non-intersective adjectives (e.g. ‘skillful’, ‘alleged’, ‘fake’)

41

slide-42
SLIDE 42

Definite Article

  • a = λP.λQ.∃x(P(x) ∧ Q(x))
  • the = λP.λQ.∃x(P(x) ∧ ∀y(P(y)⇔x=y) ∧ Q(x)))
  • Roughly: “The P Q”: there is a unique P, which is also Q
  • Unique: x is P, and anything else that is also P is equal to x

42

slide-43
SLIDE 43

Definite Article

  • the = λP.λQ.∃x(P(x) ∧ ∀y(P(y)⇔x=y) ∧ Q(x)))
  • Bertrand Russel, “On Denoting” (1905).
  • The definite article isn’t exactly the same as a constant (like “John”)
  • Rather, it picks out a set of items from a set (the generic NN), and makes a

strong assertion: A) The book arrived. B) A book arrived.

  • A ⊨ B, but B ⊭ A

43

slide-44
SLIDE 44

Definite Article + Presupposition

  • “The slides for Monday are amazing.”
  • ~> there are slides for Monday.
  • “The slides for Monday are not amazing.”
  • ~> there are slides for Monday.
  • The P Q: presupposes that there is a unique P, does not assert it

[Strawson 1950, …]

  • If there is no P, “The P Q” is neither true nor false

44

slide-45
SLIDE 45

Learning Semantic Parsers

45

slide-46
SLIDE 46

46

Zettlemoyer and Collins 2005 Supervised learning:

  • Sentences labeled with logical forms
  • Induce grammar
  • Plus semantic attachments
  • Score analyses of ambiguous

sentences with log-linear model

slide-47
SLIDE 47

Learning from Denotations

47

Learn semantic representations as latent variables for downstream task (QA, conversation, …) Liang et al 2011

slide-48
SLIDE 48

Resources

  • Datasets
  • General:
  • Abstract Meaning Representations: LDC2017T10
  • Minimal Recursion Semantics: DeepBank
  • SQL:
  • Spider: https://yale-lily.github.io/spider
  • SParC: https://yale-lily.github.io/sparc

48

slide-49
SLIDE 49

Resources: Knowledge Graphs

  • R.I.P. Freebase
  • Used by Google Knowledge Graph, then bought and killed
  • [they have an API with 100,000 queries/day for free]
  • BUT: data moved to Wikidata

49

slide-50
SLIDE 50

Lexical Semantics

50

slide-51
SLIDE 51

Lexical Semantics

  • Thus far: POS → Word {sem}
  • Can compose larger semantic formulae bottom-up this way
  • …but we haven’t really discussed what a “word” is, semantically.
  • Lexical semantics:
  • How do we formally discuss what a “word” is?
  • How do we relate words to one another?
  • How do we differentiate/relate linked senses?

51

slide-52
SLIDE 52

What is a Plant?

  • There are more kinds of plants and animals in the rainforests than

anywhere else on Earth. Over half of the millions of known species of plants and animals live in the rainforest. Many are found nowhere else. There are even plants and animals in the rainforest that we have not yet discovered.

  • The Paulus company was founded in 1938. Since those days the product

range has been the subject of constant expansions and is brought up continuously to correspond with the state of the art. We’re engineering, manufacturing, and commissioning world-wide ready-to-run plants packed with our comprehensive know-how.

52

slide-53
SLIDE 53

…by way of dad-joke Halloween costumes. 🎄

Lexical Semantics

53

A Ceiling Fan Snakes on a Plane

(Painful) Examples of Homonymy

slide-54
SLIDE 54

Sources of Confusion

Homonymy Polysemy Synonymy Antonymy [Hypo/Hyper]-nymy

54

slide-55
SLIDE 55

Sources of Confusion: Homonymy

  • Words have same form but different meanings
  • Generally same POS, but unrelated meaning
  • bank1 (side of river)
  • bank2 (financial institution)

55

slide-56
SLIDE 56

Sources of Confusion: Homonymy

  • Different types of Homonymy:
  • Homophones: same phonology, different orthographic form
  • two
  • to
  • too
  • Homographs: Same orthography, different phonology:
  • “lead” (metal)
  • “lead” (take somewhere)
  • Why do we care?
  • Problem for applications: TTS, ASR transcription, IR

56

slide-57
SLIDE 57

Sources of Confusion: Polysemy

  • Multiple RELATED senses
  • e.g. bank: money, organ, blood
  • Big issue in lexicography
  • Number of senses
  • Relations between senses
  • Differentiation

57

slide-58
SLIDE 58

Sources of Confusion: Polysemy

  • Example: [[serve]]
  • serve breakfast
  • serve Philadelphia
  • serve time

58

slide-59
SLIDE 59

Sources of Confusion: Synonymy

  • (near) identical meaning
  • Substitutability
  • Maintains propositional meaning

59

slide-60
SLIDE 60

Sources of Confusion: Synonymy

  • Issues:
  • Also has polysemy!
  • Shades of meaning - other associations
  • price vs. fare
  • big vs. large
  • water vs. H20
  • Collocational constraints
  • e.g. babbling brook vs. *babbling river
  • Register:
  • social factors: e.g. politeness, formality

60

slide-61
SLIDE 61

Sources of Confusion: Antonymy

  • Opposition
  • Typically ends of a scale
  • fast vs. slow
  • big vs. little
  • Can be hard to distinguish automatically from

synonyms

61

slide-62
SLIDE 62

Sources of Confusion: Hyponomy

  • instanceOf(x, y) relations:
  • More General (hypernym) vs. more specific (hyponym)
  • dog vs. golden retriever
  • fruit vs. mango
  • Organize as ontology/taxonomy

62

slide-63
SLIDE 63

Word Sense Disambiguation

  • Application of lexical semantics
  • Goal: given a word in context, identify the appropriate sense
  • e.g. plants and animals in the rainforest
  • Crucial for real syntactic & semantic analysis
  • Correct sense can determine
  • Available syntactic structure
  • Available thematic roles, correct meaning…

63

slide-64
SLIDE 64

Robust Disambiguation

  • More to semantics than predicate-argument structure
  • Select sense where predicates underconstrain
  • Learning approaches
  • Supervised, bootstrapped, unsupervised
  • Knowledge-based approaches
  • Dictionaries, taxonomies
  • Contexts for sense selection

64

slide-65
SLIDE 65

65

There are more kinds of plants and animals in the rainforests than anywhere else on

  • Earth. Over half of the millions of known species of plants and animals live in the
  • rainforest. Many are found nowhere else. There are even plants and animals in the

rainforest that we have not yet discovered. Biological Example The Paulus company was founded in 1938. Since those days the product range has been the subject of constant expansions and is brought up continuously to correspond with the state of the art. We’re engineering, manufacturing and commissioning world- wide ready-to-run plants packed with our comprehensive know-how. Our Product Range includes pneumatic conveying systems for carbon, carbide, sand, lime and many

  • thers. We use reagent injection in molten metal for the…

Industrial Example Label the First Use of “Plant”

slide-66
SLIDE 66

Roadmap

  • Lexical Semantics
  • Motivation & Definitions
  • Word Senses
  • Tasks:
  • Word sense disambiguation
  • Word sense similarity
  • Distributional Similarity

66

slide-67
SLIDE 67

Disambiguation: Features

  • Part of Speech
  • Of word and neighbors
  • Morphologically simplified form
  • Words in neighborhood
  • How big is “neighborhood?”
  • Is there a single optimal size? Why?

67

slide-68
SLIDE 68

Disambiguation: Features

  • (Possibly shallow) Syntactic analysis
  • predicate-argument relations
  • modification (complements)
  • phrases
  • Collocation
  • words in specific relation
  • Predicate-Argument, or (+/–)1 word index
  • Co-occurrence
  • bag of words

68

slide-69
SLIDE 69

Disambiguation: Evaluation

  • Ideally, end-to-end evaluation with WSD component
  • Demonstrate real impact of technique in system
  • Difficult, expensive, still application specific
  • Typically intrinsic, sense-based
  • Accuracy, precision, recall
  • SENSEVAL/SEMEVAL: all words, lexical sample

69

slide-70
SLIDE 70

WSD Evaluation

  • Baseline:
  • Most frequent sense
  • Ceiling:
  • Human inter-rater agreement
  • 75-80% fine
  • 90% coarse

70

slide-71
SLIDE 71

Roadmap

  • Lexical Semantics
  • Motivation & Definitions
  • Word Senses
  • Tasks:
  • Word sense disambiguation
  • Word sense similarity
  • Distributional Similarity

71

slide-72
SLIDE 72

Word Sense Similarity

  • Synonymy:
  • True propositional substitutability is rare, slippery
  • Word similarity (semantic distance)
  • Looser notion, more flexible

72

slide-73
SLIDE 73

Word Sense Similarity

  • Appropriate to applications:
  • IR, summarization, MT, essay scoring
  • Don’t need binary +/– synonym decision
  • Want terms/documents that have high similarity
  • Approaches:
  • Distributional
  • Thesaurus-based

73

slide-74
SLIDE 74

Similarity vs. Relatedness

  • Similarity:
  • car, bicycle
  • nickel < coin < currency
  • Related:
  • car, gasoline
  • coin, budget

74

slide-75
SLIDE 75

Thesaurus-Based:

  • Build ontology of senses
  • e.g. WordNet
  • Use distance to infer similarity/relatedness:

75

slide-76
SLIDE 76

Roadmap

  • Lexical Semantics
  • Motivation & Definitions
  • Word Senses
  • Tasks:
  • Word sense disambiguation
  • Word sense similarity
  • Distributional Similarity

76

slide-77
SLIDE 77

Distributional Similarity

  • “You shall know a word by the company it keeps!” (Firth, 1957)
  • A bottle of tezgüino is on the table.
  • Everybody likes tezgüino.
  • Tezgüino makes you drunk.
  • We make tezgüino from corn.
  • Tezguino: corn-based alcoholic beverage. (From Lin, 1998a)

77

slide-78
SLIDE 78

Distributional Similarity

  • Represent ‘company’ of word such that similar words will have similar

representations

  • ‘Company’ = context
  • Word represented by context feature vector
  • Many alternatives for vector
  • Initial representation:
  • ‘Bag of words’ binary feature vector
  • Feature vector length N, where N is size of vocabulary
  • fi=1 if wordi within window size w of word0

78

slide-79
SLIDE 79

Context Feature Vector

79

arts boil data function large sugar summarized water Apricot 1 1 1 1 Pineapple 1 1 1 1 Digital 1 1 1 1 Information 1 1 1 1

slide-80
SLIDE 80

Distributional Similarity Questions

  • What is the right neighborhood?
  • What is the context?
  • How should we weight the features?
  • How can we compute similarity between vectors?

80

slide-81
SLIDE 81

HW #6

81

slide-82
SLIDE 82

Goals

  • Semantics
  • Gain better understanding of semantic representations
  • Develop experience with lambda calculus and FOL
  • Create semantic attachments
  • Understand semantic composition

82

slide-83
SLIDE 83

Compositional Semantics

  • Part 1:
  • Manually create target semantic representations
  • Use Neo-Davidsonian event representation
  • e.g. verb representation with event variable, argument conjuncts
  • Can use as test cases for part 2
  • Part 2:
  • Create semantic attachments to reproduce (NLTK)
  • Add to grammatical rules to derive sentence representations
  • Note: Lots of ambiguities (scope, etc)
  • Only need to produce one

83

slide-84
SLIDE 84

Semantics in NLTK

  • Grammar files:
  • .fcfg extension
  • Example format in NLTK Book Chapter 10
  • /corpora/nltk/nltk-data/grammars/book_grammars/simple-sem.fcfg
  • Note: Not “event-style”
  • Parsing:
  • Use nltk.parse.FeatureChartParser (or similar)

84

slide-85
SLIDE 85

Semantics in NLTK

  • Printing semantic representations:

item.label()[‘SEM’].simplify() all x.(dog(x) -> exists e.(barking(e) & barker(e,x)))

  • Also nltk.sem.util.root_semrep(item)

85

slide-86
SLIDE 86

Semantic attachments in NLTK:
 Syntax

  • a,b,e,x
  • lowercase variables can be arguments:
  • \x.dog(x)
  • P,Q,X
  • uppercase lambda variables are functors
  • \P.P(john)

86

λ = \ ∃ = exists ∀ = all ∧ = & ∨ = | ⇒ =

  • >

¬ =

  • (The programming kind)
slide-87
SLIDE 87

More NLTK Logic Format

  • Added to typical CFG rules
  • Basic approach similar to HW #5
  • Composing semantics:
  • S[SEM=<?np(?vp)>] -> NP[SEM=?np] VP[SEM=?vp]
  • Creating lambdas:
  • IV[SEM=<\x.exists e.(barking(e) & barker(e,x))>] -> ‘barks’
  • Nested lambdas:
  • \x.\y. Etc → \x y.


Can remove ‘.’ between sequences of lambda elements
 Keep ‘.’ between sections: lambdas, quantifiers, body

87

slide-88
SLIDE 88

88