Professional Documents
Culture Documents
Yaregal Assabie
2014/15—Sem II
Introduction
Phrases
Sentences
Introduction
Tree Representation
Formal Language Theory
Parsing
Introduction
Syntax- refers to the way words are related to each other in a sentence.
Syntactic Analysis- analyizes:
how words are grouped together into phrases;
what words modify other words;
what words are of central importance to the sentence.
Phases of Text
Generation: Words Phrases Sentences
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 2/32
Introduction
Noun Phrases
Phrases
Adjective Phrases
Sentences
Verb Phrases
Tree Representation
Prepositional Phrases
Formal Language Theory
Adverbial Phrases
Parsing
Noun Phrases
ጠጅ
የ ץדጠጅ
ንፁֱ የ ץדጠጅ
ሁֳُ ֵُ ץንፁֱ የ ץדጠጅ
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 3/32
Introduction
Noun Phrases
Phrases
Adjective Phrases
Sentences
Verb Phrases
Tree Representation
Prepositional Phrases
Formal Language Theory
Adverbial Phrases
Parsing
Adjective Phrases
ደግ
በጣ וደግ
ፈע
רው ፈע
እንደ ወንድר בው ፈע
በጣ וእንደ ወንድר בው ፈע
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 4/32
Introduction
Noun Phrases
Phrases
Adjective Phrases
Sentences
Verb Phrases
Tree Representation
Prepositional Phrases
Formal Language Theory
Adverbial Phrases
Parsing
Verb Phrases
רጠ٤ው
ֳካሳ אፅሀፍ רጠ٤ው
ָኮֶָٍ
ֳአስَ ץገንዘብ ָኮֶָٍ
በוֹንክ ֳአስَ ץገንዘብ ָኮֶָٍ
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 5/32
Introduction
Noun Phrases
Phrases
Adjective Phrases
Sentences
Verb Phrases
Tree Representation
Prepositional Phrases
Formal Language Theory
Adverbial Phrases
Parsing
Prepositional Phrases
ወደ ቤُ
ከወንድ בጋץ
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 6/32
Introduction
Noun Phrases
Phrases
Adjective Phrases
Sentences
Verb Phrases
Tree Representation
Prepositional Phrases
Formal Language Theory
Adverbial Phrases
Parsing
Adverbial Phrases
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 7/32
Introduction
Phrases
Sentences Simple Sentences
Tree Representation Complex Sentences
Formal Language Theory
Parsing
Simple Sentences
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 8/32
Introduction
Phrases
Sentences Simple Sentences
Tree Representation Complex Sentences
Formal Language Theory
Parsing
Complex Sentences
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 9/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
on P the table NP
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 10/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
NP
NP
N (Comp.)
N (Head)
N (Comp.)
N (Head)
! "#$ % &' NP
! "#$ % &' NP
! NP
! NP
"#$ A
"#$ A
% &' NP
% &' NP
DetDet !
!NN %NN(Comp.)
% (Comp.) &'
&' N (Head)
N (Head)
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 11/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
AP
AP
Det A (HEAD)
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 12/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
P $% N
P $% N
A
VP
A
VP
P N A
PP
N (Comp.) V (Head)
P N A
PP
N (Comp.) V (Head)
P A
N
P A
N
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 13/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
PP
PP
P (Head) N
P (Head) N
PP
PP
P PP
P PP
N N P (Head)
P (Head)
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 14/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
E
AdvP
E P
N
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 15/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
A
SS
A N
VP
PP V
P
N
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 16/32
Introduction
Phrases
Sentences Examples (English)
Tree Representation Examples (Amharic)
Formal Language Theory
Parsing
A E CS
N A E VP
A E SS V
A N E VP
N E V
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 17/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 18/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
Concepts: Grammar
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 19/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
Hierarchy of Grammars/Languages
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 20/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 21/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
- Production rule:
α1Βα2→α1βα2 where
B is non-terminal symbol
α1, α2, β are all (possibly empty) sequences of terminal and non-terminal symbols (α1 is
left context and α2 is right context.
S → є is allowed if S does not appear on right hand side of any rule
These rules are used in natural languages to describe subject-verb agreement with respect to
number, i.e. singular or plural as reflected in sentences: the students come and the student
comes. For example, the following production rules can be used to describe such contexts.
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 22/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
- Production rule:
Exactly one non-terminal on left hand side, but anything on the right hand side.
These rules are used to describe grammars of natural languages that are context-free. For
example, past tenses of English are context-free with respect to the subject. Thus, it is
grammatically correct to construct the sentences: the students came and the student came. The
following production rules can be used to represent such context-free grammars.
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 23/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
- Production rule:
Exactly one non-terminal on left hand side, and one terminal and at most one non-
terminal on right hand side.
Examples:
A → aB Right Regular Grammar
A → Ba Left Regular Grammar
A→ a
Note: Regular Languages/Grammars are subsets of Context-Free Languages/Grammars.
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 24/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
Hierarchy of Grammars/Languages
Containment Hierarchy
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 25/32
Introduction
Phrases
Concepts
Sentences
Hierarchy of Grammars/Languages
Tree Representation
Automata and Machines
Formal Language Theory
Parsing
Reading assignment on
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 26/32
Introduction
Phrases
Parsing
Sentences
Parsing Strategies
Tree Representation
Towards Efficient Parsing
Formal Language Theory
Parsing
Parsing
Parsing - is a derivation process which identifies the structure of sentences using a given
grammar.
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 27/32
Introduction
Phrases
Parsing
Sentences
Parsing Strategies
Tree Representation
Towards Efficient Parsing
Formal Language Theory
Parsing
Top-down parsing starts with the symbol S and then searches through different ways to
rewrite the symbols until the input sentence is generated.
Given the following English grammar. Then, the sentence Abebe killed the lion can
be parsed using top-down strategy as follows.
S → NP VP
VP → V NP S ⇒ NP VP [rewriting S]
NP → NAME
NP → DET N ⇒ NAME VP [rewriting NP]
NAME → Abebe ⇒ Abebe VP [rewriting NAME]
V → killed
⇒ Abebe V NP [rewriting VP]
DET → the
N → lion ⇒ Abebe killed NP [rewriting V]
⇒ Abebe killed DET N [rewriting NP]
⇒ Abebe killed the N [rewriting DET]
⇒ Abebe killed the lion [rewriting N]
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 28/32
Introduction
Phrases
Parsing
Sentences
Parsing Strategies
Tree Representation
Towards Efficient Parsing
Formal Language Theory
Parsing
Bottom-up parsing starts with words in a sentence and uses production rules backward
to reduce the sequence of symbols until it consists solely of S.
Given the following English grammar. Then, the sentence Abebe killed the lion can
be parsed using bottom-up strategy as follows.
S → NP VP
VP → V NP Abebe killed the lion
NP → NAME
NAME killed the lion [rewriting Abebe]
NP → DET N
NAME → Abebe NAME V the lion [rewriting killed]
V → killed
DET → the NAME V DET lion [rewriting the]
N → lion NAME V DET N [rewriting lion]
NP V DET N [rewriting NAME]
NP V NP [rewriting DET N]
NP VP [rewriting V NP]
S [rewriting NP VP]
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 29/32
Introduction
Phrases
Parsing
Sentences
Parsing Strategies
Tree Representation
Towards Efficient Parsing
Formal Language Theory
Parsing
The efficiency of parsing algorithms can be improved if lexical rules are stored separately in a
structure called lexicon, which specifies the possible categories for each word.
The following example shows the lexical rules separated from other grammatical rules.
S → NP VP S → NP VP
VP → V NP VP → V NP
NP → NAME NP → NAME
NP → DET N NP → DET N
NAME → Abebe
V → killed
V → fly
Lexical Rules
DET → the
N → lion
N → fly Abebe: NAME
killed: V
the: DET
lion: N
fly: V, N
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 30/32
Introduction
Phrases
Parsing
Sentences
Parsing Strategies
Tree Representation
Towards Efficient Parsing
Formal Language Theory
Parsing
Chunking, also called partial parsing, is a technique which attempts to model human parsing
by breaking the text up into small pieces, each parsed separately. Chunk boundaries
correspond roughly to the pauses in everyday speech.
Each chunk can then be parsed separately. In addition to perhaps being a better model of
human behavior than full parsing methods, other advantages of chunk parsing are as
follows:
• Because a chunk parser only needs to deal with small, non-recursive clauses, it is able
to process text much more quickly.
• A chunk parser is easier to implement and requires much less memory to parse.
• When a full parse fails, it must discard an entire sentence, even if it got much of the
structure correct. A chunk parser only discards a few words when it cannot figure out
how to proceed.
Department of Computer Science, Addis Ababa University Lecture 03: Syntax and Parsing 31/32
TOC: Course Syllabus