Semantic Analysis SyntaxDriven Semantics CS 4705 Semantics and
- Slides: 25
Semantic Analysis: Syntax-Driven Semantics CS 4705
Semantics and Syntax • Some representations of meaning: The cat howls at the moon. – Logic: howl(cat, moon) – Frames: Event: howling Agent: cat Patient: moon • What shall we represent? – Entities, categories, events, time, aspect – Predicates, arguments (constants, variables) – And…quantifiers, operators (e. g. temporal) • How do we compute such representations from a Natural Language sentence?
Compositional Semantics • Assumption: The meaning of the whole is comprised of the meaning of its parts – George cooks. Dan eats. Dan is sick. – cook(George) eat(Dan) sick(Dan) – George cooks and Dan eats cook(George) ^ eat(Dan) – George cooks or Dan is sick. cook(George) v sick(Dan) – If George cooks, Dan is sick cook(George) sick(Dan) or ~cook(George) v sick(Dan)
– If George cooks and Dan eats, Dan will get sick. (cook(George) ^ eat(Dan)) sick(Dan) cook(George) ^ eat(Dan) ? ? Dan only gets sick when George cooks. You can have apple juice or orange juice. Mary got married and had a baby. George cooks but Dan eats. George cooks and eats Dan.
Meaning derives from – The entities and actions/states represented (predicates and arguments, or, nouns and verbs) – The way they are ordered and related: • The syntax of the representation may correspond to the syntax of the sentence • Can we develop a mapping between syntactic representations and formal representations of meaning?
Syntax-Driven Semantics S NP VP eat(Dan) Nom V N Dan eats • Goal: Link syntactic structures to corresponding semantic representation to produce representation of the ‘meaning’ of a sentence while parsing it
Specific vs. General-Purpose Rules • Don’t want to have to specify for every possible parse tree what semantic representation it maps to • Do want to identify general mappings from parse trees to semantic representations • One way: – Augment the lexicon and the grammar – Devise mapping between rules of the grammar and rules of semantic representation – Rule-to-Rule Hypothesis: such a mapping exists
Semantic Attachment • Extend every grammar rule with `instructions’ on how to map components of rule to a semantic representation, e. g. S NP VP {VP. sem(NP. sem)} • Each semantic function defined in terms of the semantic representation of choice • Problem: how to define semantic functions and how to specify their composition so we always get the `right’ meaning representation from the grammar
A Simple Example: Mc. Donalds serves burgers. • Associating constants with constituents – Proper. Noun Mc. Donalds {Mc. Donalds} – Plural. Noun burgers {burgers} • Defining functions to produce these from input – NP Proper. Noun {Proper. Noun. sem} – NP Plural. Noun {Plural. Noun. sem} – Assumption: meaning representations of children are passed up to parents for nonbranching constituents • But…verbs are where the action is
– V serves {E(e, x, y) (Isa(e, Serving) ^ Server(e, x) ^ Served(e, y))} where e = event, x = agent, y = patient – Will every verb needs its own distinct representation? • Mc. Donalds hires students. • Mc. Donalds gave customers a bonus. • Predicate(Agent, Patient, Beneficiary)
Composing Semantic Constituents • Once we have the semantics for each constituent, how do we combine them? – VP V NP {V. sem(NP. sem)} – Goal for VP semantics of ‘serve’: E(e, x) (Isa(e, Serving) ^ Server(e, x) ^ Served(e, Meat)) – VP. sem must tell us • Which variables to be replaced by which arguments • How is replacement accomplished?
Lambda Notation • Extension to First Order Predicate Calculus λ x P(x): λ + variable(s) + FOPC expression in those variables • Lambda binding • Apply lambda-expression to logical terms to bind lambda-expression’s parameters to terms (lambda reduction) • Simple process: substitute terms for variables in lambda expression x. P(x)(car) P(car)
An Example • Parameter list in lambda expression makes variables within body of logical expression available for binding to external arguments provided by semantics of other constituents – Lambda reduction implements replacement • So, for V serves {V. sem(NP. sem)} with target {E(e, x, y) (Isa(e, Serving) ^ Server(e, y) ^ Served(e, x))} becomes { x E(e, y) (Isa(e, Serving) ^ Server(e, y) ^ Served(e, x))} – Now ‘x’ available to be bound when V. sem is applied to NP. sem of direct object
– application binds x to value of NP. sem (burgers) – -reduction replaces x within -expression with burgers – V. sem becomes {E(e, y) (Isa(e, Serving) ^ Server(e, y) ^ Served(e, burgers))} • Now need semantic attachment for S NP VP {VP. sem(NP. sem)} to add subject NP (Mc. Donalds) to semantic representation of Mc. Donalds serves burgers – We need another -expression in V. sem so the subject NP can be bound later (in VP. sem) – So… V serves { x y E(e) (Isa(e, Serving) ^ Server(e, y) ^ Served(e, x))}
– After lambda-reduction, value of V. sem(NP. sem) for serve will be { y E(e) (Isa(e, Serving) ^ Server(e, y) ^ Served(e, burgers))} • VP V NP {V. sem(NP. sem)} binds outer expression to the object NP (burgers) but leaves inner -expression for later binding to subject NP when semantics of S determined • S NP VP {VP. sem(NP. sem)} { y E(e) Isa(e, Serving) ^ Server(e, y) ^ Served(e, burgers)}(Mc. Donald’s) Result after lambda binding: {E(e) Isa(e, Serving) ^ Server(e, Mc. Donald’s) ^ Served(e, burgers)}
But this is just the tip of the iceberg…. • Terms can be complex A restaurant serves burgers. – ‘a restaurant’: E x Isa(x, restaurant) – E e Isa(e, Serving) ^ Server(e, <E x Isa(x, restaurant)>) ^ Served(e, burgers) – Allows quantified expressions to appear where terms can by providing rules to turn them into well-formed FOPC expressions • Issues of quantifier scope Every restaurant serves every burger.
How represent other constituents? • Adjective phrases: • Happy people, cheap food, purple socks • Intersective semantics works for some… Nom Adj Nom { x (Nom. sem(x) ^ Isa(x, Adj. sem))} Adj cheap {Cheap} x Isa(x, Food) ^ Isa(x, Cheap) But…. fake gun? Local restaurant? Former friend? Would-be singer? Ex Isa(x, Gun) ^ Isa(x, Fake)
Doing Compositional Semantics • To incorporate semantics into grammar we must – Determine `right’ representation for each basic constituent – Determine `right’ representation constituents that take these basic constituents as arguments – Result: set of function-like semantic attachments to incorporate into CFG E. g. Nom Adj Nom { x Nom. sem(x) ^ Isa(x, Adj. sem)}
Parsing with Semantic Attachments • Modify parser to include operations on semantic attachments as well as syntactic constituents – E. g. , change an Early-style parser so when constituents (dot at the end of the rule) are completed, their attached semantic function is applied and a meaning representation created and stored with state • Or… let parser run to completion and then walk through resulting tree, applying semantic attachments from bottom-up
Option 1 (Integrated Semantic Analysis) S NP VP {VP. sem(NP. sem)} – VP. sem has been stored in state representing VP – NP. sem stored with the state for NP – When rule completed, retrieve value of VP. sem and of NP. sem, and apply VP. sem to NP. sem – Store result in S. sem. • As fragments of input parsed, semantic fragments created • Can be used to block ambiguous representations
Drawback • You also perform semantic analysis on orphaned constituents that play no role in final parse • Case for pipelined approach: Do semantics after syntactic parse
Non-Compositional Language • Some meaning isn’t compositional – Non-compositional modifiers: fake, former, local, socalled, putative, apparent, … – Metaphor: • You’re the cream in my coffee. She’s the cream in George’s coffee. • The break-in was just the tip of the iceberg. This was only the tip of Shirley’s iceberg. – Idiom: • The old man finally kicked the bucket. The old man finally kicked the proverbial bucket. – Deferred reference: The ham sandwich wants his check. • Solution: special rules?
Summing Up • Hypothesis: Principle of Compositionality – Semantics of NL sentences and phrases can be composed from the semantics of their subparts • Rules can be derived which map syntactic analysis to semantic representation (Rule-to-Rule Hypothesis) – Lambda notation provides a way to extend FOPC to this end – But coming up with rule 2 rule mappings is hard • Idioms, metaphors makes things even harder
Next • Midterm on Thursday: Study hard and good luck!
- 4705 in word
- Today meaning
- Coms 4705
- Compare procedural semantics and declarative semantics.
- Eecs 483
- Semantic feature analysis example
- Latent semantic indexing tutorial
- Semantic analysis compiler
- Static semantic analysis
- Semantic marker
- Semantic analysis definition
- Semantic field exercise
- Graphophonic definition
- Communicative translation vs semantic translation
- Semantic noise meaning
- Ogden and richards triangle of meaning
- Types of semantics
- Abowd and beale framework examples
- What is semantics features
- Semantic nets and frames
- Data integration with xml and semantic web technologies
- Scale classification
- Advantages and disadvantages of sample survey
- Semantic and communicative translation
- Scope of semantic
- Semantics vs syntax