Lecture 7: Language Structure: Grammar Kai-Wei Chang CS @ UCLA - - PowerPoint PPT Presentation

lecture 7 language structure grammar
SMART_READER_LITE
LIVE PREVIEW

Lecture 7: Language Structure: Grammar Kai-Wei Chang CS @ UCLA - - PowerPoint PPT Presentation

Lecture 7: Language Structure: Grammar Kai-Wei Chang CS @ UCLA kw@kwchang.net Couse webpage: https://uclanlp.github.io/CS269-17/ ML in NLP 1 Basic sentence structure CS6501: NLP 2 A Markov Model v I eat shshi; I eat meat; you eat


slide-1
SLIDE 1

Lecture 7: Language Structure: Grammar

Kai-Wei Chang CS @ UCLA kw@kwchang.net Couse webpage: https://uclanlp.github.io/CS269-17/

1 ML in NLP

slide-2
SLIDE 2

Basic sentence structure

CS6501: NLP 2

slide-3
SLIDE 3

A Markov Model

v I eat shshi; I eat meat; you eat banana… v Great, it covers many sentences

CS6501: NLP 3

slide-4
SLIDE 4

Words take different arguments

v [Good] I eat sushi v [Bad] I run sushi v [Bad] I give sushi v Intransitive verbs (sleep): no object v Transitive verbs (eat): take one direct object v Ditransitive verbs (give): take an additional indirect object.

CS6501: NLP 4

slide-5
SLIDE 5

A better model

CS6501: NLP 5

slide-6
SLIDE 6

Language is recursive

CS6501: NLP 6

Adjectives can modify nouns. We can have unlimited modifiers (in theory)

slide-7
SLIDE 7

We know how to model the simple one

CS6501: NLP 7

slide-8
SLIDE 8

Recursion can be more complex

CS6501: NLP 8

We can have another noun phrase in preposition

slide-9
SLIDE 9

Syntactic parsing

v Idea: model language as a recursive generating process

v Often use a tree structure v Decompose a sentence

CS6501: NLP 9

slide-10
SLIDE 10

What is grammar?

v A compact way to define and describe the structure of sentences v Why we need grammar?

v Number of C++ programs?

CS6501: NLP 10

976 pages. C++ standard (2014) ISO/IEC 14882:2014 1358 pages

slide-11
SLIDE 11

Can we define a program that generates all English sentences?

CS6501: NLP 11

From Julia Hockenmaier, Intro to NLP

slide-12
SLIDE 12

What is sentence structure

v Sentence structure is hierarchical

v A sentence consists of phrases (or constituents)

CS6501: NLP 12

slide-13
SLIDE 13

Can have complex constituents

CS6501: NLP 13

slide-14
SLIDE 14

Can have complex constituents

v Syntactically, constituents behave like simple ones

CS6501: NLP 14

slide-15
SLIDE 15

Constituency

v Groups of words that behave as a single unit or phrase

v E.g., Noun phrases: the man, a girl with glasses v Prepositional phrases: with classes, on a table v Verb phrase: eat sushi, sleep, sleep soundly

v Phrases has a head:

v Other parts called dependents v E.g, the man, a girl with glasses

CS6501: NLP 15

slide-16
SLIDE 16

Properties of constituents

v Substitution

v He talks [in class] ⇒ He talks [there]

v It can move around in a sentence

v He talks [in class] ⇒ [In class], he talks.

v Can be used as an answer:

v Where does he talk? – [In class]

CS6501: NLP 16

slide-17
SLIDE 17

Types of dependencies

v Phrases has a head:

v Other parts called dependents v E.g, the man, a girl with glasses

v Dependents can be arguments or adjuncts v Arguments are obligatory

v E.g., [John] likes [Mary]

v Adjuncts are optional

v E.g., John runs [fast] v Adverbs, PPs, Adjectives…

CS6501: NLP 17

All arguments have to be present and cannot be

  • ccupied multiple times

Can be an arbitrary number

  • f adjuncts
slide-18
SLIDE 18

How to represent the structure

CS6501: NLP 18

slide-19
SLIDE 19

Dependency Trees

v Dependency grammar describe the structure of sentences as a graph (tree)

v Nodes represent words v Edges represent dependencies

CS6501: NLP 19

slide-20
SLIDE 20

Phrases structure trees

v Can be modeled by Context-free grammars

CS6501: NLP 20

slide-21
SLIDE 21

Context-free grammars

CS6501: NLP 21

slide-22
SLIDE 22

Parse tree defined by CFG

CS6501: NLP 22

slide-23
SLIDE 23

Generate sentences by CFG

CS6501: NLP 23

slide-24
SLIDE 24

Example: Noun Phrases

CS6501: NLP 24

slide-25
SLIDE 25

Example: verb phrase

CS6501: NLP 25

slide-26
SLIDE 26

Sentences

CS6501: NLP 26