Syntax: Introduction
Till now, we have discussed:
Language modeling — understanding ordering of words POS tagging — understanding roles of words
Now we will discuss more complex notions, such as grammatical relations among words
What is Syntax?
Pawan Goyal (IIT Kharagpur)
2 / 14
Syntax
Refers to the way words are arranged together, and the relationship between then.
Grammar
Compositionality
Problem:
- “Ambiguity”
Week 5: Lecture 1
Syntax Tree: Example
Pawan Goyal (IIT Kharagpur)
3 / 14
Syntax
Sentence: The man read this book
We wish to understand how different words in a sentence are grouped, e.g., a Det and a Noun can together give a Noun Phrase, a Noun Phrase preceded by a verb can give a Verb phrase, etc.
Week 5: Lecture 1
Our final goal:
How to construct a syntax tree for a given sentence?
Defining the notions: Constituency
Pawan Goyal (IIT Kharagpur)
Syntax
Constituent
A group of words acts as a single unit - phrases, clauses etc.
Week 5: Lecture 1
4 / 14
the man from Amherst – NP (man: head word)
extremely clever – AP (clever: head word)
down the river – PP (down: head word)
killed the rabbit – VP (killed: head word)
Defining the notions: Constituency
Pawan Goyal (IIT Kharagpur)
Syntax
Constituent
A group of words acts as a single unit - phrases, clauses etc.
Part of Speech - “Substitution Test"
Constituency: Noun Phrase
Kermit the frog they
December twenty-sixth
the reason he is running for president
Similarly, different word-sequences (phrases) can be used as a substitute for each other.
E.g., noun phrases
Week 5: Lecture 1
4 / 14
Different words having the same POS (here, adjective)
The {sad, intelligent, green, fat, ...} one is in the corner. can be used as a substitute
for each other.
Pawan Goyal (IIT Kharagpur)
Syntax
Evidence that constituency exists
They appear in similar environments
Week 5: Lecture 1
6 / 14
Pawan Goyal (IIT Kharagpur)
Syntax
Evidence that constituency exists
They appear in similar environments
Week 5: Lecture 1
6 / 14
Evidence that constituency exists
Pawan Goyal (IIT Kharagpur)
Syntax
They appear in similar environments
Can be placed in a number of different locations
Week 5: Lecture 1
6 / 14
Evidence that constituency exists
Pawan Goyal (IIT Kharagpur)
Syntax
They appear in similar environments
Can be placed in a number of different locations
Week 5: Lecture 1
6 / 14
Modeling Constituency: what tool do we need?
Pawan Goyal (IIT Kharagpur)
7 / 14
Syntax
Basically, we want tools to understand which words (in a given text) come together as a unit.
E.g., which words together make up a noun phrase?
Week 5: Lecture 1
Modeling Constituency
Pawan Goyal (IIT Kharagpur)
Syntax
Context-free grammar
The most common way of modeling constituency
Consists of production Rules
These rules express the ways in which the symbols of the language can be grouped and ordered together
Week 5: Lecture 1
8 / 14
Modeling Constituency
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
8 / 14
CFG for Languages
Pawan Goyal (IIT Kharagpur)
9 / 14
Syntax
Week 5: Lecture 1
CFG for Languages
Pawan Goyal (IIT Kharagpur)
Syntax
Example
“Noun”, “ProperNoun”, “Det” are pre-terminals.
Week 5: Lecture 1
10 / 14
But we cannot generate any string with these rules, since there is no terminal.
CFG for Languages
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
10 / 14
NLP is highly context-sensitive BTW
CFG as a generator
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
11 / 14
CFG as a generator
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
11 / 14
CFG as a generator
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
11 / 14
CFG as a generator
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
11 / 14
CFGs and Grammaticality
Pawan Goyal (IIT Kharagpur)
12 / 14
Syntax
A CFG defines a formal language = set of all sentences (string of words) that can be derived by the grammar
Sentences in this set are said to be grammatical
Sentences outside this set are said to be ungrammatical
Week 5: Lecture 1
CFGs and Recursion
Pawan Goyal (IIT Kharagpur)
Syntax
Week 5: Lecture 1
13 / 14
CFGs and Recursion
Pawan Goyal (IIT Kharagpur)
Syntax
Example Sentence
[SThe mailman ate his [NP lunch [PP with his friend [PP from the cleaning staff
[PP of the building [PP at the intersection [PP on the north end [PP of town]]]]]]].
start of a NP
start of a NP
start of a NP
Week 5: Lecture 1
13 / 14
start of a NP
start of a NP