Computational Lexicology, Morphology and Syntax Diana Trandab ă ț Academic year 2015-2016.

Slides:



Advertisements
Similar presentations
Is natural language regular? Context –free? (chapter 13)
Advertisements

Jamie Frost – Franks Society MT10. What is language?
Syntactic analysis using Context Free Grammars. Analysis of language Morphological analysis – Chairs, Part Of Speech (POS) tagging – The/DT man/NN left/VBD.
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.
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
10. Lexicalized and Probabilistic Parsing -Speech and Language Processing- 발표자 : 정영임 발표일 :
Introduction and Jurafsky Model Resource: A Probabilistic Model of Lexical and Syntactic Access and Disambiguation, Jurafsky 1996.
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing Probabilistic Context Free Grammars (Chapter 14) Muhammed Al-Mulhem March 1,
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
Parsing I Miriam Butt May 2005 Jurafsky and Martin, Chapters 10, 13.
1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake.
1 Introduction: syntax and semantics Syntax: a formal description of the structure of programs in a given language. Semantics: a formal description of.
Chapter 3: Formal Translation Models
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.
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.
PARSING David Kauchak CS457 – Fall 2011 some slides adapted from Ray Mooney.
1 13. LANGUAGE AND COMPLEXITY 2007 년 11 월 03 일 인공지능연구실 한기덕 Text: Speech and Language Processing Page.477 ~ 498.
Introduction Syntax: form of a sentence (is it valid) Semantics: meaning of a sentence Valid: the frog writes neatly Invalid: swims quickly mathematics.
Natural Language Processing Lecture 6 : Revision.
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.
Context Free Grammars CIS 361. Introduction Finite Automata accept all regular languages and only regular languages Many simple languages are non regular:
Grammars CPSC 5135.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Parsing with Context Free Grammars.
Introduction to Language Theory
October 2005csa3180: Parsing Algorithms 11 CSA350: NLP Algorithms Sentence Parsing I The Parsing Problem Parsing as Search Top Down/Bottom Up Parsing Strategies.
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.
The Chomsky Hierarchy. Sentences The sentence as a string of words E.g I saw the lady with the binoculars string = a b c d e b f.
Albert Gatt Corpora and Statistical Methods Lecture 11.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
CS460/626 : Natural Language Processing/Speech, NLP and the Web (Lecture 29– CYK; Inside Probability; Parse Tree construction) Pushpak Bhattacharyya CSE.
November 2011CLINT-LN CFG1 Computational Linguistics Introduction Context Free Grammars.
CS : Speech, NLP and the Web/Topics in AI Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture-16: Probabilistic parsing; computing probability of.
Rules, Movement, Ambiguity
Chapter 3 Describing Syntax and Semantics
CSA2050 Introduction to Computational Linguistics Parsing I.
PARSING 2 David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
1 Context Free Grammars October Syntactic Grammaticality Doesn’t depend on Having heard the sentence before The sentence being true –I saw a unicorn.
NLP. Introduction to NLP Motivation –A lot of the work is repeated –Caching intermediate results improves the complexity Dynamic programming –Building.
Natural Language Processing
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.
English Syntax Read J & M Chapter 9.. Two Kinds of Issues Linguistic – what are the facts about language? The rules of syntax (grammar) Algorithmic –
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.
DERIVATION S RULES USEDPROBABILITY P(s) = Σ j P(T,S) where t is a parse of s = Σ j P(T) P(T) – The probability of a tree T is the product.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Formal Languages and Grammars
CSA3050: NLP Algorithms Sentence Grammar NLP Algorithms.
The Chomsky Hierarchy.
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
Formal grammars A formal grammar is a system for defining the syntax of a language by specifying sequences of symbols or sentences that are considered.
CS460/626 : Natural Language Processing/Speech, NLP and the Web (Lecture 25– Probabilistic Parsing) Pushpak Bhattacharyya CSE Dept., IIT Bombay 14 th March,
1 Statistical methods in NLP Course 5 Diana Trandab ă ț
Natural Language Processing : Probabilistic Context Free Grammars Updated 8/07.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesAlgebraic.
Natural Language Processing Vasile Rus
Grammars.
PROGRAMMING LANGUAGES
Basic Parsing with Context Free Grammars Chapter 13
PARSE TREES.
CS 388: Natural Language Processing: Statistical Parsing
CS 388: Natural Language Processing: Syntactic Parsing
David Kauchak CS159 – Spring 2019
David Kauchak CS159 – Spring 2019
Presentation transcript:

Computational Lexicology, Morphology and Syntax Diana Trandab ă ț Academic year

The sentence as a string of words I saw the lady with the binoculars a b c d e b f string = a b c d e b f

The relations of parts of the string to each other may be different I saw the lady with the binoculars is stucturally ambiguous Who has the binoculars?

[ I ] saw the lady [ with the binoculars ] = [a] b c d [e b f] I saw [ the lady with the binoculars] = a b [c d e b f]

How can we represent the difference? By assigning them different structures. We can represent structures with 'trees'. I read thebook

a. I saw the lady with the binoculars S NP VP VNP NPPP Isaw the lady with the binoculars I saw [the lady with the binoculars]

b. I saw the lady with the binoculars S NP VP VPPP I saw the lady with the binoculars I [ saw the lady ] with the binoculars

birds fly S NPVP NV birds fly S →NPVP NP → N VP → V Syntactic rules

S NPVP birdsfly a b ab = string

S A B a b S → A B A → a B → b

Rules Assumption: natural language grammars are rule-based systems What kind of grammars describe natural language phenomena? What are the formal properties of grammatical rules?

The Chomsky Hierarchy

Chomsky (1957) Syntactic Structures. The Hague: Mouton Chomsky, N. and G.A. Miller (1958) Finite- state languages Information and Control 1, Chomsky (1959) On certain formal properties of languages. Information and Control 2,

Rules in Linguistics 1. PHONOLOGY /s/ → [θ]  V ___V Rewrite /s/ as [θ] when /s/ occurs in context V ____ V With: V =auxiliary node s, θ=terminal nodes

Rules in Linguistics 2. SYNTAX S →NP VP VP→v NP→n Rewrite S as NP VP in any context With: S, NP, VP =auxiliary nodes v, n =terminal node

SYNTAX (phrase/sentence formation) SENTENCE : The boykissed the girl S UBJECTPREDICATE NOUN PHRASEVERB PHRASE ART + NOUNVERB + NOUN PHRASE S→NPVP VP→VNP NP→ARTN

Chomsky Hierarchy 0.Type 0 (recursively enumerable) languages Only restriction on rules: left-hand side cannot be the empty string (* Ø  …….) 1. Context-Sensitive languages - Context-Sensitive (CS) rules 2. Context-Free languages - Context-Free (CF) rules 3. Regular languages - Non-Context-Free (CF) rules 0 ⊇ 1 ⊇ 2 ⊇ 3 a ⊇ b meaning a properly includes b (a is a superset of b), i.e. b is a proper subset of a or b is in a

Generative power 0.Type 0 (recursively enumerable) languages - only restriction on rules: left-hand side cannot be the empty string (* Ø  …….) - is the most powerful system 3. Type 3(regular language) - is the least powerful

Rule Type – 3 Name: Regular Example: Finite State Automata (Markov-process Grammar) Rule type: a) right-linear A  xB or A  x with: A, B = auxiliary nodes and x = terminal node b) or left-linear A  Bx or A  x Generates: a m b n with m,n  1 Cannot guarantee that there are as many a’s as b’s; no embedding

A regular grammar for natural language sentences S→theA A→catB A→mouseB A→duckB B→bitesC B→seesC B→eatsC C→theD D→boy D→girl D→monkey the cat bites the boy the mouse eats the monkey the duck sees the girl

Regular grammars Grammar 1: Grammar 2:A → a A → a BA → B a B → b AB → A b Grammar 3: Grammar 4:A → a A → a BA → B aB → b B → b AB → A b Grammar 5:Grammar 6: S→a AA → A a S→b BA → B a A→a SB → b B→b b SB → A b S→  A → a

Grammars: non-regular Grammar 5:Grammar 6: S→A BA → a S→b BA → B a A→a SB → b B→b b SB → b A S→ 

Finite-State Automaton articlenoun NP NP1 NP2 adjective

NP article NP1 adjectiveNP1 nounNP2 NP → article NP1 NP1 →adjective NP1 NP1 → noun NP2

A parse tree S root node NPVPnon- terminal n vNP nodes detn terminal nodes

Rule Type – 2 Name: Context Free Example: Phrase Structure Grammars/ Push-Down Automata Rule type: A   with: A = auxiliary node  = any number of terminal or auxiliary nodes Recursiveness (centre embedding) allowed: A   A 

CF Grammar A Context Free grammar consists of: a)a finite terminal vocabulary V T b)a finite auxiliary vocabulary V A c)an axiom S  V A d)a finite number of context free rules of form A → γ, whereA  V A and γ  {V A  V T }* In natural language syntax S is interpreted as the start symbol for sentence, as in S → NP VP

Natural language Is English regular or CF? If centre embedding is required, then it cannot be regular Centre Embedding: 1.[The cat][likes tuna fish] ab 2.The cat the dog chased likes tuna fish a a b b 3.The cat the dog the rat bit chased likes tuna fish a a ab b b 4.The cat the dog the rat the elephant admired bit chased likes tuna fish a a a a b b b b ab aabb aaabbb aaaabbbb

[The cat][likes tuna fish] a b 2.[The cat] [the dog] [chased] [likes...] a a b b

Centre embedding S NPVP thelikes cattuna a b = ab

S NPVP likes NPStuna the b cat NP VP a the chased dog b a =aabb

S NPVP likes NPStuna the b cat NP VP a chased NP S b the dog NP VP a the bit rat b a =aaabbb

Natural language 2 More Centre Embedding: 1.If S 1, then S 2 a 2.Either S 3, or S 4 b Sentence with embedding: If either the man is arriving today or the woman is arriving tomorrow, then the child is arriving the day after. a =[if b =[either the man is arriving today] b =[or the woman is arriving tomorrow]] a =[then the child is arriving the day after] = abba

CS languages The following languages cannot be generated by a CF grammar (by pumping lemma): a n b m c n d m Swiss German: A string of dative nouns (e.g. aa), followed by a string of accusative nouns (e.g. bbb), followed by a string of dative-taking verbs (cc), followed by a string of accusative-taking verbs (ddd) = aabbbccddd = a n b m c n d m

Swiss German: Jan sait das (Jan says that) … merem Hanses Huushälfed aastriiche weHans/DATthe house/ACChelped paint we helped Hans paint the house abcd NPdat NPdat NPacc NPacc Vdat Vdat Vacc Vacc aab b c cd d

Context Free Grammars (CFGs) Sets of rules expressing how symbols of the language fit together, e.g. S -> NP VP NP -> Det N Det -> the N -> dog

What Does Context Free Mean? LHS of rule is just one symbol. Can have NP -> Det N Cannot have X NP Y -> X Det N Y

Grammar Symbols Non Terminal Symbols Terminal Symbols – Words – Preterminals

Non Terminal Symbols Symbols which have definitions Symbols which appear on the LHS of rules S -> NP VP NP -> Det N Det -> the N -> dog

Non Terminal Symbols Same Non Terminals can have several definitions S -> NP VP NP -> Det N NP -> N Det -> the N -> dog

Terminal Symbols Symbols which appear in final string Correspond to words Are not defined by the grammar S -> NP VP NP -> Det N Det -> the N -> dog

Parts of Speech (POS) NT Symbols which produce terminal symbols are sometimes called pre-terminals S -> NP VP NP -> Det N Det -> the N -> dog Sometimes we are interested in the shape of sentences formed from pre-terminals Det N V Aux N V D N

CFG - formal definition A CFG is a tuple (N, ,R,S) N is a set of non-terminal symbols  is a set of terminal symbols disjoint from N R is a set of rules each of the form A   where A is non-terminal S is a designated start-symbol

CFG - Example grammar: S  NP VP NP  N VP  V NP lexicon: V  kicks N  John N  Bill N = {S, NP, VP, N, V}  = {kicks, John, Bill} R = (see opposite) S = “S”

Exercise Write grammars that generate the following languages, for m > 0 (ab) m a n b m a n b n Which of these are Regular? Which of these are Context Free?

(ab) m for m > 0 S -> a b S -> a b S

(ab) m for m > 0 S -> a b S -> a b S S -> a X X -> b Y Y -> a b Y -> S

anbmanbm S -> A B A -> a A -> a A B -> b B -> b B

anbmanbm S -> A B A -> a A -> a A B -> b B -> b B S -> a AB AB -> a AB AB -> B B -> b B -> b B

Grammar Defines a Structure grammar: S  NP VP NP  N VP  V NP lexicon: V  kicks N  John N  Bill S NP N Johnkicks NPV VP N Bill

Different Grammar Different Stucture grammar: S  NP NP NP  N V NP  N lexicon: V  kicks N  John N  Bill S NP N Bill John V N NP kicks

Which Grammar is Best? The structure assigned by the grammar should be appropriate. The structure should – Be understandable – Allow us to make generalisations. – Reflect the underlying meaning of the sentence.

Ambiguity A grammar is ambiguous if it assigns two or more structures to the same sentence. NP  NP CONJ NP NP  N lexicon: CONJ  and N  John N  Bill The grammar should not generate too many possible structures for the same sentence.

Criteria for Evaluating Grammars Does it undergenerate? Does it overgenerate? Does it assign appropriate structures to sentences it generates? Is it simple to understand? How many rules are there? Does it contain just a few generalisations or is it full of special cases? How ambiguous is it? How many structures does it assign for a given sentence?

Probabilistic Context Free Grammar (PCFG) A PCFG is a probabilistic version of a CFG where each production has a probability. String generation is now probabilistic where production probabilities are used to non- deterministically select a production for rewriting a given non-terminal.

Characteristics of PCFGs In a PCFG, the probability P(A  β) expresses the likelihood that the non-terminal A will expand as β. – e.g. the likelihood that S  NP VP (as opposed to S  VP, or S  NP VP PP, or… ) can be interpreted as a conditional probability: – probability of the expansion, given the LHS non-terminal – P(A  β) = P(A  β|A) Therefore, for any non-terminal A, probabilities of every rule of the form A  β must sum to 1 – If this is the case, we say the PCFG is consistent

Simple PCFG for English S → NP VP S → Aux NP VP S → VP NP → Pronoun NP → Proper-Noun NP → Det Nominal Nominal → Noun Nominal → Nominal Noun Nominal → Nominal PP VP → Verb VP → Verb NP VP → VP PP PP → Prep NP Grammar Prob Det → the | a | that | this Noun → book | flight | meal | money Verb → book | include | prefer Pronoun → I | he | she | me Proper-Noun → Houston | NWA Aux → does 1.0 Prep → from | to | on | near | through Lexicon

Parse tree and Sentence Probability Assume productions for each node are chosen independently. Probability of a parse tree (derivation) is the product of the probabilities of its productions. Resolve ambiguity by picking most probable parse tree. Probability of a sentence is the sum of the probabilities of all of its derivations.

Example PCFG Rules & Probabilities S  NP VP1.0 NP  DT NN0.5 NP  NNS0.3 NP  NP PP 0.2 PP  P NP1.0 VP  VP PP 0.6 VP  VBD NP0.4 DT  the1.0 NN  gunman0.5 NN  building0.5 VBD  sprayed 1.0 NNS  bullets1.0 P  with1.0

Example Parse t 1` The gunman sprayed the building with bullets. S 1.0 NP 0.5 VP 0.6 DT 1.0 NN 0.5 VBD 1.0 NP 0.5 PP 1.0 DT 1.0 NN 0.5 P 1.0 NP 0.3 NNS 1.0 bullets with buildingthe Thegunman sprayed P (t 1 ) = 1.0 * 0.5 * 1.0 * 0.5 * 0.6 * 0.4 * 1.0 * 0.5 * 1.0 * 0.5 * 1.0 * 1.0 * 0.3 * 1.0 = VP 0.4

Another Parse t 2 S 1.0 NP 0.5 VP 0.4 DT 1.0 NN 0.5 VBD 1.0 NP 0.5 PP 1.0 DT 1.0 NN 0.5 P 1.0 NP 0.3 NNS 1.0 bullets with buildingthe Thegunmansprayed NP 0.2 P (t 2 ) = 1.0 * 0.5 * 1.0 * 0.5 * 0.4 * 1.0 * 0.2 * 0.5 * 1.0 * 0.5 * 1.0 * 1.0 * 0.3 * 1.0 = The gunman sprayed the building with bullets. P (sentence) = = P (t 1 ) + P(t 2 ) = = =

NLP with Regular Expressions User: Men are all alike ELIZA: IN WHAT WAY? User: They’re always bugging us about something or other ELIZA: CAN YOU THINK OF A SPECIFIC EXAMPLE? User: Well, my boyfriend made me come here ELIZA: YOUR BOYFRIEND MADE YOU COME HERE. User: He says I’m depressed much of the time ELIZA: I AM SORRY TO HEAR THAT YOU ARE DEPRESSED. Transcript with Eliza, simulation of a Rogerian psychotherapist (Weizenbaum, 1966)

How did it work?.* all.* → IN WHAT WAY.* always.* → CAN YOU THINK OF A SPECIFIC EXAMPLE.* I’m (depressed|sad).* → I AM SORRY TO HEAR YOU ARE \1.* I’m (depressed|sad).* → WHY DO YOU THINK YOU ARE \1?

Aside… What is intelligence? What does Eliza tell us about intelligence?

Great! See you next time!

PATR-II The PATR-II formalism can be viewed as a computer language for encoding linguistic information. A PATR-II grammar consists of a set of rules and a lexicon. The rules are CFG rules augmented with constaints. The lexicon provides information about terminal symbols.

Example PATR-II Grammar and Lexicon Grammar (grammar.grm) Rule s -> np vp Rule np -> n Rule vp -> v Lexicon (lexicon.lex) \w uther \c n \w sleeps \c v