Lecture 6: Context-Free Grammars

Similar documents
Informatics 2A: Language Complexity and the. Inf2A: Chomsky Hierarchy

Grammars & Parsing, Part 1:

CS 598 Natural Language Processing

A General Class of Noncontext Free Grammars Generating Context Free Languages

Basic Parsing with Context-Free Grammars. Some slides adapted from Julia Hirschberg and Dan Jurafsky 1

RANKING AND UNRANKING LEFT SZILARD LANGUAGES. Erkki Mäkinen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A ER E P S I M S

Language properties and Grammar of Parallel and Series Parallel Languages

Proof Theory for Syntacticians

Syntax Parsing 1. Grammars and parsing 2. Top-down and bottom-up parsing 3. Chart parsers 4. Bottom-up chart parsing 5. The Earley Algorithm

A Version Space Approach to Learning Context-free Grammars

Context Free Grammars. Many slides from Michael Collins

Developing a TT-MCTAG for German with an RCG-based Parser

11/29/2010. Statistical Parsing. Statistical Parsing. Simple PCFG for ATIS English. Syntactic Disambiguation

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

Erkki Mäkinen State change languages as homomorphic images of Szilard languages

AQUA: An Ontology-Driven Question Answering System

On the Polynomial Degree of Minterm-Cyclic Functions

1/20 idea. We ll spend an extra hour on 1/21. based on assigned readings. so you ll be ready to discuss them in class

Enumeration of Context-Free Languages and Related Structures

Using dialogue context to improve parsing performance in dialogue systems

"f TOPIC =T COMP COMP... OBJ

Natural Language Processing. George Konidaris

Parsing of part-of-speech tagged Assamese Texts

The Interface between Phrasal and Functional Constraints

BANGLA TO ENGLISH TEXT CONVERSION USING OPENNLP TOOLS

Compositional Semantics

Discriminative Learning of Beam-Search Heuristics for Planning

Chapter 4: Valence & Agreement CSLI Publications

Aspectual Classes of Verb Phrases

An Interactive Intelligent Language Tutor Over The Internet

Rule Learning With Negation: Issues Regarding Effectiveness

A Minimalist Approach to Code-Switching. In the field of linguistics, the topic of bilingualism is a broad one. There are many

Efficient Normal-Form Parsing for Combinatory Categorial Grammar

A R "! I,,, !~ii ii! A ow ' r.-ii ' i ' JA' V5, 9. MiN, ;

A Grammar for Battle Management Language

Maximizing Learning Through Course Alignment and Experience with Different Types of Knowledge

Assessing Children s Writing Connect with the Classroom Observation and Assessment

Machine Learning from Garden Path Sentences: The Application of Computational Linguistics

What the National Curriculum requires in reading at Y5 and Y6

Chunk Parsing for Base Noun Phrases using Regular Expressions. Let s first let the variable s0 be the sentence tree of the first sentence.

Enhancing Unlexicalized Parsing Performance using a Wide Coverage Lexicon, Fuzzy Tag-set Mapping, and EM-HMM-based Lexical Probabilities

Language Acquisition Fall 2010/Winter Lexical Categories. Afra Alishahi, Heiner Drenhaus

Analysis: Evaluation: Knowledge: Comprehension: Synthesis: Application:

Pre-Processing MRSes

Objectives. Chapter 2: The Representation of Knowledge. Expert Systems: Principles and Programming, Fourth Edition

Replace difficult words for Is the language appropriate for the. younger audience. For audience?

Rule Learning with Negation: Issues Regarding Effectiveness

Memory-based grammatical error correction

Introduction to Ensemble Learning Featuring Successes in the Netflix Prize Competition

WSU Five-Year Program Review Self-Study Cover Page

EdIt: A Broad-Coverage Grammar Checker Using Pattern Grammar

4-3 Basic Skills and Concepts

Developing True/False Test Sheet Generating System with Diagnosing Basic Cognitive Ability

Mining Student Evolution Using Associative Classification and Clustering

Probabilistic Latent Semantic Analysis

ENGBG1 ENGBL1 Campus Linguistics. Meeting 2. Chapter 7 (Morphology) and chapter 9 (Syntax) Pia Sundqvist

UNIVERSITY OF OSLO Department of Informatics. Dialog Act Recognition using Dependency Features. Master s thesis. Sindre Wetjen

Modeling Attachment Decisions with a Probabilistic Parser: The Case of Head Final Structures

SARDNET: A Self-Organizing Feature Map for Sequences

arxiv: v1 [math.at] 10 Jan 2016

Inleiding Taalkunde. Docent: Paola Monachesi. Blok 4, 2001/ Syntax 2. 2 Phrases and constituent structure 2. 3 A minigrammar of Italian 3

IT Students Workshop within Strategic Partnership of Leibniz University and Peter the Great St. Petersburg Polytechnic University

South Carolina English Language Arts

Analysis of Probabilistic Parsing in NLP

CS Machine Learning

BULATS A2 WORDLIST 2

Loughton School s curriculum evening. 28 th February 2017

Chinese Language Parsing with Maximum-Entropy-Inspired Parser

Artificial Neural Networks written examination

A Computational Evaluation of Case-Assignment Algorithms

1 st Quarter (September, October, November) August/September Strand Topic Standard Notes Reading for Literature

Liquid Narrative Group Technical Report Number

Classroom Connections Examining the Intersection of the Standards for Mathematical Content and the Standards for Mathematical Practice

Minimalism is the name of the predominant approach in generative linguistics today. It was first

Title:A Flexible Simulation Platform to Quantify and Manage Emergency Department Crowding

PRODUCT PLATFORM DESIGN: A GRAPH GRAMMAR APPROACH

First Grade Curriculum Highlights: In alignment with the Common Core Standards

Part I. Figuring out how English works

Listening and Speaking Skills of English Language of Adolescents of Government and Private Schools

(Sub)Gradient Descent

Target Language Preposition Selection an Experiment with Transformation-Based Learning and Aligned Bilingual Data

The Evolution of Random Phenomena

Derivational: Inflectional: In a fit of rage the soldiers attacked them both that week, but lost the fight.

Hyperedge Replacement and Nonprojective Dependency Structures

Radius STEM Readiness TM

Secret Code for Mazes

FOREWORD.. 5 THE PROPER RUSSIAN PRONUNCIATION. 8. УРОК (Unit) УРОК (Unit) УРОК (Unit) УРОК (Unit) 4 80.

Prediction of Maximal Projection for Semantic Role Labeling

Dear Teacher: Welcome to Reading Rods! Reading Rods offer many outstanding features! Read on to discover how to put Reading Rods to work today!

Linking Task: Identifying authors and book titles in verbose queries

Developing Grammar in Context

Collocations of Nouns: How to Present Verb-noun Collocations in a Monolingual Dictionary

Defragmenting Textual Data by Leveraging the Syntactic Structure of the English Language

Three New Probabilistic Models. Jason M. Eisner. CIS Department, University of Pennsylvania. 200 S. 33rd St., Philadelphia, PA , USA

A Neural Network GUI Tested on Text-To-Phoneme Mapping

Be aware there will be a makeup date for missed class time on the Thanksgiving holiday. This will be discussed in class. Course Description

Houghton Mifflin Reading Correlation to the Common Core Standards for English Language Arts (Grade1)

Content Language Objectives (CLOs) August 2012, H. Butts & G. De Anda

DIPLOMA IN ENGLISH LANGUAGE & LITERATURE PROGRAMME

Predicting Students Performance with SimStudent: Learning Cognitive Skills from Observation

Transcription:

Lecture 6: Context-Free Grammars September 27, 2016 CS 1010 Theory of Computation So far, we ve classified languages as regular or not regular. Regular languages are recognized by DFAs, NFAs, and regexes, and are closed under regular operations. We can also pump regular languages via the pumping lemma. However, as we know due to contradictions of the pumping lemma, some fairly simple languages are not regular. Topics Covered 1. Context-Free Grammars 2. Context-Free Languages 3. Ambiguity 4. Chomsky Normal Form 1 Context-Free Grammars Consider the regex 0 (10 11) 1. Let A = 0, B = (10 11), and C = 1. We can express this regex as the concatenation ABC. We can also right down rules for generating elements of the language of the regular expression: A ε 0A B ε 10B 11B C ε 1C For example, we can follow the chain of steps: start ABC 0ABC 00ABC 00BC 0011BC 001110BC 001110C 001110111. This binary string, 001110111, is in the language of 0 (10 11) 1. A context-free grammar (CFG) is a 4-tuple (V, Σ, R, S) such that 1. V is a finite set of variables 2. Σ is a finite set of terminals (a.k.a. the alphabet) 3. R is a finite set of rules, where r R is of the form A w where A V and w (V Σ) Lecture 6: Context-Free Grammars Page 1 / 5

4. S V is the designated start variable If G = (V, Σ, R, S) is a CFG; u, v, w are strings in (V Σ) ; A is in V ; and A w is in R, then we say that vau yields vwu, written vau vwu. We also say that u derives v, written u v, if there exist u 1,..., u k with k 0 such that u u 1 u k v. The leftmost derivation is a derivation in which, at every step, a rule is applied to the leftmost variable. 2 Context-Free Languages For a CFG G = (V, Σ, R, S), the language L(G) = {w w Σ and S w}. A language L is context-free if L = L(G) for some CFG G. Theorem Theorem If L is regular, then it is context-free. Not every context-free language is regular. As an example of the second theorem, recall our favorite nonregular language, {0 n 1 n n 0}. We can define a CFG for this language, with only one rule: S ε 0S1. Thus we can see that not every context-free language is regular. Language Structure We can use CFGs to capture the structure of spoken language. Consider the following set of rules, standing in for various parts of speech: <sentence> <noun-phrase> <verb-phrase> <noun-phrase> <complex-noun> <complex-noun> <prep-phrase> <verb-phrase> <complex-verb> <complex-verb> <prep-phrase> <prep-phrase> <prep> <complex-noun> <prep> with <complex-noun> <article> <noun> <article> a the <noun> boy girl flower heart <complex-verb> <verb> <verb> <noun-phrase> <verb> touches sees likes Lecture 6: Context-Free Grammars Page 2 / 5

We can use these rules to create a sentence, structuring the derivation as a parse tree: <sentence> <noun-phrase> <complex-noun> <verb-phrase> <complex-verb> <article> <noun> <verb> a girl sees Alternatively, we can write the rules that lead to a sentence; for example: S <noun-phrase> <verb-phrase> <complex-noun> <verb-phrase> a girl <verb-phrase> a girl <complex-verb> <prep-phrase> a girl sees <prep-phrase> a girl sees with the heart 3 Ambiguity Is it possible to create the same sentence in multiple ways? Consider the sentence a girl sees a boy with a flower. There are at least two ways to parse this sentence: 1. We might have the noun-phrase a girl, the verb-phrase sees, and the noun-phrase a boy with a flower. 2. We could also have the noun-phrase a girl, the complex-verb sees a boy, and the prepositional-phrase with a flower. In particular, there are two different parse trees corresponding to each of these constructions of the sentence. This leads to the definition of an ambiguous CFG. A CFG G is ambiguous if there exists some w in L(G) such that w has at least two different parse trees. Equivalently, w has more than one leftmost derivation. If G is ambiguous, there are two further classifications: 1. There exists G, not ambiguous, such that L(G) = L(G ). 2. L(G) is inherently ambiguous, so for all G such that L(G) = L(G ), G is ambiguous. Lecture 6: Context-Free Grammars Page 3 / 5

4 Chomsky Normal Form A CFG G = (V, Σ, R, S) is in Chomsky Normal Form (CNF) if every rule r R is in one of the following forms: 1. S ε 2. A BC, where A, B, and C are all variables and B, C S 3. A a, where A is a variable and a is a terminal Intuitively, we don t want S to ever appear on the righthand side of a rule. Moreover, in a parse tree corresponding to a CFG in Chomsky Normal Form, each node is either a leaf or has exactly two children. This will make it possible to design polynomial-time algorithms to check for membership in a CFL. We will cover this in more detail in future lectures. Theorem Let G be a CFG. Then there exists a CFG G in CNF such that L(G) = L(G ). Proof This is not a true proof, as we only outline a process for converting a CFG into CNF without justification of correctness. Suppose that A w, where w is neither a terminal nor of the form BC. In other words, A w is a rule that is not in Chomsky Normal Form. There are two cases to consider: 1. First, A B 1 B 2... B k for variables B i V. To fix this, we successively add new variables C 1,..., C k 2 and rules such that A B 1 C 1, C 1 B 2 C 2,..., C k 2 B k 1 B k. These rules are all of the form A BC, which is acceptable for CNF. 2. Second, we might have the case that A w 1 w 2... w k for terminals w i Σ. To fix this, we create a new variable B and add the rule B w i. We replace the original rule with A w 1... w i 1 Bw i+1... w k. We continue this process as needed, and then fix the resulting instance of the first case, if needed. There are three more cases to consider, where the righthand side is not necessarily too long but is incorrect in a different way. 3. If A S or A SB, then we create a new start variable S 0 and add S 0 S to the grammar. 4. A rule such as A ε is incorrect because ε is not a terminal. To fix this, find every rule of the form B AC, B CA, and B AA. For either of the first two rules, add another rule B C. If B AA, add B A and B ε. If a rule has previously been removed, do not add it again. 5. The final case is when a rule is of the form A B. To fix this, whenever we have the rule C AD, we add C BD. If C A, we add C B, unless previously removed. Lecture 6: Context-Free Grammars Page 4 / 5

Notice that many of these fixes create new situations or improper rules that will be successively dealt with as we iterate through the process. It is important to consider why, despite this, the algorithm is not circular. In particular, whenever we add a rule, we first check that it has not been previously removed. Lecture 6: Context-Free Grammars Page 5 / 5