CONTEXT-FREE GRAMMARS

Similar documents
Grammars & Parsing, Part 1:

Context Free Grammars. Many slides from Michael Collins

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

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

CS 598 Natural Language Processing

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

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

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

BANGLA TO ENGLISH TEXT CONVERSION USING OPENNLP TOOLS

2/15/13. POS Tagging Problem. Part-of-Speech Tagging. Example English Part-of-Speech Tagsets. More Details of the Problem. Typical Problem Cases

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

Parsing with Treebank Grammars: Empirical Bounds, Theoretical Models, and the Structure of the Penn Treebank

LTAG-spinal and the Treebank

Accurate Unlexicalized Parsing for Modern Hebrew

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

Parsing of part-of-speech tagged Assamese Texts

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

Ch VI- SENTENCE PATTERNS.

Heuristic Sample Selection to Minimize Reference Standard Training Set for a Part-Of-Speech Tagger

Natural Language Processing. George Konidaris

Proof Theory for Syntacticians

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

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

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

Prediction of Maximal Projection for Semantic Role Labeling

Developing Grammar in Context

Compositional Semantics

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

The stages of event extraction

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

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

Chapter 4: Valence & Agreement CSLI Publications

University of Alberta. Large-Scale Semi-Supervised Learning for Natural Language Processing. Shane Bergsma

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

An Introduction to the Minimalist Program

"f TOPIC =T COMP COMP... OBJ

Analysis of Probabilistic Parsing in NLP

The Indiana Cooperative Remote Search Task (CReST) Corpus

Chinese Language Parsing with Maximum-Entropy-Inspired Parser

A Version Space Approach to Learning Context-free Grammars

The Interface between Phrasal and Functional Constraints

a) analyse sentences, so you know what s going on and how to use that information to help you find the answer.

Towards a MWE-driven A* parsing with LTAGs [WG2,WG3]

SEMAFOR: Frame Argument Resolution with Log-Linear Models

Today we examine the distribution of infinitival clauses, which can be

Parsing natural language

EdIt: A Broad-Coverage Grammar Checker Using Pattern Grammar

Extracting Verb Expressions Implying Negative Opinions

Universal Grammar 2. Universal Grammar 1. Forms and functions 1. Universal Grammar 3. Conceptual and surface structure of complex clauses

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

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

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

Part I. Figuring out how English works

Adjectives tell you more about a noun (for example: the red dress ).

The Internet as a Normative Corpus: Grammar Checking with a Search Engine

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

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

Ensemble Technique Utilization for Indonesian Dependency Parser

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

Some Principles of Automated Natural Language Information Extraction

Thornhill Primary School - Grammar coverage Year 1-6

Construction Grammar. University of Jena.

Argument structure and theta roles

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

Case government vs Case agreement: modelling Modern Greek case attraction phenomena in LFG

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

The presence of interpretable but ungrammatical sentences corresponds to mismatches between interpretive and productive parsing.

LNGT0101 Introduction to Linguistics

cmp-lg/ Jan 1998

Loughton School s curriculum evening. 28 th February 2017

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

Tracy Dudek & Jenifer Russell Trinity Services, Inc. *Copyright 2008, Mark L. Sundberg

What is NLP? CS 188: Artificial Intelligence Spring Why is Language Hard? The Big Open Problems. Information Extraction. Machine Translation

Part of Speech Template

Advanced Grammar in Use

The Smart/Empire TIPSTER IR System

IBAN LANGUAGE PARSER USING RULE BASED APPROACH

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

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

Chapter 9 Banked gap-filling

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

ELA/ELD Standards Correlation Matrix for ELD Materials Grade 1 Reading

Towards a Machine-Learning Architecture for Lexical Functional Grammar Parsing. Grzegorz Chrupa la

Copyright 2017 DataWORKS Educational Research. All rights reserved.

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

Product Feature-based Ratings foropinionsummarization of E-Commerce Feedback Comments

Adapting Stochastic Output for Rule-Based Semantics

What the National Curriculum requires in reading at Y5 and Y6

Opportunities for Writing Title Key Stage 1 Key Stage 2 Narrative

A Computational Evaluation of Case-Assignment Algorithms

A General Class of Noncontext Free Grammars Generating Context Free Languages

Theoretical Syntax Winter Answers to practice problems

Chapter 4 - Fractions

Formulaic Language and Fluency: ESL Teaching Applications

Annotation Projection for Discourse Connectives

GRAMMAR IN CONTEXT 2 PDF

Language properties and Grammar of Parallel and Series Parallel Languages

The Discourse Anaphoric Properties of Connectives

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

STUDENT MOODLE ORIENTATION

Transcription:

COMP90042 LECTURE 8 CONTEXT-FREE GRAMMARS

SYNTACTIC CONSTITUENTS Sequential models like HMMs assume entirely flat structure But language clearly isn t like that [A man] [saw [a dog] [in [the park]]] Words group together to form syntactic constituents Can be replaced, or moved around as a unit Grammars allow us to formalize these intuitions Symbols correspond to syntactic constituents

TESTING FOR CONSTITUENCY Various tests for constituency, based on linguistic intuition Only constituents can answer a question Trevor gave a lecture on grammar Who gave the lecture on grammar? Trevor Trevor gave a lecture on grammar Trevor did what with the lecture on grammar?*gave (fails) Trevor gave a lecture on grammar What topic was Trevor s lecture on? on grammar Only constituents can be coordinated with others (of same type) Trevor gave a lecture on grammar and on parsing Trevor gave a lecture on grammar and parsing Trevor gave a lecture on grammar and a treatise on parsing Trevor gave a lecture on grammar and ate a tasty pie #Trevor gave a lecture on and a treatise about grammar More tests, e.g., topicalisation, clefting and coordination.

OUTLINE The context-free grammar formalism Parsing with CFGs Representing English with CFGs

BASICS OF CONTEXT-FREE GRAMMARS Symbols Terminal: word such as book Non-terminal: syntactic label such as NP or NN Convention to use upper and lower-case to distinguish, or else quotes for terminals Productions (rules) W X Y Z Exactly one non-terminal on left-hand side (LHS) An ordered list of symbols on right-hand side (RHS) can be Terminals or Non-terminals

REGULAR EXPRESSIONS AS CFGS Regular expressions match simple patterns E.g., [A-Z][a-z]* words starting with a capital Can rewrite as a grammar S C S C RS C A C B C Z RS R RS R RS R a R b R z In fact, a regex is a way of specifying a regular language (language = set of strings matching pattern) The class of regular languages is a subset of the contextfree languages, which are specified using a CFG

CFGS VS REGULAR GRAMMARS CFGs (and regexs) used to describe a set of strings, aka a language Regular grammars describe a smaller class of languages, e.g., a*b*c* can be parsed using finite state machine HMMs are a model for a (weighted) regular grammar (exercise: show the grammar for a POS tagging HMM) CFGs can describe hierarchical groupings e.g., matching brackets (a n b n ) & many recursive tree structures found in language requires push-down automata to parse Context sensitive grammars are even more expressive (and intractable)

A SIMPLE GRAMMAR Terminal symbols: rat, the, ate, cheese Non-terminal symbols: S, NP, VP, DT, VBD, NN Productions: S NP VP NP DT NN VP VBD NP DT the NN rat NN cheese VBD ate

GENERATING SENTENCES WITH CFGS Always start with S (the sentence/start symbol) S Apply rule with S on LHS (S NP VP), i.e substitute RHS NP VP Apply rule with NP on LHS (NP DT NN) DT NN VP Apply rule with DT on LHS (DT the) the NN VP Apply rule with NN on LHS (NN rat) the rat VP

GENERATING SENTENCES WITH CFGS Apply rule with VP on LHS (VP VBD NP) the rat VBD NP Apply rule with VBD on LHS (VBD ate) the rat ate NP Apply rule with NP on LHS (NP DT NN) the rat ate DT NN Apply rule with DT on LHS (DT the) the rat ate the NN Apply rule with NN on LHS (NN cheese) the rat ate the cheese

CFG TREES Generation corresponds to a syntactic tree Non-terminals are internal nodes Terminals are leaves (S (NP (DT the) (NN rat)) (VP (VBG ate) (NP (DT the) (NN cheese)))) Parsing is the reverse process

PARSE AMBIGUITY Often more than one tree can describe a string While hunting in Africa, I shot an elephant in my pajamas. How he got into my pajamas, I don't know. Animal Crackers (1930) Example & figures: http://www.nltk.org/book/ch08.html

PARSING CFGS Parsing: given string, identify possible structures Brute force search is intractable for non-trivial grammars Good solutions use dynamic programming Two general strategies Bottom-up Start with words, work up towards S CYK parsing Top-down Start with S, work down towards words Earley parsing (not covered)

THE CYK PARSING ALGORITHM Convert grammar to Chomsky Normal Form (CNF) Fill in a parse table Use table to derive parse Convert result back to original grammar

CONVERT TO CNF Change grammar so all rules of form A B C or A a Step 1: Convert rules of form A B c into pair of rules A B X, X c Not usually necessary in POS-based grammars Step 2: Convert rules A B C D into A B Y, Y C D Usually necessary, but not for our toy grammar X, Y are new symbols we have introduced Unary rules A B can be permitted, but have to factor out cycles)

PARSE TABLE the rat ate the cheese DT NP S [0,1] [0,2] [0,3] [0,4] [0,5] NN S NP VP NP DT NN VP VBD NP DT the NN rat NN cheese VBD ate [1,2] [1,3] [1,4] [1,5] VBD VP [2,3] [2,4] [2,5] DT NP [3,4] [3,5] NN [4,5]

CYK ALGORITHM JM3, Ch 12

CYK: RETRIEVING THE PARSES S in the top-left corner of parse table indicates success To get parse(s), follow pointers back for each match Convert back from CNF by removing new non-terminals

PARSE TABLE WITH BACKPOINTERS DT the rat ate the cheese NP [0,1] [0,2] [0,3] [0,4] [0,5] NN Split = 1; NP DT NN S Split = 2; S NP VP S NP VP NP DT NN VP VBD NP DT the NN rat NN cheese VBD ate [1,2] [1,3] [1,4] [1,5] VBD [2,3] [2,4] [2,5] DT VP NP [3,4] [3,5] NN [4,5] Split = 3; VP VBD NP Split = 4; NP DT NN

FROM TOY GRAMMARS TO REAL GRAMMARS Toy grammars with handful of productions good for demonstration or extremely limited domains For real texts, we need real grammars Hundreds or thousands of production rules

KEY CONSTITUENTS IN PENN TREEBANK Sentence (S) Noun phrase (NP) Verb phrase (VP) Prepositional phrase (PP) Adjective phrase (AdjP) Adverbial phrase (AdvP) Subordinate clause (SBAR)

EXAMPLE PTB/0001 ( (S (NP-SBJ (NP (NNP Pierre) (NNP Vinken) ) (,,) (ADJP (NP (CD 61) (NNS years) ) (JJ old) ) (,,) ) (VP (MD will) (VP (VB join) (NP (DT the) (NN board) ) (PP-CLR (IN as) (NP (DT a) (JJ nonexecutive) (NN director) )) (NP-TMP (NNP Nov.) (CD 29) ))) (..) ))

BASIC ENGLISH SENTENCE STRUCTURES Declarative sentences (S NP VP) E.g. The rat ate the cheese Imperative sentences (S VP) E.g. Eat the cheese! Yes/no questions (S VB NP VP) E.g. did the rat eat the cheese? Wh-subject-questions (S WH VP) Who ate the cheese? Wh-object-questions (S WH VB NP VP) What did the rat eat?

ENGLISH NOUN PHRASES Pre-modifiers DT, CD, ADJP, NNP, NN E.g. the two very best Philly cheese steaks Post-modifiers PP, VP, SBAR A delivery from Bob coming today that I don t want to miss NP DT? CD? ADJP? (NN NNP)+ PP* VP? SBAR? NP PRP

VERB PHRASES Auxiliaries MD, AdvP, VB, TO E.g should really have tried to wait VP (MD VB TO) AdvP? VP Arguments and adjuncts NP, PP, SBAR, VP, AdvP E.g told him yesterday that I was ready E.g. gave John a gift for his birthday to make amends VP VB NP? NP? PP* AdvP* VP? SBAR?

OTHER CONSTITUENTS Prepositional phrase PP IN NP (in the house) Adjective phrase AdjP (AdvP) JJ (really nice) Adverb phrase AdvP (AdvP) RB (not too well) Subordinate clause SBAR (IN) S (since I came here) Coordination NP NP CC NP; VP VP CC VP; etc. (Jack and Jill) Complex sentences S S SBAR; S SBAR, S; etc. (if he goes, I ll go)

A FINAL WORD Context-free grammars can represent linguistic structure There are relatively fast dynamic programming algorithms to retrieve this structure But what about ambiguity? Extreme ambiguity will slow down parsing If multiple possible parses, which is best?

REQUIRED READING J&M3 Ch. 11.1-11.5, Ch. 12.1-12.2 Constituency tests http://people.umass.edu/nconstan/201/constituency%20te sts.pdf