computational language: week 10 lexical knowledge representation concluded syntax-based...

45
Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free grammars Phrase Structure rules Parsing with phrase structure grammars

Upload: saige-leavey

Post on 01-Apr-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Computational language: week 10 Lexical Knowledge Representation

concluded Syntax-based computational

language Sentence structure: syntax Context free grammars Phrase Structure rules Parsing with phrase structure grammars

Page 2: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Lexical Knowledge Representation concluded

Page 3: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Modelling verbs in DATR

ThinkPresent

1st person singular think (I think)2nd person singular think (you think)3rd person singular thinks (she thinks)1st person plural think (we think)2nd person plural think (you two think)3rd person plural think (they think)

Page 4: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Lexical knowledge representation continued

Summary

Inheritance Inference rules Formalism Computable

Page 5: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Syntax-based computational language

Page 6: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence structure

Units of the sentence are constituents Constituent: a group of words treated as a

single unit Minimum constituent is the word Structure of the sentence: syntax

Page 7: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax

what is syntax?“characteriz[ing] the relation between

semantic predicate-argument relations and the superficial word and phrase configurations by which a language expresses them” (Kaplan 2003)

Page 8: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax

(a) John saw Mary syntactic level

(b) saw (John1, Mary2) semantic level

(c) Mary was seen by John syntactic level(d) Mary sent John books syntactic level(e) sent (Mary1, John2, books3) semantic level

(f) saw: 1 = agent, 2 = patient(g) sent: 1 = agent, 2 = goal, 3 = patient

Page 9: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax

Max met Jane

Max gave Jane bananas

Page 10: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax N V N Max met Jane

N V N N Max gave Jane bananas

Page 11: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax The boys watched the game

Page 12: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax [The boys] watched [the game]

Page 13: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax [The boys] watched [the game]

The boys from Brazil watched an interesting game on TV

Page 14: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax [The boys] watched [the game]

[The boys from Brazil] watched [an interesting

game on TV]

Page 15: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax [The boys] watched [the game]

[The boys from Brazil]l watched [an interesting

game on TV] My mother sent Mary a recipe

Page 16: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax [The boys] watched [the game]

[The boys from Brazil]l watched [an interesting

game on TV] [My mother] sent Mary [a recipe]

Page 17: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax [The boys] watched [the game]

[The boys from Brazil]l watched [an interesting

game on TV] [My mother] sent [a recipe] to Mary My mother in London sent my sister the wrong

recipe

Page 18: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Structure of sentences: syntax NP V NP [The boys] watched [the game]

NP V NP [The boys from Brazil] watched [an interesting game on TV]

NP V NP NP [My mother] sent Mary [a recipe]

NP V NP NP [My mother in London] sent [my sister] [the wrong recipe]

Page 19: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Context Free Grammars

Taking linear strings as input Producing non-linear hierarchical

data structures (graphs) as outputs Assumption: sentences have a

constituent structure

Page 20: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Hierarchical structure1. My mother likes her cats

  

S

[my mother likes her cats]

Page 21: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Hierarchical structure1. My mother likes her cats

  

S

[my mother likes her cats]

NP [my mother]

VP [likes her cats]

Page 22: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Hierarchical structure1. My mother likes her cats

  

S

[my mother likes her cats]

NP [my mother]

VP [likes her cats]

Det N [my]

[mother]

Page 23: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Hierarchical structure1. My mother likes her cats

  

S

[my mother likes her cats]

NP [my mother]

VP [likes her cats]

Det N [my]

[mother]

V NP

[her cats]

[likes]

Page 24: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Hierarchical structure1. My mother likes her cats

  

S

[my mother likes her cats]

NP [my mother]

VP [likes her cats]

Det N [my]

[mother]

V NP

[her cats]

[likes]

Det N [her] [cats]

Page 25: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Context Free Grammars Phrase structure rules

Item(s) to right of arrow is an ordered list of symbols

Item to left is a generalization over this list

Start symbol Rules unordered

Page 26: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Context Free Grammars Phrase structure rules

The student enjoys maths The birds sang The relatives of my husband live in

Chicago The student drove his car into the

tree

Page 27: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Context Free Grammars Formal language

Set of strings derivable from designated start symbol S

Strings are ‘grammatical’ sentences

Page 28: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Context Free Grammars Four parameters

Set of non-terminal symbols or variables

Set of terminal symbols (found in lexicon)

Set of phrase structure rules Designated start symbol

Page 29: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Computable grammars The evaluation of a grammar:

Its ability to capture significant generalizations within the specific grammar of a given language, and across the grammars of different languages

Page 30: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Context Free Grammars / Phrase Structure Grammars (PSG)

Historical note Popularised by Chomsky Chomsky’s Transformational

Grammar Famous computable example:

Generalised Phrase Structure Grammar (Gazdar et al.)

Page 31: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing recognize / accept a sentence generate sentences

Page 32: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing recognize / accept a sentence generate sentences parsing: assign correct structure to

a sentence i.e. match a sentence to the correct

parse tree of the number of parse trees generated by a grammar

Page 33: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsingmy mother likes her cats

S

NP VP

Det N V NP

Det N

S

NP VP

Det N V

Page 34: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing the set of possible trees generated by

the grammar is the search space parsing is searching through the space

to find correct tree for the given sentence

goal: find all trees which: 1. have their root in S 2. cover no more or less the words in the

input

Page 35: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Two methods 1. top-down parsing

The tree must have S as its root Deduction reasoning Rule-driven

Page 36: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Two methods 1. top-down parsing 2. bottom-up parsing

The tree must have n number of leaves, and the following terminal symbols: x, y, z

Induction reasoning Data-driven

Page 37: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Two methods 1. top-down parsing

trees grown downward to syntactic category nodes

trees rejected if leaf nodes do not line up with all words in input

Page 38: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Two methods 2. bottom-up parsing

trees grown upwards from the input sentence, using the grammar

Page 39: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Two methods

Top-down

Bottom-up

advantages disadvantages No search on trees that are not rooted in S Search space will include trees that are

not rooted in S

disadvantages advantages Generates trees which are not at all consistent with the input data

Any candidate tree will at the very least be consistent with the input data

Page 40: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Top-down

Parallel Depth-first, left-to-right:

fully expand each partial tree beginning at the left-most node

Page 41: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Top-down

Bottom-up filtering Left-corner table

Page 42: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Top-down

Bottom-up filtering Left-corner table

Category Left corners (Part of Speech) S

Noun or Determiner

NP Noun or Determiner VP Verb PP Preposition

Page 43: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Problems

Left recursionGrammar has a non-terminal symbol that

has a expansion that includes itself ANDit is the left-most symbol in the expansion

e.g. NP -> NP PP

Page 44: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Problems

Structural ambiguityA given input sentence fits more than one

candidate parse treee.g. my friend saw the man with the telescope

…NP -> NP PPVP -> V NP PP…

Page 45: Computational language: week 10 Lexical Knowledge Representation concluded Syntax-based computational language Sentence structure: syntax Context free

Sentence parsing Applications

Grammar checker Semantic analysis