Fall 2005 Lecture Notes #3 EECS 595 / LING 541 / SI 661 Natural Language Processing.

Slides:



Advertisements
Similar presentations
Basic Parsing with Context-Free Grammars CS 4705 Julia Hirschberg 1 Some slides adapted from Kathy McKeown and Dan Jurafsky.
Advertisements

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
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.
Albert Gatt LIN3022 Natural Language Processing Lecture 8.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Word Classes and English Grammar.
Artificial Intelligence 2005/06 From Syntax to Semantics.
Syllabus Text Books Classes Reading Material Assignments Grades Links Forum Text Books עיבוד שפות טבעיות - שיעור שמונה Context Free Grammars and.
CMSC 723 / LING 645: Intro to Computational Linguistics November 10, 2004 Lecture 10 (Dorr): CFG’s (Finish Chapter 9) Parsing (Chapter 10) Prof. Bonnie.
NLP and Speech 2004 English Grammar
CS 4705 Lecture 7 Parsing with Context-Free Grammars.
CS 4705 Basic Parsing with Context-Free Grammars.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Grammar Sentence Constructs.
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.
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.
Chapter 9. Context-Free Grammars for English
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.
Context-Free Grammars for English 1 인공지능 연구실 허 희 근.
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.
BİL711 Natural Language Processing
CS 4705 Parsing More Efficiently and Accurately. Review Top-Down vs. Bottom-Up Parsers Left-corner table provides more efficient look- ahead Left recursion.
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)
Finite State Parsing & Information Extraction CMSC Intro to NLP January 10, 2006.
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.
Fall 2004 Lecture Notes #4 EECS 595 / LING 541 / SI 661 Natural Language Processing.
Chapter 13: Parsing with Context-Free Grammars Heshaam Faili University of Tehran.
11 Syntactic Parsing. Produce the correct syntactic parse tree for a sentence.
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.
PARSING David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
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.
October 2008CSA3180: Sentence Parsing1 CSA3180: NLP Algorithms Sentence Parsing Algorithms 2 Problems with DFTD Parser.
1 LIN6932 Spring 2007 LIN6932 Topics in Computational Linguistics Lecture 6: Grammar and Parsing (I) February 15, 2007 Hana Filip.
Chapter 12: Context-Free Grammars Heshaam Faili University of Tehran.
Parsing with Context-Free Grammars References: 1.Natural Language Understanding, chapter 3 (3.1~3.4, 3.6) 2.Speech and Language Processing, chapters 9,
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.
October 2005CSA3180: Parsing Algorithms 21 CSA3050: NLP Algorithms Parsing Algorithms 2 Problems with DFTD Parser Earley Parsing Algorithm.
Syllabus Text Books Classes Reading Material Assignments Grades Links Forum Text Books עיבוד שפות טבעיות - שיעור שמונה Context Free Parsing אורן.
November 2009HLT: Sentence Parsing1 HLT Sentence Parsing Algorithms 2 Problems with Depth First Top Down Parsing.
NLP. Introduction to NLP #include int main() { int n, reverse = 0; printf("Enter a number to reverse\n"); scanf("%d",&n); while (n != 0) { reverse =
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
Natural Language Processing Vasile Rus
Basic Parsing with Context Free Grammars Chapter 13
Natural Language - General
Parsing and More Parsing
CSA2050 Introduction to Computational Linguistics
Parsing I: CFGs & the Earley Parser
David Kauchak CS159 – Spring 2019
Presentation transcript:

Fall 2005 Lecture Notes #3 EECS 595 / LING 541 / SI 661 Natural Language Processing

Context-Free Grammars for English

Context-Free Rules and Trees Grammars CFG = PSG = BNF Derivations, parse trees

Constituency Examples: –Josephine –My neighbor’s cat –He –Peter, Paul, and Mary –The first three people to participate in the competition –with (?) Preposed and postposed constructions: –In the park, he plays with his dog. –He plays in the park with his dog. –He plays with his dog in the park.

Examples of noun phrases Terminals, non-terminals Parsing: the process of mapping from a string of words to one or more parse trees

Sentence-level constructions Declarative vs. imperative sentences Imperative sentences: S  VP Yes-no questions: S  Aux NP VP Wh-type questions: S  Wh-NP VP Fronting (less frequent): On Tuesday, I would like to fly to San Diego

Noun phrase Before the noun –Determiner: a, the, that, this, those, any, some –No determiner (e.g., in plural, mass nouns “dinner”) –Predeterminers: all –Postdeterminers: cardinals, ordinals, quantifiers: one, two; first, second, next, last, past, other, another; many, (a) few, several, much, a little –Adjectives: a first-class fare, a nonstop flight, the longest layover –AP: the least expensive fare –NP  (Det) (Card) (Ord) (Quant) (AP) Nominal

Noun phrases (Cont’d) Postmodifiers: –any stopovers [for Delta seven fifty one] –all flights [from Cleveland] [to Newark] Nominal  Nominal PP (PP) (PP) Non-finite postmodifiers: gerundive, -ed, infinitive

Gerunds any flights [arriving after ten p.m] Nominal  Nominal GerundVP GerundVP  GerundV NP | GerundV PP | GerundV | GerundV NP PP GerundV  being | preferring | arriving …

Infinitives and –ed forms the last flight to arrive in Boston I need to have dinner served which is the aircraft used by this flight?

Postnominal relative clauses Restrictive relative clauses: –A flight that serves breakfast –Flights that leave in the morning –The United flight that arrives in San Jose at ten p.m. Rules: –Nominal  Nominal RelClause –RelClause  (who | that) VP Multiple postnominal modifiers can be combined: –A boy from London studying French in Spain (what are the modifiers in the previous example)?

Combining post-modifiers A flight from Phoenix to Detroit leaving Monday evening Evening flights from Nashville to Houston that serve dinner

A slightly more complicated example The earliest American Airlines flight that I can get What rules are needed in the grammar for this type of constructions?

Coordination Coordinate noun phrases: –NP  NP and NP –S  S and S –Similar for VP, etc.

Agreement Examples: –Do any flights stop in Chicago? –Do I get dinner on this flight? –Does Delta fly from Atlanta to Boston? –What flights leave in the morning? –* What flight leave in the morning? Rules: –S  Aux NP VP –S  3sgAux 3sgNP VP –S  Non3sgAux Non3sgNP VP –3sgAux  does | has | can … –non3sgAux  do | have | can …

Agreement We now 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.

Combinatorial explosion What other phenomena will cause the grammar to expand? Solution: parameterization with feature structures (see Chapter 11)

The Verb phrase VP  Verb VP  Verb NP VP  Verb NP PP VP  Verb PP

Sentential complements You said there were two flights that were the cheapest You said you had a two hundred sixty six dollar fare VP  Verb S I want to fly from Milwaukee to Orlando I’m trying to find a flight that goes from Pittsburgh to Denver next Friday VP  Verb VP

Subcategorization Frames: –0: eat, sleep –NP: prefer, find, leave –NP NP: show, give –PP from PP to : fly, travel –NP PP with : help, load –VP to : prefer, want, need –VP barestem : can, would, might –S: mean

Subcategorization ambiguity Find me a flight –What phenomenon is related to this sentence? Others?

Auxiliaries Modals: can, could, may, might Perfect: have Progressive: be Passive: be What are their subcategories? Ordering: modal < perfect < progressive < passive

Parsing with Context-Free Grammars

Introduction Parsing = associating a structure (parse tree) to an input string using a grammar CFG are declarative, they don’t specify how the parse tree will be constructed Parsing programming languages is easy. They are designed to be unambiguous and efficiently parsed. However, natural languages are inherently ambiguous –I saw [the man] [with a telescope]. –I saw [the man with a telescope].

Applications Parse trees are used in –Grammar checking: MS Word –Semantic analysis: explaining ambiguity –Machine translation: parse tree operations –Question answering: e.g. “How many people in the Human Resources Department receive salaries above $30,000?” –Speech recognition: e.g. Put the file in the folder. Put the file and the folder. –information extraction, information retrieval, etc..

Parsing as search S  NP VPDet  that | this |a S  Aux NP VPNoun  book | flight | meal | money S  VPVerb  book | include | prefer NP  Det NominalAux  does Nominal  NounProper-Noun  Houston | TWA Nominal  Noun NominalPrep  from | to | on NP  Proper-Noun VP  Verb VP  Verb NP Nominal  Nominal PP

Parsing as search Book that flight. S VP NP Nom VerbDetNoun Bookthatflight Two types of constraints on the parses: a) some that come from the input string, b) others that come from the grammar

Top-down parsing S NPVP S AuxVP S S NP S VP DetNom S NPVP PropN S NPVP DetNom S VP VNP Aux S NPVPAux PropN S VP V

Bookthatflight Bookthatflight NounDetNoun Bookthatflight VerbDetNoun Bookthatflight NounDetNoun Bookthatflight VerbDetNoun Bookthatflight NounDetNoun Bookthatflight VerbDetNoun Bookthatflight VerbDetNoun Bookthatflight VerbDetNoun Bookthatflight VerbDetNoun NOM VPNP VP Bottom-up parsing NP VP

Comparing TD and BU parsers TD parser –never wastes time exploring trees that cannot result in an S –but ignores the input until it reaches the “leaves” of the tree. BU parser –never spends effort on trees that are not consistent with the input. –but constructs useless subtrees that do not lead to an S. Needed: some middle ground.

Basic TD parser Practically infeasible to generate all trees in parallel. Use depth-first strategy. When arriving at a tree that is inconsistent with the input, return to the most recently generated but still unexplored tree.

function TOP-DOWN-PARSE (input, grammar) returns a parse tree agenda  (Initial S tree, Beginning of input) current-search-state  POP (agenda) loop if SUCCESSFUL-PARSE? (current-search-state) then return TREE (current-search-state) else if CAT (NODE-TO-EXPAND (current-search-state)) is a POS then if CAT (node-to-expand)  POS (CURRENT-INPUT (current-search-state)) then PUSH (APPLY-LEXICAL-RULE (current-search-state), agenda) else return reject else PUSH (APPLY-RULES (current-search-state, grammar), agenda) if agenda is empty then return reject else current-search-state  NEXT (agenda) end A TD-DF-LR parser

An example Does this flight include a meal? We can add bottom-up filtering to eliminate the trees that are inconsistent with the input. This is called left corner (LC) parsing.

Problems with the basic parser Left-recursion: rules of the type: NP  NP PP solution: rewrite each rule of the form A  A  |  using a new symbol: A   A ’ A   A ’ |  Ambiguity: attachment ambiguity, coordination ambiguity, noun-phrase bracketing ambiguity Attachment ambiguity: I saw the Grand Canyon flying to New York Coordination ambiguity: old men and women

Problems with the basic parser Example: President Kennedy today pushed aside other White House business to devote all his time and attention to working on the Berlin crisis address he will deliver tomorrow night to the American people over nationwide television and radio. Solutions: return all parses or include disambiguation in the parser. Inefficient reparsing of subtrees: a flight from Indianapolis to Houston on TWA

The Earley algorithm (aka Chart Parser) Resolving: –Left-recursive rules –Ambiguity –Inefficient reparsing of subtrees A chart with N+1 entries Dotted rules –S . VP, [0,0] –NP  Det. Nominal, [1,2] –VP  V NP., [0,3]

Three operations Predictor (expands the rules) –Given S . VP, [0,0], derive VP . Verb, [0,0] and VP . Verb NP, [0,0] Scanner (scans the current word in the input if applicable) –Given VP . Verb NP, [0,0], derive VP  Verb., [0,1] and VP  Verb. NP, [0,1] if the current word is a Verb. Completer (completes parsing an entire rule) –Given NP  Det Nominal., [1,3], and VP  Verb. NP, [0,1], derive VP  Verb NP., [0,3]

Overview of Chart Parser Dynamic programming. All possible states for chart[n] are produced before reading the n+1 st word. Never parses the same subtree again. The idea of “incremental” parsing is close to how humans parse the sentences. Is chart table a representation of the human brain’s state?

Some Theoretical Limitations Chart parser is O(n 3 ) Fast CFG parsing requires fast Boolean matrix multiplication (Lee 2002), i.e. it is very unlikely that a much better algorithm exists for parsing. There is strong evidence showing that natural languages may not be context-free at all (Shieber 1985).

Parsing with FSAs Shallow parsing Useful for information extraction: noun phrases, verb phrases, locations, etc. The Fastus system (Appelt and Israel, 1997) Sample rules for noun groups: NG  Pronoun | Time-NP | Date-NP NG  (DETP) (Adjs) HdNns | DETP Ving HdNns DETP  DETP-CP | DETP-CP Complete determiner-phrases: “the only five”, “another three”, “this”, “many”, “hers”, “all”, “the most”

Sample FASTUS output Company Name:Bridgestone Sports Co. Verb Group:said Noun Group:Friday Noun Group:it Verb Group:had set up Noun Group:a joint venture Preposition:in Location:Taiwan Preposition:with Noun Group:a local concern Conjunction:and Noun Group:a Japanese trading house Verb Group:to produce Noun Group:golf clubs Verb Group:to be shipped Preposition:to Location:Japan