Context-Free Grammars. A grammar is a set of rules for putting strings together and so corresponds to a language.

Similar documents
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

Grammars & Parsing, Part 1:

CS 598 Natural Language Processing

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

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

Context Free Grammars. Many slides from Michael Collins

Natural Language Processing. George Konidaris

Parsing of part-of-speech tagged Assamese Texts

Proof Theory for Syntacticians

"f TOPIC =T COMP COMP... OBJ

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

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

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

Chapter 4: Valence & Agreement CSLI Publications

Basic Syntax. Doug Arnold We review some basic grammatical ideas and terminology, and look at some common constructions in English.

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

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

Digital Fabrication and Aunt Sarah: Enabling Quadratic Explorations via Technology. Michael L. Connell University of Houston - Downtown

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

Some Principles of Automated Natural Language Information Extraction

A General Class of Noncontext Free Grammars Generating Context Free Languages

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

Language properties and Grammar of Parallel and Series Parallel Languages

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

Hyperedge Replacement and Nonprojective Dependency Structures

Hindi Aspectual Verb Complexes

BANGLA TO ENGLISH TEXT CONVERSION USING OPENNLP TOOLS

GRAMMAR IN CONTEXT 2 PDF

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

AGS THE GREAT REVIEW GAME FOR PRE-ALGEBRA (CD) CORRELATED TO CALIFORNIA CONTENT STANDARDS

THE HEAD START CHILD OUTCOMES FRAMEWORK

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

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

Type Theory and Universal Grammar

LNGT0101 Introduction to Linguistics

A Version Space Approach to Learning Context-free Grammars

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

Parsing natural language

Accurate Unlexicalized Parsing for Modern Hebrew

Correspondence between the DRDP (2015) and the California Preschool Learning Foundations. Foundations (PLF) in Language and Literacy

California Department of Education English Language Development Standards for Grade 8

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

Chapter 4 - Fractions

TABE 9&10. Revised 8/2013- with reference to College and Career Readiness Standards

Best website to write my essay >>>CLICK HERE<<<

Grammar Lesson Plan: Yes/No Questions with No Overt Auxiliary Verbs

A Usage-Based Approach to Recursion in Sentence Processing

Developing Grammar in Context

Learning to Think Mathematically With the Rekenrek

In how many ways can one junior and one senior be selected from a group of 8 juniors and 6 seniors?

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

2 nd grade Task 5 Half and Half

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

Compositional Semantics

Argument structure and theta roles

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

Classify: by elimination Road signs

Adjectives In Paragraphs

and secondary sources, attending to such features as the date and origin of the information.

Introduction to HPSG. Introduction. Historical Overview. The HPSG architecture. Signature. Linguistic Objects. Descriptions.

Taught Throughout the Year Foundational Skills Reading Writing Language RF.1.2 Demonstrate understanding of spoken words,

Analysis of Probabilistic Parsing in NLP

Teachers: Use this checklist periodically to keep track of the progress indicators that your learners have displayed.

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

If we want to measure the amount of cereal inside the box, what tool would we use: string, square tiles, or cubes?

Human-like Natural Language Generation Using Monte Carlo Tree Search

PowerTeacher Gradebook User Guide PowerSchool Student Information System

Poll. How do you feel when someone says assessment? How do your students feel?

Name of Course: French 1 Middle School. Grade Level(s): 7 and 8 (half each) Unit 1

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

Highlighting and Annotation Tips Foundation Lesson

systems have been developed that are well-suited to phenomena in but is properly contained in the indexed languages. We give a

An Introduction to the Minimalist Program

LEXICAL COHESION ANALYSIS OF THE ARTICLE WHAT IS A GOOD RESEARCH PROJECT? BY BRIAN PALTRIDGE A JOURNAL ARTICLE

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

What Can Neural Networks Teach us about Language? Graham Neubig a2-dlearn 11/18/2017

Working Papers in Linguistics

Demystifying The Teaching Portfolio

The Interface between Phrasal and Functional Constraints

University of Waterloo School of Accountancy. AFM 102: Introductory Management Accounting. Fall Term 2004: Section 4

- Period - Semicolon - Comma + FANBOYS - Question mark - Exclamation mark

Considerations for Aligning Early Grades Curriculum with the Common Core

Written by: YULI AMRIA (RRA1B210085) ABSTRACT. Key words: ability, possessive pronouns, and possessive adjectives INTRODUCTION

English for Life. B e g i n n e r. Lessons 1 4 Checklist Getting Started. Student s Book 3 Date. Workbook. MultiROM. Test 1 4

A method to teach or reinforce concepts of restriction enzymes, RFLPs, and gel electrophoresis. By: Heidi Hisrich of The Dork Side

Mathematics Success Level E

L1 and L2 acquisition. Holger Diessel

More ESL Teaching Ideas

Statewide Framework Document for:

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

AQUA: An Ontology-Driven Question Answering System

Control and Boundedness

Feature-Based Grammar

Character Stream Parsing of Mixed-lingual Text

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

Advanced Grammar in Use

The building blocks of HPSG grammars. Head-Driven Phrase Structure Grammar (HPSG) HPSG grammars from a linguistic perspective

Subject: Opening the American West. What are you teaching? Explorations of Lewis and Clark

Word Stress and Intonation: Introduction

ecampus Basics Overview

Transcription:

Context-Free Grammars A grammar is a set of rules for putting strings together and so corresponds to a language.

Grammars A grammar consists of: a set of variables (also called nonterminals), one of which is designated the start variable; It is customary to use upper-case letters for variables; a set of terminals (from the alphabet); and a list of productions (also called rules). Goddard 6a: 2

Example: 0 n 1 n Here is a grammar: S 0S1 S ε S is the only variable. The terminals are 0 and 1. There are two productions. Goddard 6a: 3

Using a Grammar A production allows one to take a string containing a variable and replace the variable by the RHS of the production. String w of terminals is generated by the grammar if, starting with the start variable, one can apply productions and end up with w. The sequence of strings so obtained is a derivation of w. We focus on a special version of grammars called a context-free grammar (CFG). A language is context-free if it is generated by a CFG. Goddard 6a: 4

Example Continued S 0S1 S ε The string 0011 is in the language generated. The derivation is: S = 0S1 = 00S11 = 0011 For compactness, we write S 0S1 ε where the vertical bar means or. Goddard 6a: 5

Example: Palindromes Let P be language of palindromes with alphabet {a, b}. One can determine a CFG for P by finding a recursive decomposition. If we peel first and last symbols from a palindrome, what remains is a palindrome; and if we wrap a palindrome with the same symbol front and back, then it is still a palindrome. CFG is P ap a bp b ε Actually, this generates only those of even length... Goddard 6a: 6

Formal Definition One can provide a formal definition of a contextfree grammar. It is a 4-tuple (V, Σ, S, P ) where: V is a finite set of variables; Σ is a finite alphabet of terminals; S is the start variable; and P is the finite set of productions. Each production has the form V (V Σ). Goddard 6a: 7

Further Examples: Even 0 s A CFG for all binary strings with an even number of 0 s. Find the decomposition. If first symbol is 1, then even number of 0 s remain. If first symbol is 0, then go to next 0; after that again an even number of 0 s remain. This yields: S 1S 0A0S ε A 1A ε Goddard 6a: 8

Alternate CFG for Even 0 s Here is another CFG for the same language. Note that when first symbol is 0, what remains has odd number of 0 s. Goddard 6a: 9

Alternate CFG for Even 0 s Here is another CFG for the same language. Note that when first symbol is 0, what remains has odd number of 0 s. S 1S 0T ε T 1T 0S Goddard 6a: 10

Example A CFG for the regular language corresponding to the RE 00 11. Goddard 6a: 11

Example A CFG for the regular language corresponding to the RE 00 11. The language is the concatenation of two languages: all strings of zeroes with all strings of ones. S CD C 0C 0 D 1D 1 Goddard 6a: 12

Example Complement A CFG for the complement of RE 00 11. CFGs don t do and s, but they do do or s. A string not of the form 0 i 1 j where i, j > 0 is one of the following: contains 10; is only zeroes; or is only ones. This yields CFG: S A B C A D10D D 0D 1D ε B 0B 0 C 1C 1 Goddard 6a: 13

Consistency and Completeness Note that to check a grammar and description match, one must check two things: that everything the grammar generates fits the description (consistency), and everything in the description is generated by the grammar (completeness). Goddard 6a: 14

Example Consider the CFG S 0S1S 1S0S ε The string 011100 is generated: S = 0S1S = 01S = 011S0S = 0111S0S0S = 01110S0S = 011100S = 011100 What does this language contain? Certainly every string generated has equal 0 s and 1 s... But can any string with equal 0 s and 1 s be generated? Goddard 6a: 15

Example Argument for Completeness Yes. All strings with equal 0 s & 1 s are generated: Well, at some point, equality between 0 s and 1 s is reached. The key is that if string starts with 0, then equality is first reached at a 1. So the portion between first 0 and this 1 is itself an example of equality, as is the portion after this 1. That is, one can break up string as 0w1x with both w and x in the language. The break-up of 00101101: 0 0 1 0 1 1 0 1 w x Goddard 6a: 16

A Silly Language CFG This CFG generates sentences as composed of noun- and verb-phrases: S NP VP NP the N VP V NP V sings eats N cat song canary This generates the canary sings the song, but also the song eats the cat. This CFG generates all legal sentences, not just meaningful ones. Goddard 6a: 17

Practice Give grammars for the following two languages: 1. All binary strings with both an even number of zeroes and an even number of ones. 2. All strings of the form 0 a 1 b 0 c where a + c = b. (Hint: it s the concatenation of two simpler languages.) Goddard 6a: 18

Practice Solutions 1) S 0X 1Y ε X 0S 1Z Y 1S 0Z Z 0Y 1X (odd zeroes, even ones) (odd ones, even zeroes) (odd ones, odd zeroes) 2) S T U T 0T 1 ε U 1U0 ε Goddard 6a: 19

Summary A context-free grammar (CFG) consists of a set of productions that you use to replace a variable by a string of variables and terminals. The language of a grammar is the set of strings it generates. A language is context-free if there is a CFG for it. Goddard 6a: 20