Context-free grammars ICS 482 Natural Language Processing

Slides:



Advertisements
Similar presentations
12/18/20141 Machine Translation ICS 482 Natural Language Processing Lecture 29-2: Machine Translation Husni Al-Muhtaseb.
Advertisements

4/14/20151 REGULAR EXPRESSIONS AND AUTOMATA Lecture 3: REGULAR EXPRESSIONS AND AUTOMATA Husni Al-Muhtaseb.
Mrach 1, 2009Dr. Muhammed Al-Mulhem1 ICS482 Formal Grammars Chapter 12 Muhammed Al-Mulhem March 1, 2009.
Syntactic analysis using Context Free Grammars. Analysis of language Morphological analysis – Chairs, Part Of Speech (POS) tagging – The/DT man/NN left/VBD.
5/12/20151 N-Gram: Part 1 ICS 482 Natural Language Processing Lecture 7: N-Gram: Part 1 Husni Al-Muhtaseb.
Statistical NLP: Lecture 3
1 Lexicalized and Probabilistic Parsing – Part 1 ICS 482 Natural Language Processing Lecture 14: Lexicalized and Probabilistic Parsing – Part 1 Husni Al-Muhtaseb.
6/11/20151 Parsing Context-free grammars – Part 1 ICS 482 Natural Language Processing Lecture 12: Parsing Context-free grammars – Part 1 Husni Al-Muhtaseb.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Word Classes and English Grammar.
Artificial Intelligence 2005/06 From Syntax to Semantics.
NLP Credits and Acknowledgment These slides were adapted from presentations of the Authors of the book SPEECH and LANGUAGE PROCESSING: An Introduction.
NLP and Speech 2004 English Grammar
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Fall 2005-Lecture 2.
Syntax and Context-Free Grammars CMSC 723: Computational Linguistics I ― Session #6 Jimmy Lin The iSchool University of Maryland Wednesday, October 7,
1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake.
1 CSC 594 Topics in AI – Applied Natural Language Processing Fall 2009/ Outline of English Syntax.
CPSC 503 Computational Linguistics
The students will be able to know:
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing INTRODUCTION Muhammed Al-Mulhem March 1, 2009.
Semantics: Representing Meaning ICS 482 Natural Language Processing
Context Free Grammars Reading: Chap 12-13, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
School of something FACULTY OF OTHER School of Computing FACULTY OF ENGINEERING COMP3310 Natural Language Processing Eric Atwell, Language Research Group.
1 Features and Unification Chapter 15 October 2012 Lecture #10.
Context Free Grammars Reading: Chap 12-13, Jurafsky & Martin This slide set was adapted from J. Martin and Rada Mihalcea.
Speech and Language Processing Lecture 12—02/24/2015 Susan W. Brown.
Session 13 Context-Free Grammars and Language Syntax Introduction to Speech and Natural Language Processing (KOM422 ) Credits: 3(3-0)
1 Syntax Sudeshna Sarkar 25 Aug Sentence-Types Declaratives: A plane left S -> NP VP Imperatives: Leave! S -> VP Yes-No Questions: Did the plane.
1 CPE 480 Natural Language Processing Lecture 5: Parser Asst. Prof. Nuttanart Facundes, Ph.D.
10/3/2015CPSC503 Winter CPSC 503 Computational Linguistics Lecture 8 Giuseppe Carenini.
10/13/20151 Representing Meaning Part 4 & Semantic Analysis ICS 482 Natural Language Processing Lecture 21: Representing Meaning Part 4 & Semantic Analysis.
5/31/20161 Lexical Semantic + Students Presentations ICS 482 Natural Language Processing Lecture 26: Lexical Semantic + Students Presentations Husni Al-Muhtaseb.
Context Free Grammars Reading: Chap 9, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Rada Mihalcea.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
6/2/2016CPSC503 Winter CPSC 503 Computational Linguistics Lecture 9 Giuseppe Carenini.
1 LIN6932 Spring 2007 LIN6932 Topics in Computational Linguistics Lecture 6: Grammar and Parsing (I) February 15, 2007 Hana Filip.
Linguistic Essentials
1 Parts of Speech Part 1 ICS 482 Natural Language Processing Lecture 9: Parts of Speech Part 1 Husni Al-Muhtaseb.
29 November Parsing Context-free grammars Part 2 ICS 482 Natural Language Processing Lecture 13: Parsing Context-free grammars Part 2 Husni Al-Muhtaseb.
1 Context Free Grammars October Syntactic Grammaticality Doesn’t depend on Having heard the sentence before The sentence being true –I saw a unicorn.
Artificial Intelligence 2004
12/22/20151 Representing Meaning Part 2 ICS 482 Natural Language Processing Lecture 18: Representing Meaning Part 2 Husni Al-Muhtaseb.
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Spring 2006-Lecture 2.
Natural Language Processing Lecture 14—10/13/2015 Jim Martin.
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
1/31/20161 Lexical Semantic 2 ICS 482 Natural Language Processing Lecture 29-1: Lexical Semantic 2 Husni Al-Muhtaseb.
CSA3050: NLP Algorithms Sentence Grammar NLP Algorithms.
3/7/20161 Representing Meaning Part 3 ICS 482 Natural Language Processing Lecture 20: Representing Meaning Part 3 Husni Al-Muhtaseb.
Speech and Language Processing Formal Grammars Chapter 12.
Context Free Grammars. Slide 1 Syntax Syntax = rules describing how words can connect to each other * that and after year last I saw you yesterday colorless.
Natural Language Processing Vasile Rus
Beginning Syntax Linda Thomas
Statistical NLP: Lecture 3
Speech and Language Processing
CSC NLP -Context-Free Grammars
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
CPSC 503 Computational Linguistics
Lecture 13: Grammar and Parsing (I) November 9, 2004 Dan Jurafsky
CSC 594 Topics in AI – Natural Language Processing
CSCI 5832 Natural Language Processing
CSCI 5832 Natural Language Processing
CS 388: Natural Language Processing: Syntactic Parsing
CSCI 5832 Natural Language Processing
Probabilistic and Lexicalized Parsing
CSCI 5832 Natural Language Processing
Linguistic Essentials
David Kauchak CS159 – Spring 2019
Information Extraction ICS 482 Natural Language Processing
Structure of a Lexicon Debasri Chakrabarti 13-May-19.
Artificial Intelligence 2004 Speech & Natural Language Processing
Lecture 27: Husni Al-Muhtaseb
Presentation transcript:

Context-free grammars ICS 482 Natural Language Processing Lecture 11: Syntax and Context-free grammars Husni Al-Muhtaseb

بسم الله الرحمن الرحيم ICS 482 Natural Language Processing Lecture 11: Syntax and Context-free grammars Husni Al-Muhtaseb

Syntax and Context-free grammars ICS 482 Natural Language Processing Lecture 11: Husni Al-Muhtaseb

NLP Credits and Acknowledgment These slides were adapted from presentations of the Authors of the book SPEECH and LANGUAGE PROCESSING: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition and some modifications from presentations found in the WEB by several scholars including the following

NLP Credits and Acknowledgment If your name is missing please contact me muhtaseb At Kfupm. Edu. sa

NLP Credits and Acknowledgment Husni Al-Muhtaseb James Martin Jim Martin Dan Jurafsky Sandiway Fong Song young in Paula Matuszek Mary-Angela Papalaskari Dick Crouch Tracy Kin L. Venkata Subramaniam Martin Volk Bruce R. Maxim Jan Hajič Srinath Srinivasa Simeon Ntafos Paolo Pirjanian Ricardo Vilalta Tom Lenaerts Heshaam Feili Björn Gambäck Christian Korthals Thomas G. Dietterich Devika Subramanian Duminda Wijesekera Lee McCluskey David J. Kriegman Kathleen McKeown Michael J. Ciaraldi David Finkel Min-Yen Kan Andreas Geyer-Schulz Franz J. Kurfess Tim Finin Nadjet Bouayad Kathy McCoy Hans Uszkoreit Azadeh Maghsoodi Khurshid Ahmad Staffan Larsson Robert Wilensky Feiyu Xu Jakub Piskorski Rohini Srihari Mark Sanderson Andrew Elks Marc Davis Ray Larson Jimmy Lin Marti Hearst Andrew McCallum Nick Kushmerick Mark Craven Chia-Hui Chang Diana Maynard James Allan Martha Palmer julia hirschberg Elaine Rich Christof Monz Bonnie J. Dorr Nizar Habash Massimo Poesio David Goss-Grubbs Thomas K Harris John Hutchins Alexandros Potamianos Mike Rosner Latifa Al-Sulaiti Giorgio Satta Jerry R. Hobbs Christopher Manning Hinrich Schütze Alexander Gelbukh Gina-Anne Levow Guitao Gao Qing Ma Zeynep Altan

Previous Lectures Pre-start questionnaire Introduction and Phases of an NLP system NLP Applications - Chatting with Alice Finite State Automata & Regular Expressions & languages Morphology: Inflectional & Derivational Parsing and Finite State Transducers Stemming & Porter Stemmer 20 Minute Quiz Statistical NLP – Language Modeling N Grams Smoothing and NGram: Add-one & Witten-Bell Return Quiz1 Parts of Speech Arabic Parts of Speech

Today's Lecture Context Free Grammar (CFG) Syntax and Grammar Derivation & Parsing Recursion Agreement Subcategorization

Administration Quiz 2 When? 3rd April 2007 or 10th April 2007? Class time Covered material Textbook: Ch 6, 8, 9 + External Material + … We are not covering Speech related material

Syntax Syntax: the kind of implicit knowledge of your native language that you had mastered by the time you were 3 or 4 years old without explicit instruction Isn't it the kind of stuff you were later taught in school?

Syntax Applications Grammar checkers Question answering Information extraction Machine translation

General NLP System Architecture Lexicon Grammar

Analysis of Natural Languages Syntax actual structure of a sentence Parsing best possible way to make an analysis of a sentence Semantics representation of the meaning of a sentence Grammar the rule set used in the analysis

NL Understanding Understanding written text Stages Which books are bestsellers? Who wrote them? Stages Morphology: analyze word inflection Syntax: determine grammatical structure Semantics: convert to a form that is meaningful to a computer eg, SQL query Pragmatics and discourse: influence of context eg, what them refers to

Example Original: Who wrote them? Morphology: who write/past them Grammar: [verb=write, subject=who, object=them] Semantics: Select title, firstname, lastname from [X] Discourse & pragmatics: Select title, firstname, lastname from books Where salesthisyear >10000

Grammar: Definition A grammar defines syntactically legal sentences Ahmad ate an apple (syntactically legal) Ahmad ate apple (not syntactically legal) Ahmad ate a building (syntactically legal) Sentences may be grammatically OK but not acceptable (acceptability?) The sleepy table eats the green idea. تأكل المنضدة الناعسة الفكرة الخضراء. (تركيب صحيح لكن هل الجملة مقبولة؟)

Context-Free Grammars (CFG) Capture constituency and ordering Ordering is easy What are the rules that govern the ordering of words and bigger units in the language What’s constituency? How do words group into units and what we say about how the various kinds of units behave

CFG Examples S  NP VP NP  Det NOMINAL NOMINAL  Noun VP  Verb Det  a Noun  flight Verb  left

CFGs S  NP VP This says that there are units called S, NP, and VP in this language That an S consists of an NP followed immediately by a VP Doesn’t say that that’s the only kind of S Nor does it say that this is the only place that NPs and VPs occur

Generativity As with FSAs and FSTs you can view these rules as either analysis or synthesis machines Generate strings in the language Reject strings not in the language Impose structures (trees) on strings in the language

Derivations A derivation is a sequence of rules applied to a string that accounts for that string Covers all the elements in the string Covers only the elements in the string

Derivations as Trees Sentence VP NP TranVerb Det NP Noun Det Noun The The student sees the instructor Sentence VP NP TranVerb Det NP Noun Det Noun The student sees the instructor

Parsing Parsing is the process of taking a string and a grammar and returning a (many?) parse tree(s) for that string It is equivalent to running a finite-state transducer with a tape Its just more powerful

One Parsing Tree Sentence VP NP TranVerb Det NP Noun Det Noun the instructor student sees The

Context? The notion of context in CFGs has nothing to do with the ordinary meaning of the word context in language. All it really means is that the non-terminal on the left-hand side of a rule is out there all by itself A  B C Means that I can rewrite an A as a B followed by a C regardless of the context in which A is found

Key Constituents (English) Sentences Noun phrases Verb phrases Prepositional phrases

Sentence-Types Declaratives: A plane left Imperatives: Leave! S  NP VP Imperatives: Leave! S  VP Yes-No Questions: Did the plane leave? S  Aux NP VP WH Questions: When did the plane leave? S  WH Aux NP VP

Recursion We’ll have to deal with rules such as the following where the non-terminal on the left also appears somewhere on the right (directly). NP  NP PP [[The flight] [to Jeddah]] VP  VP PP [[departed Riyadh] [at noon]]

Recursion This is what makes syntax interesting flights from Dammam Flights from Dammam to Riyadh Flights from Dammam to Riyadh in February Flights from Dammam to Riyadh in February on a Friday Flights from Dammam to Riyadh in February on a Friday under SR300 Flights from Dammam to Riyadh in February on a Friday under SR300 with lunch

Recursion This is what makes syntax interesting [[flights] [from Dammam]] [[[Flights] [from Dammam]] [to Riyadh]] [[[[Flights] [from Dammam]] [to Riyadh]] [in February]] [[[[[Flights] [from Dammam]] [to Riyadh]] [in February]] [on a Friday]] Etc.

Recursion This is what makes syntax interesting [NP PP] [[NP PP] PP] [[[NP PP] PP] PP] [[[[NP PP] PP] PP] PP] Etc.

Context Free If we have a rule like VP  V NP It only cares that the thing after the verb (V) is a Noun Phrase (NP). It doesn’t have to know about the internal affairs of that NP

NP internally might be different VP  V NP I like flights from Dammam Flights from Dammam to Riyadh Flights from Dammam to Riyadh in February Flights from Dammam to Riyadh in February on a Friday Flights from Dammam to Riyadh in February on a Friday under SR300 Flights from Dammam to Riyadh in February on a Friday under SR300 with lunch

Conjunctive Constructions S  S and S Ahmad went to Jeddah and Ali followed him NP  NP and NP VP  VP and VP … In fact the right rule for English is X  X and X

Problems Agreement Subcategorization

Agreement This boy Those boys This boy walks Those boys walk *This boys *Those boy *This boy walk *Those boys walks

Agreement In English, subjects and verbs have to agree in person and number Determiners and nouns have to agree in number Many languages have agreement systems that are far more complex than this.

Possible CFG Solution Sg for singular Pl for Plural S  NP VP NP  Det Nominal VP  V NP … SgS  SgNP SgVP PlS  PlNp PlVP SgNP  SgDet SgNom PlNP  PlDet PlNom PlVP  PlV NP SgVP  SgV NP … Sg for singular Pl for Plural

Agreement We need similar rules for pronouns, also for number agreement, etc. 3SgNP  (Det) (Card) (Ord) (Quant) (AP) SgNominal Non3SgNP  (Det) (Card) (Ord) (Quant) (AP) PlNominal SgNominal  SgNoun | SgNoun SgNoun etc. Card: two friends Ord: First person Quant: Many people AP: Adjective Phrase: longest sentence

Notation Predet: Pre-determiner – all Det: Determiner – the a, an Card: Cardinal number – one two Ord: Ordinal number –first, second, other Quant: Quantifier –many, several AP is the adjective phrase. AP can have an adverb before the adjective. AP  (Adv) Adj e.g. the least expensive fare

Subcategorization Sneeze: Mazen [sneezed] Find: Please find [a flight to Jeddah]NP Give: Give [me]NP [a cheaper fare]NP Help: Can you help [me]NP [with a flight]PP Prefer: I prefer [to leave earlier]TO-VP Told: I was told [Saudia has a flight]S …

Subcategorization *Mazen sneezed the book *I found to fly to Jeddah *Give with a flight Subcategorization expresses the constraints that a predicate (verb for now) places on the number and type of the argument it wants to take

Subcategorization Frames: (around the verb) 0: eat, sleep NP: prefer, find, leave NP NP: show, give PPfrom PPto: fly, travel NP PPwith: help, load VPto: prefer, want, need VPbare-stem: can, would, might S: mean What do we notice? Are we still in pure syntax?

Towards Semantics It turns out that verb subcategorization facts will provide a key element for semantic analysis (determining who did what to who in an event).

Subcategorization and generation The various rules for VPs over-generate. They permit the presence of strings containing verbs and arguments that don’t go together For example VP  V NP therefore Sneezed the book is a VP since “sneeze” is a verb and “the book” is a valid NP

Possible CFG Solution Intrans: Intransitive Trans: Transitive VP  V VP  V NP VP  V NP PP … VP  IntransV VP  TransV NP VP  TransV NP PP … Intrans: Intransitive Trans: Transitive

Auxiliaries subcategories Modals: can, could, may, might VP – Head verb bare stem Perfect: have VP – Head verb past participle Progressive: be VP – Head verb gerundive participle Passive: be Multiple auxiliaries appear in particular order modal < perfect < progressive < passive

Parameterization with feature: Get a feeling Sentence[plur] NP[plur] VP[plur] TranVerb[plur] Det[either] Noun[plur] NP[sing] Det[either] Noun[sing] The boys see the instructor

Some features Number (singular, plural) Person (I, you, him) Tense (past, present, future) Gender (feminine, masculine) Polarity (positive, negative) …

السلام عليكم ورحمة الله Thank you السلام عليكم ورحمة الله