Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Fall 2005 Lecture Notes #3 EECS 595 / LING 541 / SI 661 Natural Language Processing."— Presentation transcript:

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

2 Context-Free Grammars for English

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

4 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.

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

6 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

7 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

8 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

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

10 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?

11 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)?

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

13 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?

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

15 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 …

16 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.

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

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

19 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

20 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

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

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

23 Parsing with Context-Free Grammars

24 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].

25 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..

26 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

27 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

28 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

29 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

30 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.

31 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.

32 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

33 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.

34 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

35 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

36 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]

37 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]

38 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?

39 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).

40 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”

41 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


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

Similar presentations


Ads by Google