BİL711 Natural Language Processing

Slides:



Advertisements
Similar presentations
BİL711 Natural Language Processing1 Problems with CFGs We know that CFGs cannot handle certain things which are available in natural languages. In particular,
Advertisements

Syntactic analysis using Context Free Grammars. Analysis of language Morphological analysis – Chairs, Part Of Speech (POS) tagging – The/DT man/NN left/VBD.
Natural Language Processing - Parsing 1 - Language, Syntax, Parsing Problems in Parsing Ambiguity, Attachment / Binding Bottom vs. Top Down Parsing.
Chapter 9: Parsing with Context-Free Grammars
PARSING WITH CONTEXT-FREE GRAMMARS
Parsing with Context Free Grammars Reading: Chap 13, Jurafsky & Martin
CKY Parsing Ling 571 Deep Processing Techniques for NLP January 12, 2011.
Artificial Intelligence 2004 Natural Language Processing - Syntax and Parsing - Language, Syntax, Parsing Problems in Parsing Ambiguity, Attachment.
1 Earley Algorithm Chapter 13.4 October 2009 Lecture #9.
 Christel Kemke /08 COMP 4060 Natural Language Processing PARSING.
CS Basic Parsing with Context-Free Grammars.
Parsing context-free grammars Context-free grammars specify structure, not process. There are many different ways to parse input in accordance with a given.
Parsing with CFG Ling 571 Fei Xia Week 2: 10/4-10/6/05.
Amirkabir University of Technology Computer Engineering Faculty AILAB Efficient Parsing Ahmad Abdollahzadeh Barfouroush Aban 1381 Natural Language Processing.
Artificial Intelligence 2005/06 From Syntax to Semantics.
Syllabus Text Books Classes Reading Material Assignments Grades Links Forum Text Books עיבוד שפות טבעיות - שיעור שמונה Context Free Grammars and.
Amirkabir University of Technology Computer Engineering Faculty AILAB Parsing Ahmad Abdollahzadeh Barfouroush Aban 1381 Natural Language Processing Course,
CMSC 723 / LING 645: Intro to Computational Linguistics November 10, 2004 Lecture 10 (Dorr): CFG’s (Finish Chapter 9) Parsing (Chapter 10) Prof. Bonnie.
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
Syntactic Parsing with CFGs CMSC 723: Computational Linguistics I ― Session #7 Jimmy Lin The iSchool University of Maryland Wednesday, October 14, 2009.
CS 4705 Basic Parsing with Context-Free Grammars.
1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake.
Artificial Intelligence 2004 Natural Language Processing - Syntax and Parsing - Language Syntax Parsing.
Parsing SLP Chapter 13. 7/2/2015 Speech and Language Processing - Jurafsky and Martin 2 Outline  Parsing with CFGs  Bottom-up, top-down  CKY parsing.
Syntax Construction of phrases and sentences from morphemes and words. Usually the word syntax refers to the way words are arranged together. Syntactic.
Basic Parsing with Context- Free Grammars 1 Some slides adapted from Julia Hirschberg and Dan Jurafsky.
Context-Free Grammar CSCI-GA.2590 – Lecture 3 Ralph Grishman NYU.
1 Basic Parsing with Context Free Grammars Chapter 13 September/October 2012 Lecture 6.
11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin.
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.
TEORIE E TECNICHE DEL RICONOSCIMENTO Linguistica computazionale in Python: -Analisi sintattica (parsing)
1 CPE 480 Natural Language Processing Lecture 5: Parser Asst. Prof. Nuttanart Facundes, Ph.D.
CS 4705 Parsing More Efficiently and Accurately. Review Top-Down vs. Bottom-Up Parsers Left-corner table provides more efficient look- ahead Left recursion.
1 CKY and Earley Algorithms Chapter 13 October 2012 Lecture #8.
Chapter 10. Parsing with CFGs From: Chapter 10 of An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, by.
LINGUISTICA GENERALE E COMPUTAZIONALE ANALISI SINTATTICA (PARSING)
10. Parsing with Context-free Grammars -Speech and Language Processing- 발표자 : 정영임 발표일 :
Context-Free Parsing Read J & M Chapter 10.. Basic Parsing Facts Regular LanguagesContext-Free Languages Required Automaton FSMPDA Algorithm to get rid.
Profs. Necula CS 164 Lecture Top-Down Parsing ICOM 4036 Lecture 5.
Chapter 13: Parsing with Context-Free Grammars Heshaam Faili University of Tehran.
11 Syntactic Parsing. Produce the correct syntactic parse tree for a sentence.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Parsing with Context Free Grammars.
October 2005csa3180: Parsing Algorithms 11 CSA350: NLP Algorithms Sentence Parsing I The Parsing Problem Parsing as Search Top Down/Bottom Up Parsing Strategies.
Parsing with Context Free Grammars CSC 9010 Natural Language Processing Paula Matuszek and Mary-Angela Papalaskari This slide set was adapted from: Jim.
Parsing I: Earley Parser CMSC Natural Language Processing May 1, 2003.
Context Free Grammars Reading: Chap 9, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Rada Mihalcea.
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.
Lecture 1, 7/21/2005Natural Language Processing1 CS60057 Speech &Natural Language Processing Autumn 2007 Lecture August 2007.
Sentence Parsing Parsing 3 Dynamic Programming. Jan 2009 Speech and Language Processing - Jurafsky and Martin 2 Acknowledgement  Lecture based on  Jurafsky.
Natural Language - General
PARSING 2 David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
Quick Speech Synthesis CMSC Natural Language Processing April 29, 2003.
CS 4705 Lecture 10 The Earley Algorithm. Review Top-Down vs. Bottom-Up Parsers –Both generate too many useless trees –Combine the two to avoid over-generation:
csa3050: Parsing Algorithms 11 CSA350: NLP Algorithms Parsing Algorithms 1 Top Down Bottom-Up Left Corner.
Artificial Intelligence 2004
Computerlinguistik II / Sprachtechnologie Vorlesung im SS 2010 (M-GSW-10) Prof. Dr. Udo Hahn Lehrstuhl für Computerlinguistik Institut für Germanistische.
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
Top-Down Parsing.
Instructor: Nick Cercone CSEB - 1 Parsing and Context Free Grammars Parsers, Top Down, Bottom Up, Left Corner, Earley.
October 2005CSA3180: Parsing Algorithms 21 CSA3050: NLP Algorithms Parsing Algorithms 2 Problems with DFTD Parser Earley Parsing Algorithm.
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
Speech and Language Processing SLP Chapter 13 Parsing.
Parsing with Context Free Grammars. Slide 1 Outline Why should you care? Parsing Top-Down Parsing Bottom-Up Parsing Bottom-Up Space (an example) Top -
Natural Language Processing Vasile Rus
Basic Parsing with Context Free Grammars Chapter 13
Parsing and More Parsing
Lecture 7: Introduction to Parsing (Syntax Analysis)
CSA2050 Introduction to Computational Linguistics
Parsing I: CFGs & the Earley Parser
Presentation transcript:

BİL711 Natural Language Processing Syntax Syntax (of natural languages) describe how words are strung together to form components of sentences, and how those components are strung together to form sentences. In the core of the description of the syntax of a natural language, we use context-free grammars (CFGs). Groups of words may behave as a single unit or phrases, called as constituent. noun phrase, verb phrase CFGs will allow us to model these constituency facts. BİL711 Natural Language Processing

Some Applications of Syntax We may need knowledge of syntax in the following applications Grammar Checkers Question Answering / Database access Information Extraction Generation Translation Understanding BİL711 Natural Language Processing

BİL711 Natural Language Processing Constituency How do words group together? Some noun phrases (noun groups) in English: three parties from Brooklyn they three books All noun phrases can appear in similar syntactic environments: three parties from Brooklyn arrive they arrive Although whole noun phrase can appear before a verb, its parts may not appear before verb. * from arrive A noun phrase can be placed in certain places in a sentence. A prepositional phrase can be placed in different places in the sentences. On September seventh, I’d like to fly from Atlanta to Denver I’d like to fly on September seventh from Atlanta to Denver I’d like to fly from Atlanta to Denver on September seventh BİL711 Natural Language Processing

BİL711 Natural Language Processing Context Free Grammars CFGs capture constituency and ordering in natural language sentences. But we will need extra information to model: grammatical relations such as agreement subcategorization of verbs dependency relations between words and phrases So, a CFG will be in the core of the description of the syntax of a natural language. Context-Free Grammars are also called as Phrase-Structure Grammars. BİL711 Natural Language Processing

Why not Other Formalisms Why do we use CFG to describe the syntax of a natural language. Regular Grammars -- too weak Context Sensitive Grammars -- too strong. Turing Machines -- way too strong. Too weak means that they cannot capture/describe the syntactic structures which exist in natural languages. Too strong means that we do not need that much power to capture/describe the syntactic structures which exist in natural languages. For weaker methods, we have much efficient computational processes. BİL711 Natural Language Processing

BİL711 Natural Language Processing Definition of CFG A CFG consists of: Sets of terminals (either lexical items or parts of speech) Sets of non-terminals (the constituents of the language) Sets of rules of the form A  α where α is a string of zero or more terminals and non-terminals. One of non-terminals is designated as a start symbol. BİL711 Natural Language Processing

BİL711 Natural Language Processing An Example of CFG S  NP VP NP  Pronoun | NOM | Det NOM NOM  Noun | Noun NOM VP  Verb NP -- Lexicon -- (parts of speech) Prounoun  I | they Noun  flight | morning | evening Verb  prefer Det  a | the | that BİL711 Natural Language Processing

BİL711 Natural Language Processing Derivation A derivation is a sequence of rule applications. In each rule application, a non-terminal in a string is re-written as α if there is a rule in the form A  α. βAγ  βαγ We say that α1 derives αm (α1 * αm ) if: α1  …  αm The language generated by a CFG G is: LG = { w | w is a string of terminals and S derives w } A derivation can be represented by a parse tree. Mapping from a string of terminals to its parse tree is called as parsing. BİL711 Natural Language Processing

BİL711 Natural Language Processing Parse Tree S NP VP NP NOM Pronoun Verb Det Noun Noun I prefer a morning flight BİL711 Natural Language Processing

Parse Tree - Bracketed Notation Sometimes convenient to represent a parse tree in more compact format called bracketed notation. This format is similar to LISP format. [S [NP [Pro I] ] [VP [V prefer] [NP [Det a] [NOM [N morning] [NOM [N flight]]]] ] ] BİL711 Natural Language Processing

BİL711 Natural Language Processing Developing Grammars We have to do a lot to develop grammars for natural languages. We will look some trivial parts of grammars. Here we look at some constituents (syntactic substructures) in natural languages. The key constituents are: (We will investigate) Sentences Noun Phrases Verb Phrases Prepositional Phrases BİL711 Natural Language Processing

BİL711 Natural Language Processing Sentence Types Declarative Sentences S  NP VP He left Imperative Sentences S  VP Get out! Yes-No Questions S  Aux NP VP Did you decide? WH-Questions S  WH-Word Aux NP VP What did you decide? BİL711 Natural Language Processing

BİL711 Natural Language Processing Noun Phrases Each noun phrase has a head noun. -- a book A noun phrase the head noun may be preceded by pre-nominal modifiers and followed by post-nominal modifiers. Pre-Nominal Modifiers: Determiner -- a, the, that, this, any, some -- a book mass-nouns do not require determiners Pre-Determiners -- all -- all the flights, all flights Cardinal Numbers -- one, two -- two friends, one man Ordinal Numbers -- first,second,next,last,other -- the last flight Quantifiers -- many,several,few -- many fares Adjective Phrases -- the least expensive fare Adjectives can be grouped into a phrase called an adjective phrase. A simplified rule: NP  (PreDet) (Det) (Card) (Ord) (Quan) (AP) NOM BİL711 Natural Language Processing

Noun Phrases -- Post-Modifiers Three common post-modifiers: prepositional phrases -- all flights from Ankara non-finite clauses -- any flight arriving after 5 p.m. three common non-finite post-modifiers: gerundive, -ed, and infinitive forms. relative clauses -- a flight that serves dinner NOM  NOM PP (PP) (PP) NOM  NOM GerundVP NOM  NOM RelClause GerundVP  GerundV | GerundV NP | GerundV PP | GerundV NP PP GerundV  arriving | preferring | … RelClause  who VP | that VP BİL711 Natural Language Processing

BİL711 Natural Language Processing Conjunctions Noun phrases and other phrases can be conjoined with conjunctions such as and, or, but, … table and chair ... the flights that leaving Ankara and arriving in Istanbul he came from Ankara and he went to Istanbul. NP  NP and NP VP  VP and VP S  S and S BİL711 Natural Language Processing

BİL711 Natural Language Processing Recursive Structures Recursive rules may appear in our grammars. NP  NP PP the flight from Ankara VP  VP PP departed Ankara at 5 p.m. These rules allow us the following: Flights to Ankara Flights to Ankara from Istanbul Flights to Ankara from Istanbul in March Flights to Ankara from Istanbul in March on Friday Flights to Ankara from Istanbul in March on Friday under $100 Flights to Ankara from Istanbul in March on Friday under $100 with lunch BİL711 Natural Language Processing

Some Difficulties in Grammar Development When we use CFGs to describe the syntax of a natural language, we may encounter certain difficulties in the expression of some structures in natural languages. Some of these difficulties are: Agreement he flies … * he fly I fly .. * I flies this book * this books those books * those book Subcategorization * I disappeared the cat. (disappear cannot be followed by a noun phrase) BİL711 Natural Language Processing

BİL711 Natural Language Processing Agreement How can we modify our grammar to handle these agreement phenomena? We may expand our with multiple set of rules 3SgNP  … Non3SgNP  … But this will double the size of the grammar. A better way to deal with agreement problems without exploding the size of the grammar by parameterizing each non-terminal with feature structures. BİL711 Natural Language Processing

BİL711 Natural Language Processing SubCategorization A verb phrase may consists of a verb and a number of constituents. VP  Verb -- disappear VP  Verb NP -- prefer a morning flight VP  Verb NP PP -- leave Ankara in the morning VP  Verb PP -- leaving on Monday VP  Verb S -- You said there is only one flight Although a verb phrase can have many possible of constituents, not every verb is compatible with every verb phrase. Verbs have preferences for the kinds of constituents they co-occur with. Transitive verbs Intransitive verbs Modern grammars distinguish too many subcategories (100 subcategories) BİL711 Natural Language Processing

Some SubCategorization Frames Frame Verb Example  eat,sleep I want to eat NP prefer I prefer a morning flight NP NP show Show me all flights from Ankara PPfrom PPto fly I would like to fly from Ankara to Istanbul NP PPwith help Can you help me with a flight VPto prefer I would prefer to go by THY. VPbare can I can go from Ankara S mean This means THY has a hub in Istanbul BİL711 Natural Language Processing

BİL711 Natural Language Processing Parsing Parsing with a CFG is the task of assigning a correct parse tree (or derivation) to a string given some grammar. The correct means that it is consistent with the input and grammar. It doesn’t mean that it’s the “right” tree in global sense of correctness. The leaves of the parse tree cover all and only the input, and that parse tree corresponds to a valid derivation according to the grammar. The parsing can be viewed as a search. The search space corresponds to the space of parse trees generated by the grammar. The search is guided by the structure of space and by the input. First, we will look at basic (bad) methods of the parsing. After seeing what’s wrong with them, we will look at better methods. BİL711 Natural Language Processing

A Simple English Grammar S  NP VP Det  that | this | a | the S  Aux NP VP Noun  book | flight | meal | money S  VP Verb  book | include | prefer NP  Det NOM Aux  does NP  ProperNoun Prep  from | to | on NOM  Noun ProperNoun  Houston | TWA NOM  Noun NOM NOM  NOM PP VP  Verb VP  Verb NP PP  Prep NOM BİL711 Natural Language Processing

Basic Top-Down Parsing A top-down parser searches a parse tree by trying to build from the root node S (start symbol) down to leaves. First, we create the root node, then we create its children. We chose one of its children and then we create its children. We can search the search space of the parse trees: breadth first search -- level by level search depth first search -- first we search one of the children BİL711 Natural Language Processing

A Top-Down Search Space S S S NP VP Aux NP VP VP S S S S S S NP VP NP VP Aux NP VP Aux NP VP VP VP Det NOM PropN Det NOM PropN Verb NP Verb . Input: Book that flight BİL711 Natural Language Processing

Basic Bottom-Up Parsing In bottom-up parsing, the parser starts with the words of input, tries to build parse trees from words up. The parser is successful if the parser succeeds building a parse tree rooted in the start symbol that covers all of the input. BİL711 Natural Language Processing

A Bottom-Up Search Space Book that flight Noun Det Noun Verb Det Noun Book that flight Book that flight NOM NOM NOM NP NP NOM NOM VP NOM NOM Noun Det Noun Verb Det Noun Verb Det Noun Book that flight Book that flight Book that flight BİL711 Natural Language Processing

A Bottom-Up Search Space (cont.) VP NP NP VP NOM NOM Verb Det Noun Verb Det Noun Book that flight Book that flight S NP NOM Verb Det Noun Book that flight BİL711 Natural Language Processing

BİL711 Natural Language Processing Top-Down or Bottom-Up? Each of top-down and bottom-up parsing techniques has its own advantages and disadvantages. The top-down strategy never wastes time exploring trees cannot result in the start symbol (starts from there). On the other hand, bottom-up strategy may waste time in those kind of trees. But the top-down strategy spends with trees which are not consistent with the input. On the other hand, bottom-up strategy never suggests trees that are not at least locally grounded in the actual input. None of these two basic strategies are good enough to be used in the parsing of natural languages. BİL711 Natural Language Processing

BİL711 Natural Language Processing Search Control Issues How our search will take place? Which node in the tree will be expanded next? Which applicable grammar rule will be tried first? The answers of these questions determine how to control our search in the search space of trees. Are we going to use depth-first or breath-first search? BİL711 Natural Language Processing

A Top-Down Depth-First Left-to-Right Search In this top-down search, we will use: depth-first strategy -- we will choose a node and explore its sub-trees left-to-right -- we will choose the left-most node to explore For the chosen node, we will choose one of applicable rules (the first one) and we will apply it into that node. If there is more than one applicable rule, we keep a pointer to other applicable rules in a stack; so that if our choice fails we can backtrack to other alternatives. Let us look at how this method for our grammar and the following input: Does this flight include a meal? (Draw parse trees on the board) BİL711 Natural Language Processing

Top-Down Parsing with Bottom-Up Filtering When we choose applicable rules, we can use bottom-up information. For example, in our grammar we have: S  NP VP S  Aux NP VP S  VP If we want to parse the input: Does this flight serve a meal? Although all three of these rules are applicable, the first and the third ones will definitely fail because NP and VP cannot derive to strings starting with does (an auxiliary verb here). Can we make this decision before we choose an applicable rule? Yes. We can use left-corner filtering. BİL711 Natural Language Processing

Filtering with Left Corners The parser should not consider any grammar rule if the current input serve as the first word along the left edge of some derivation from this rule. the first word along the left edge of a derivation is called as the left-corner of the tree. B is a left-corner of A if the following relation holds: A * B In other words, B can be the left-corner of A if there is a derivation of A that begins with B. We will ask whether a part of speech (of the current input) can be left-corner of the current-node (non-terminal). BİL711 Natural Language Processing

BİL711 Natural Language Processing Left Corner prefer (or Verb) is a left-corner of VP VP NP NOM Verb Det Noun Noun prefer a morning flight BİL711 Natural Language Processing

Filtering with Left-Corners (cont.) Do not consider any expansion where the current input can not serve as the left-corner of that expansion. Category Left-Corners S Det, ProperNoun, Aux, Verb NP Det, ProperNoun NOM Noun VP Verb PP Prep BİL711 Natural Language Processing

Problems with Basic Top-Down Parser Even the top-down parser with bottom-up filtering has three problems that make it an insufficient solution to general-purpose parsing problem. Left-Recursion Ambiguity Inefficient Reparsing of Subtrees First we will talk about these three problems. Then we will present earley algorithm to avoid these problems. BİL711 Natural Language Processing

BİL711 Natural Language Processing Left-Recursion When left-recursive grammars are used, top-down depth-first left-to-right parsers can dive into an infinite path. A grammar is left-recursive if it contains at least one non-terminal A such that: A * A This kind of structures are common in natural language grammars. NP  NP PP We can convert a left-recursive grammar into an equivalent grammar which is not left-recursive. A  A |  ==> A  A’ A’  A’ |  Unfortunately, the resulting grammar may no longer be the most grammatically natural way to represent syntactic structures. BİL711 Natural Language Processing

BİL711 Natural Language Processing Ambiguity Top-down parser is not efficient at handling ambiguity. Local ambiguity lead to hypotheses that are locally reasonable but eventually lead nowhere. They lead to backtracking. Global ambiguity potentially leads to multiple parses for the same input (if we force it to do). The parsers without disambiguation tools must simply return all possible parses. But most of disambiguation tools require statistical and semantic knowledge. There will be many unreasonable parses. But most of applications do not want all possible parses, they want a single correct parse. The reason for many unreasonable parses, exponential number of parses are possible for certain inputs. BİL711 Natural Language Processing

BİL711 Natural Language Processing Ambiguity - Example If we add the following rules to our grammar: VP  VP PP NP  NP PP The following input: Show me the meal on flight 286 from Ankara to Istanbul. will have a lot of parses (14 parses?). Some of them are really strange parses. If we have PP  Prep NP Number of NP parses Number of PPs 2 2 5 3 14 4 132 5 469 6 BİL711 Natural Language Processing

Repeated Parsing of Subtrees The parser often builds valid trees for portion of the input, then discards them during backtracking, only to find that it has to rebuild them again. The parser creates small parse trees that fail because they do not cover all the input. The parser backtracks to cover more input, and recreates subtrees again and again. The same thing is repeated more than once unnecessarily. BİL711 Natural Language Processing

Repeated Parsing of Subtrees (cont.) Consider parsing the following NP with the following rules: a flight from Ankara to Istanbul on THY NP  Det NOM NP  NP PP NP  ProperNoun What happens with a top-down parser? BİL711 Natural Language Processing

Repeated Parsing of Subtrees (cont.) a flight from Ankara to Istanbul on THY a flight is parsed 4 times, from Ankara is parsed 3 times, ... BİL711 Natural Language Processing

BİL711 Natural Language Processing Dynamic Programming We want a parsing algorithm (using dynamic programming technique) that fills a table with solutions to subproblems that: Does not do repeated work Does top-down search with bottom-up filtering Solves the left-recursion problem Solves an exponential problem in O(N3) time. The answer is Earley Algorithm. BİL711 Natural Language Processing

BİL711 Natural Language Processing Earley Algorithm Earley algorithm fills a table in a single pass over the input. The table will be size N+1 where N is the number of words in the input. We may think that each table entry, called state, represents gaps between words. Each possible subtree is represented only once, and it can be shared by all the parses that need it. BİL711 Natural Language Processing

BİL711 Natural Language Processing States A state in a table entry contains three kinds of information: a subtree corresponding to a single grammar rule information about the progress made in completing this subtree the position of subtree with respect to to the input. We use a dot in the state’s grammar rule to indicate the progress made in recognizing it. We call this resulting structure dotted rule. A state’s position are represented by by two numbers indicating that where the state starts and where its dot lies. BİL711 Natural Language Processing

BİL711 Natural Language Processing States - Dotted Rule Three example states: (Ex: Book that flight) S   VP, [0,0] NP  Det  NOM, [1,2] VP  Verb NP , [0,3] The first state represents a top-down prediction for S. The first 0 indicates that the constituent predicted by this state should begin at position 0 (beginning of the input). The second 0 indicates that the dot lies at position 0. The second state represents an in-progress constituent. The constituent starts at position 1 and the dot lies at position 2. The third state represents a completed constituent. This state describes that VP is successfully parsed, and that constituent covers the input from position 0 to position 3. BİL711 Natural Language Processing

Graphical Representations of Dotted Rules A directed acyclic graph can be in the representation of dotted rules. VP  Verb NP  S   VP NP  Det  NOM  Book  that  flight  0 1 2 3 BİL711 Natural Language Processing

Parsing with Earley Algorithm New predicted states are based on existing table entries (predicted or in-progress) that predict a certain constituent at that spot. New in-progress states are created by updating older states to reflect the fact that the previously expected completed constituents have been located. New complete states are created when the dot in an in-progress state moves to the end. BİL711 Natural Language Processing

BİL711 Natural Language Processing More Specifically 1. Predict all the states 2. Read an input. See what predictions you can match. Extend matched states, add new predictions. Go to next state (state 2) 3. At the end, see if state[N+1] contains a complete S BİL711 Natural Language Processing

A Simple English Grammar (Ex.) S  NP VP Det  that | this | a | the S  Aux NP VP Noun  flight | meal | money S  VP Verb  book | include | prefer NP  Det NOM Aux  does NP  ProperNoun NOM  Noun ProperNoun  Houston | TWA NOM  Noun NOM VP  Verb VP  Verb NP BİL711 Natural Language Processing

BİL711 Natural Language Processing Example: Chart[0]    S [0,0] Dummy start state S   NP VP [0,0] Predictor NP   Det NOM [0,0] Predictor NP   ProperNoun [0,0] Predictor S   Aux NP VP [0,0] Predictor S   VP [0,0] Predictor VP   Verb [0,0] Predictor VP   Verb NP [0,0] Predictor BİL711 Natural Language Processing

BİL711 Natural Language Processing Example: Chart[1] Verb  book  [0,1] Scanner VP  Verb  [0,1] Completer S  VP  [0,1] Completer VP  Verb  NP [0,1] Completer NP   Det NOM [1,1] Predictor NP   ProperNoun [1,1] Predictor BİL711 Natural Language Processing

BİL711 Natural Language Processing Example: Chart[2] Det  that  [1,2] Scanner NP  Det  NOM [1,2] Completer NOM   Noun [2,2] Predictor NOM   Noun NOM [2,2] Predictor BİL711 Natural Language Processing

BİL711 Natural Language Processing Example: Chart[3] Noun  flight  [2,3] Scanner NOM  Noun  [2,3] Completer NOM  Noun  NOM [2,3] Completer NP  Det NOM  [1,3] Completer VP  Verb NP  [0,3] Completer S  VP  [0,3] Completer NOM   Noun [3,3] Predictor NOM   Noun NOM [3,3] Predictor BİL711 Natural Language Processing

BİL711 Natural Language Processing Earley Algorithm The Earley algorithm has three main functions that do all the work. Predictor: Adds predictions into the chart. It is activated when the dot (in a state) is in the front of a non-terminal which is not a part of speech. Completer: Moves the dot to the right when new constituents are found. It is activated when the dot is at the end of a state. Scanner: Reads the input words and enters states representing those words into the chart. It is activated when the dot (in a state) is in the front of a non-terminal which is a part of speech. The Earley algorithm uses theses functions to maintain the chart. BİL711 Natural Language Processing

BİL711 Natural Language Processing Predictor procedure PREDICTOR((A    B , [i,j])) for each (B  ) in GRAMMAR-RULES-FOR(B,grammar) do ENQUEUE((B   , [j,j]), chart[j]) end BİL711 Natural Language Processing

BİL711 Natural Language Processing Completer procedure COMPLETER((B    , [j,k])) for each (A    B , [i,j]) in chart[j] do ENQUEUE((A   B  , [i,k]), chart[k]) end BİL711 Natural Language Processing

BİL711 Natural Language Processing Scanner procedure SCANNER((A    B , [i,j])) if (B  PARTS-OF-SPEECH(word[j]) then ENQUEUE((B  word[j]  , [j,j+1]), chart[j+1]) end BİL711 Natural Language Processing

BİL711 Natural Language Processing Enqueue procedure ENQUEUE(state,chart-entry) if state is not already in chart-entry then Add state at the end of chart-entry) end BİL711 Natural Language Processing

BİL711 Natural Language Processing Earley Code function EARLEY-PARSE(words,grammar) returns chart ENQUEUE((   S, [0,0], chart[0]) for i from 0 to LENGTH(words) do for each state in chart[i] do if INCOMPLETE?(state) and NEXT-CAT(state) is not a PS then PREDICTOR(state) elseif INCOMPLETE?(state) and NEXT-CAT(state) is a PS then SCANNER(state) else COMPLETER(state) end return(chart) BİL711 Natural Language Processing

Retrieving Parse Trees from A Chart To retrieve parse trees from a chart, the representation of each state must be augmented with an additional field to store information about the completed states that generated its constituents. To collect parse trees, we have to update COMPLETER such that it should add a pointer to the older state onto the list of previous-states of the new state. Then, the parse tree can be created by retrieving these list of previous-states (starting from the completed state of S). BİL711 Natural Language Processing

Chart[0] - with Parse Tree Info S0    S [0,0] [] Dummy start state S1 S   NP VP [0,0] [] Predictor S2 NP   Det NOM [0,0] [] Predictor S3 NP   ProperNoun [0,0] [] Predictor S4 S   Aux NP VP [0,0] [] Predictor S5 S   VP [0,0] [] Predictor S6 VP   Verb [0,0] [] Predictor S7 VP   Verb NP [0,0] [] Predictor BİL711 Natural Language Processing

Chart[1] - with Parse Tree Info S8 Verb  book  [0,1] [] Scanner S9 VP  Verb  [0,1] [S8] Completer S10 S  VP  [0,1] [S9] Completer S11 VP  Verb  NP [0,1] [S8] Completer S12 NP   Det NOM [1,1] [] Predictor S13 NP   ProperNoun [1,1] [] Predictor BİL711 Natural Language Processing

Chart[2] - with Parse Tree Info S14 Det  that  [1,2] [] Scanner S15 NP  Det  NOM [1,2] [S14] Completer S16 NOM   Noun [2,2] [] Predictor S17 NOM   Noun NOM [2,2] [] Predictor BİL711 Natural Language Processing

Chart[3] - with Parse Tree Info S18 Noun  flight  [2,3] [] Scanner S19 NOM  Noun  [2,3] [S18] Completer S20 NOM  Noun  NOM [2,3] [S18] Completer S21 NP  Det NOM  [1,3] [S14,S19] Completer S22 VP  Verb NP  [0,3] [S8,S21] Completer S23 S  VP  [0,3] [S22] Completer S24 NOM   Noun [3,3] [] Predictor S25 NOM   Noun NOM [3,3] [] Predictor BİL711 Natural Language Processing

BİL711 Natural Language Processing Global Ambiguity S  Verb S  Noun Chart[0] S0    S [0,0] [] Dummy start state S1 S   Verb [0,0] [] Predictor S2 S   Noun [0,0] [] Predictor Chart[1] S3 Verb  book  [0,1] [] Scanner S4 Noun  book  [0,1] [] Scanner S5 S  Verb  [0,1] [S3] Predictor S6 S  Noun  [0,1] [S4] Predictor BİL711 Natural Language Processing