General Information on Context-free and Probabilistic Context-free Grammars İbrahim Hoça CENG784, Fall 2013.

Slides:



Advertisements
Similar presentations
Grammars, constituency and order A grammar describes the legal strings of a language in terms of constituency and order. For example, a grammar for a fragment.
Advertisements

Grammars, Languages and Parse Trees. Language Let V be an alphabet or vocabulary V* is set of all strings over V A language L is a subset of V*, i.e.,
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
Chapter 12 Lexicalized and Probabilistic Parsing Guoqiang Shan University of Arizona November 30, 2006.
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing Probabilistic Context Free Grammars (Chapter 14) Muhammed Al-Mulhem March 1,
Chapter 4 Normal Forms for CFGs Chomsky Normal Form n Defn A CFG G = (V, , P, S) is in chomsky normal form if each rule in G has one of.
PCFG Parsing, Evaluation, & Improvements Ling 571 Deep Processing Techniques for NLP January 24, 2011.
CS5371 Theory of Computation
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
1 Note As usual, these notes are based on the Sebesta text. The tree diagrams in these slides are from the lecture slides provided in the instructor resources.
Language Model. Major role: Language Models help a speech recognizer figure out how likely a word sequence is, independent of the acoustics. A lot of.
Normal forms for Context-Free Grammars
Chapter 3: Formal Translation Models
COP4020 Programming Languages
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
Context-Free Grammar CSCI-GA.2590 – Lecture 3 Ralph Grishman NYU.
Models of Generative Grammar Smriti Singh. Generative Grammar  A Generative Grammar is a set of formal rules that can generate an infinite set of sentences.
Lecture 21: Languages and Grammars. Natural Language vs. Formal Language.
Chapter 4 Context-Free Languages Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
Languages & Strings String Operations Language Definitions.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
Introduction Syntax: form of a sentence (is it valid) Semantics: meaning of a sentence Valid: the frog writes neatly Invalid: swims quickly mathematics.
BİL711 Natural Language Processing1 Statistical Parse Disambiguation Problem: –How do we disambiguate among a set of parses of a given sentence? –We want.
1 Statistical Parsing Chapter 14 October 2012 Lecture #9.
GRAMMARS David Kauchak CS159 – Fall 2014 some slides adapted from Ray Mooney.
A sentence (S) is composed of a noun phrase (NP) and a verb phrase (VP). A noun phrase may be composed of a determiner (D/DET) and a noun (N). A noun phrase.
Grammars CPSC 5135.
CS 3240: Languages and Computation Context-Free Languages.
The CYK Algorithm Presented by Aalapee Patel Tyler Ondracek CS6800 Spring 2014.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
Albert Gatt Corpora and Statistical Methods Lecture 11.
PARSING 2 David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 3: Introduction to Syntactic Analysis.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CPSC 422, Lecture 27Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27 Nov, 16, 2015.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
December 2011CSA3202: PCFGs1 CSA3202: Human Language Technology Probabilistic Phrase Structure Grammars (PCFGs)
GRAMMARS David Kauchak CS457 – Spring 2011 some slides adapted from Ray Mooney.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Chapter 4: Syntax analysis Syntax analysis is done by the parser. –Detects whether the program is written following the grammar rules and reports syntax.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CS460/626 : Natural Language Processing/Speech, NLP and the Web (Lecture 25– Probabilistic Parsing) Pushpak Bhattacharyya CSE Dept., IIT Bombay 14 th March,
Natural Language Processing : Probabilistic Context Free Grammars Updated 8/07.
Chapter 2. Formal Languages Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
Roadmap Probabilistic CFGs –Handling ambiguity – more likely analyses –Adding probabilities Grammar Parsing: probabilistic CYK Learning probabilities:
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Natural Language Processing Vasile Rus
PROGRAMMING LANGUAGES
PROGRAMMING LANGUAGES
System Software Unit-1 (Language Processors) A TOY Compiler
Context-Free Grammars: an overview
Even-Even Devise a grammar that generates strings with even number of a’s and even number of b’s.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
Top-Down Parsing.
Probabilistic and Lexicalized Parsing
CSCI 5832 Natural Language Processing
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
CHAPTER 2 Context-Free Languages
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 26
Discrete Mathematics and its Applications Rosen 7th ed., Ch. 13.1
David Kauchak CS159 – Spring 2019
Discrete Mathematics and its Applications Rosen 8th ed., Ch. 13.1
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Formal Languages Context free languages provide a convenient notation for recursive description of languages. The original goal of formalizing the structure.
Lecture 7: Definite Clause Grammars
David Kauchak CS159 – Spring 2019
Prof. Pushpak Bhattacharyya, IIT Bombay
Presentation transcript:

General Information on Context-free and Probabilistic Context-free Grammars İbrahim Hoça CENG784, Fall 2013

Outline Basics of Context-free Grammars (CFGs) Tree Structure Convenience of Tree Structures Natural Language Examples Probabilistic Context-free Grammars (PCFGs) PCFG Rules Computing the Probabilities in PCFGs Some Aspects of PCFGs

Basics of Context-free Grammars A CFG is a quadruple (V, Σ, P, S) where -V is a finite set of variables, -Σ (the alphabet) is a finite set of terminal symbols, -P is a finite set of rules, and -S is a distinguished element of V called the start symbol.

Basics of Context-free Grammars -A rule is an element of the set V x (VU)* -The rule [A, w] is written as A  w. -Lambda (null) rules are also possible: A  λ -The rules are written using the shorthand A  u|v to abbreviate A  u and A  v, the vertical bar being ‘or’.

Sample Derivations G =(V, Σ, P, S) V = {S,A} Σ = {a,b} P: S  AA A  AAA | bA | Ab | a S => AA => aA => aAAA => abAAA => abaAA => ababAA => ababaA => ababaa (a) S => AA => AAAA => aAAA => abAAA => abaAA => ababAA => ababaA => ababaa (b) S => AA => Aa => AAAa => AAbAa => AAbaa => AbAbaa => Ababaa => ababaa (c) S => AA => aA => aAAA => aAAa => abAAa => abAbAa => ababAa => ababaa (d)

Tree Structure Trees corresponding to the derivations in the previous slide.

Implementing CFG on Natural Language Let’s consider the following sentence: ‘nice dogs like cats’ Rules: S  NP VP NP  Adj N NP  N VP  V NP N  dogs | cats V  like Adj  nice Tree:

Convenience of Tree Structures -Natural language have a recursive structure. -Tree structures, hence CFGs, allow us to extend the context according to the properties of the relevant head nodes rather than limiting it with an arbitrary amount of adjacent words.

Convenience of Tree Structures Consider the verb agreement in the following construction: ‘Velocity of the seismic waves rises to …’ bigram:trigram: P(rises|waves)P(rises|seismic waves) quadrigram: P(rises|the seismic waves)

Convenience of Tree Structures -The verb ‘rises’ is apparently modified by a singular noun, which is ‘velocity’ in this case. -CFG allows us to capture this relationship between non-adjacent words.

Probabilistic Context-free Grammars (PCFG) -PCFG is simply a CFG with probabilities added to the rules, indicating how likely different rewritings are.

PCFG A PCFG G consists of: A set of terminals: {w k }, k = 1, …,V A set of non-terminals: {N i }, i = 1,…n A designated start symbol: N 1 A set of rules: {N i  ζ j }, (where ζ j is the sequence of terminals and non-terminals) A corresponding set of probabilities on rules such that:

PCFG Rules S  NP VP1.0 NP  NP PP0.4 PP  P NP1.0 VP  V NP0.7 NP  astronomers0.1 NP  ears0.18 NP  saw0.04 NP  stars0.18 NP  telescopes0.1 V  saw1.0 P  with1.0 Note that the NP rules are chosen to make the rules comply with the Chomsky Normal Form, which basically allows: A  B C A  w A  λ Where A, B, and C are non-terminals, and w is a terminal symbol.

Computing the Probabilities in PCFG where t is the parse tree and w 1m is the sentence from w 1 to w m. -This formula gives us the total probability of a sentence. -Probability of each tree is found by multiplication of the probabilities of the rules that created the tree.

Computing the Probabilities in PCFG P(t 1 ) = 1.0 × 0.1 × 0.7 × 1.0 × 0.4 × 0.18 × 1.0 × 1.0 × 0.18 =

Computing the Probabilities in PCFG P(t2) = 1.0 × 0.1 × 0.3 × 0.7 × 1.0 × 0.18 × 1.0 × 1.0 × 0.18 =

Computing the Probabilities in PCFG P(w 15 ) = P(t 1 ) + P(t 2 ) =

Some Aspects of PCFG + As grammars expand to cover a large and diverse corpus of text, they become increasingly ambiguous. A PCFG gives some idea of plausibility of different parses. - Nevertheless, a PCFG does not offer a very good idea of plausibility in itself, since its probability estimates are based purely on structural factors, and do not include lexical co- occurrence.

Some Aspects of PCFG + Real text tends to have grammatical mistakes, disfluencies and errors. This problem can be avoided to some extent with a PCFG by ruling out nothing excluded by the grammar but instead, by giving implausible sentences a low probability. - In a PCFG, the probability of a smaller tree is greater than a larger tree. For instance, the most frequent length for Wall Street Journal sentences is around 23 words. A PCFG gives too much of the probability mass to very short sentences.