<<

Natural Language Processing

• NLP is the branch of computer science focused on developing systems that allow CS 343: Artificial Intelligence computers to communicate with people Natural Language Processing using everyday language. • Also called Computational Linguistics – Also concerns how computational methods can aid the understanding of human language Raymond J. Mooney University of Texas at Austin

1 2

Communication Communication (cont)

• The goal in the production and comprehension of • Communication for the hearer: natural language is communication. – Perception: Map input modality to a string of words, e.g. optical character recognition (OCR) or speech • Communication for the speaker: recognition. – Intention: Decide when and what information should – Analysis: Determine the information content of the be transmitted (a.k.a. strategic generation). May string. require planning and reasoning about agents’ goals and • Syntactic interpretation (): Find the correct parse tree beliefs. showing the phrase structure of the string. • Semantic Interpretation: Extract the (literal) meaning of the – Generation: Translate the information to be string (). communicated (in internal logical representation or • Pragmatic Interpretation: Consider effect of the overall “language of thought”) into string of words in desired context on altering the literal meaning of a . natural language (a.k.a. tactical generation). – Incorporation: Decide whether or not to believe the content of the string and add it to the KB. – Synthesis: Output the string in desired modality, text or speech.

3 4

Communication (cont) , Semantic,

• Syntax concerns the proper ordering of words and its affect on meaning. – The dog bit the boy. – The boy bit the dog. – * Bit boy dog the the. – Colorless green ideas sleep furiously. • Semantics concerns the (literal) meaning of words, phrases, and sentences. – “plant” as a photosynthetic organism – “plant” as a manufacturing facility – “plant” as the act of sowing • Pragmatics concerns the overall communicative and social context and its effect on interpretation. – The ham sandwich wants another beer. (co-, ) – John thinks vanilla. (ellipsis)

5 6

1 Modular Comprehension

• Natural language is highly ambiguous and must be disambiguated. – I saw the man on the hill with a Acoustic/ Syntax Semantics Pragmatics telescope. Phonetic sound words parse literal meaning – I saw the Grand Canyon flying to LA. waves trees meaning (contextualized) – Time flies like an arrow. – Horse flies like a sugar cube. – Time runners like a coach. – Time cars like a Porsche.

7 8

Ambiguity is Ubiquitous Ambiguity is Explosive

• Speech Recognition • compound to generate enormous – “recognize speech” vs. “wreck a nice beach” – “youth in Asia” vs. “euthanasia” numbers of possible interpretations. • Syntactic Analysis • In English, a sentence ending in n – “I ate spaghetti with chopsticks” vs. “I ate spaghetti with meatballs.” n • Semantic Analysis prepositional phrases has over 2 syntactic – “The dog is in the pen.” vs. “The ink is in the pen.” interpretations (cf. Catalan numbers). – “I put the plant in the window” vs. “Ford put the plant in Mexico” – “I saw the man with the telescope”: 2 parses • Pragmatic Analysis – From “The Pink Panther Strikes Again”: – “I saw the man on the hill with the telescope.”: 5 parses – Clouseau: Does your dog bite? – “I saw the man on the hill in Texas with the telescope”: Hotel Clerk: No. 14 parses Clouseau: [bowing down to pet the dog] Nice doggie. [Dog barks and bites Clouseau in the hand] – “I saw the man on the hill in Texas with the telescope at Clouseau: I thought you said your dog did not bite! noon.”: 42 parses Hotel Clerk: That is not my dog. – “I saw the man on the hill in Texas with the telescope at 9 noon on Monday” 132 parses 10

Humor and Ambiguity Natural Languages vs. Computer Languages

• Many jokes rely on the ambiguity of language: • Ambiguity is the primary difference between – Groucho Marx: One morning I shot an elephant in my natural and computer languages. pajamas. How he got into my pajamas, I’ll never know. • Formal programming languages are designed to be – She criticized my apartment, so I knocked her flat. unambiguous, i.e. they can be defined by a – Noah took all of the animals on the ark in pairs. Except grammar that produces a unique parse for each the worms, they came in apples. sentence in the language. – Policeman to little boy: “We are looking for a thief with a bicycle.” Little boy: “Wouldn’t you be better using • Programming languages are also designed for your eyes.” efficient (deterministic) parsing, i.e. they are – Why is the teacher wearing sun-glasses. Because the deterministic context-free languages (DCLFs). class is so bright. – A sentence in a DCFL can be parsed in O(n) time where n is the length of the string.

11 12

2 Syntactic Parsing Context Free Grammars (CFG)

• Produce the correct syntactic parse tree for a • N a set of non-terminal symbols (or variables) sentence. • Σ a set of terminal symbols (disjoint from N) • R a set of productions or rules of the form A→β, where A is a non-terminal and β is a string of symbols from (Σ∪ N)* • S, a designated non-terminal called the start symbol

Simple CFG for ATIS English Sentence Generation

Grammar Lexicon • Sentences are generated by recursively rewriting S → NP VP Det → the | a | that | this the start symbol using the productions until only S → Aux NP VP Noun → book | flight | meal | money terminals symbols remain. S → VP Verb → book | include | prefer S NP → Pronoun Pronoun → I | he | she | me NP → Proper-Noun Proper-Noun → Houston | NWA VP Derivation NP → Det Nominal Aux → does or Nominal → Noun Prep → from | to | on | near | through Verb NP Parse Tree Nominal → Nominal Noun Nominal → Nominal PP book Det Nominal VP → Verb VP → Verb NP the Nominal PP VP → VP PP Noun Prep NP PP → Prep NP flight through Proper-Noun Houston

Parse Trees and Syntactic Ambiguity Prepositional Phrase Attachment Explosion

• If a sentence has more • A transitive English sentence ending in m than one possible prepositional phrases has at least 2m parses. derivation (parse tree) it is said to be syntactically I saw the man on the hill with a telescope on Tuesday in Austin…. ambiguous. • The exact number of parses is given by the Catalan numbers (where n=m+1)

1, 2, 5, 14, 132, 429, 1430, 4862, 16796, ……

17 18

3 Spurious Ambiguity Parsing

• Most parse trees of most NL sentences make no • Given a string of non-terminals and a CFG, sense. determine if the string can be generated by the CFG. – Also return a parse tree for the string – Also return all possible parse trees for the string • Must search space of derivations for one that derives the given string. – Top-Down Parsing: Start searching space of derivations for the start symbol. – Bottom-up Parsing: Start search space of reverse deivations from the terminal symbols in the string.

19

Parsing Example Top Down Parsing

S S

VP NP VP

Verb NP Pronoun book that flight book Det Nominal

that Noun

flight

Top Down Parsing Top Down Parsing

S S

NP VP NP VP

Pronoun ProperNoun X book

4 Top Down Parsing Top Down Parsing

S S

NP VP NP VP

ProperNoun Det Nominal X book

Top Down Parsing Top Down Parsing

S S

NP VP Aux NP VP

Det Nominal X book

Top Down Parsing Top Down Parsing

S S

Aux NP VP VP X book

5 Top Down Parsing Top Down Parsing

S S

VP VP

Verb Verb

book

Top Down Parsing Top Down Parsing

S S

VP VP

Verb Verb NP X book that

Top Down Parsing Top Down Parsing

S S

VP VP

Verb NP Verb NP

book book Pronoun

6 Top Down Parsing Top Down Parsing

S S

VP VP

Verb NP Verb NP

book Pronoun book ProperNoun X that

Top Down Parsing Top Down Parsing

S S

VP VP

Verb NP Verb NP

book ProperNoun book Det Nominal X that

Top Down Parsing Top Down Parsing

S S

VP VP

Verb NP Verb NP

book Det Nominal book Det Nominal

that that Noun

7 Top Down Parsing Bottom Up Parsing

S

VP

Verb NP

book Det Nominal

that Noun book that flight

flight

44

Bottom Up Parsing Bottom Up Parsing

Nominal

Noun Noun

book that flight book that flight

45 46

Bottom Up Parsing Bottom Up Parsing

Nominal Nominal

Nominal Noun Nominal Noun X Noun Noun

book that flight book that flight

47 48

8 Bottom Up Parsing Bottom Up Parsing

Nominal Nominal

Nominal PP Nominal PP

Noun Noun Det

book that flight book that flight

49 50

Bottom Up Parsing Bottom Up Parsing

Nominal Nominal

Nominal PP Nominal PP NP NP

Noun Det Nominal Noun Det Nominal

book that flight book that Noun

flight

51 52

Bottom Up Parsing Bottom Up Parsing

Nominal Nominal

Nominal PP Nominal PP S

NP NP VP Noun Det Nominal Noun Det Nominal

book that Noun book that Noun

flight flight

53 54

9 Bottom Up Parsing Bottom Up Parsing

Nominal Nominal

S Nominal PP Nominal PPX NP VP NP Noun Det Nominal X Noun Det Nominal

book that Noun book that Noun

flight flight

55 56

Bottom Up Parsing Bottom Up Parsing

VP NP NP

Verb Det Nominal Verb Det Nominal

book that Noun book that Noun

flight flight

57 58

Bottom Up Parsing Bottom Up Parsing

S S

VP VP X NP NP

Verb Det Nominal Verb Det Nominal

book that Noun book that Noun

flight flight

59 60

10 Bottom Up Parsing Bottom Up Parsing

VP VP

VP PP VP PP NP X NP Verb Det Nominal Verb Det Nominal

book that Noun book that Noun

flight flight

61 62

Bottom Up Parsing Bottom Up Parsing

VP VP NP NP NP Verb Det Nominal Verb Det Nominal

book that Noun book that Noun

flight flight

63 64

Bottom Up Parsing Top Down vs. Bottom Up

• Top down never explores options that will not lead to a full parse, but can explore many options that never connect to the actual sentence.

S • Bottom up never explores options that do not connect to the actual sentence but can explore VP options that can never lead to a full parse. NP • Relative amounts of wasted search depend on how Verb Det Nominal much the grammar branches in each direction.

book that Noun

flight

65 66

11 Syntactic Parsing & Ambiguity Statistical Parsing

• Just produces all possible parse trees. • Statistical parsing uses a probabilistic model of • Does not address the important issue of syntax in order to assign probabilities to each parse tree. ambiguity resolution. • Provides principled approach to resolving syntactic ambiguity. • Allows supervised learning of parsers from tree- banks of parse trees provided by human linguists. • Also allows unsupervised learning of parsers from unannotated text, but the accuracy of such parsers has been limited.

67 68

Probabilistic Context Free Grammar Simple PCFG for ATIS English (PCFG)

• A PCFG is a probabilistic version of a CFG Grammar Prob Lexicon where each production has a probability. S → NP VP 0.8 Det → the | a | that | this S → Aux NP VP 0.1 + 1.0 0.6 0.2 0.1 0.1 • Probabilities of all productions rewriting a S → VP 0.1 Noun → book | flight | meal | money NP → Pronoun 0.2 0.1 0.5 0.2 0.2 given non-terminal must add to 1, defining a NP → Proper-Noun 0.2 + 1.0 Verb → book | include | prefer distribution for each non-terminal. NP → Det Nominal 0.6 0.5 0.2 0.3 Nominal → Noun 0.3 Pronoun → I | he | she | me • String generation is now probabilistic where Nominal → Nominal Noun 0.2 + 1.0 0.5 0.1 0.1 0.3 Nominal → Nominal PP 0.5 Proper-Noun → Houston | NWA production probabilities are used to non- VP → Verb 0.2 0.8 0.2 1.0 deterministically select a production for VP → Verb NP 0.5 + Aux → does VP → VP PP 0.3 1.0 rewriting a given non-terminal. PP → Prep NP 1.0 Prep → from | to | on | near | through 0.25 0.25 0.1 0.2 0.2

69

Sentence Probability Syntactic Disambiguation

• Assume productions for each node are chosen • Resolve ambiguity by picking most probable parse independently. tree. • Probability of derivation is the product of the S D probabilities of its productions. P(D2) = 0.1 x 0.3 x 0.5 x 0.6 x 0.5 x 0.1 2 VP 0.6 x 0.3 x 1.0 x 0.5 x 0.2 x 0.3 P(D ) = 0.1 x 0.5 x 0.5 x 0.6 x 0.6 x S 1 0.1 D1 0.2 x 0.8 VP0.5 0.5 x 0.3 x 1.0 x 0.2 x 0.2 x = VP 0.5 0.00001296 Verb NP 0.6 0.5 x 0.8 0.5 PP Verb NP 0.6 book Det Nominal 1.0 = 0.0000216 0.5 0.6 0.3 book Det Nominal 0.5 the Noun Prep NP 0.2 0.6 0.5 0.2 the Nominal PP 1.0 flight through Proper-Noun 0.3 0.8 Noun Prep NP Houston 0.2 0.2 0.5 flight through Proper-Noun 0.8 Houston

71 72

12 Sentence Probability Three Useful PCFG Tasks

• Probability of a sentence is the sum of the • Observation likelihood: To classify and probabilities of all of its derivations. order sentences.

P(“book the flight through Houston”) = • Most likely derivation: To determine the

P(D1) + P(D2) = 0.0000216 + 0.00001296 most likely parse tree for a sentence. = 0.00003456 • Maximum likelihood training: To train a PCFG to fit empirical training data.

73 74

PCFG: Observation Likelihood PCFG: Most Likely Derivation

• What is the probability that a given string is • What is the most probable derivation (parse produced by a given PCFG. tree) for a sentence. • Can use a PCFG as a language model to choose between alternative sentences for speech recognition or .

S → NP VP 0.9 John liked the dog in the pen. O S → NP VP 0.9 S → VP 0.1 1 S S → VP 0.1 NP → Det A N 0.5 NP → Det A N NP → NP PP 0.3 ? The dog big barked. 0.5 NP VP NP → NP PP 0.3 NP → PropN 0.2 NP → PropN 0.2 PCFG A → ε 0.6 John V NP PP A → ε 0.6 A → Adj A 0.4 The big dog barked Parser A → Adj A 0.4 PP → Prep NP 1.0 ? liked the dog in the pen PP → Prep NP VP → V NP 0.7 1.0 O2 VP → V NP 0.7 VP → VP PP 0.3 X VP → VP PP 0.3 P(O2 | English) > P(O1 | English) ? English English 75

PCFG: Most Likely Derivation PCFG: Supervised Training

• What is the most probable derivation (parse • If parse trees are provided for training sentences, a tree) for a sentence. grammar and its parameters can be can all be estimated directly from counts accumulated from the tree-bank (with appropriate smoothing). Tree Bank

S John liked the dog in the pen. S → NP VP 0.9 NP VP S → NP VP 0.9 S → VP 0.1 S John V NP PP S → VP NP → Det A N 0.5 0.1 put the dog in the pen NP → NP PP 0.3 NP VP NP → Det A N 0.5 S NP → NP PP NP → PropN 0.2 PCFG 0.3 Supervised NP → PropN A → ε 0.6 John V NP NP VP 0.2 Parser A → ε 0.6 A → Adj A 0.4 John V NP PP PCFG A → Adj A PP → Prep NP 1.0 liked the dog in the pen 0.4 put the dog in the pen VP → V NP 0.7 Training PP → Prep NP 1.0 VP → V NP 0.7 VP → VP PP 0.3 . VP → VP PP 0.3 English . English 77 . 78

13 Estimating Production Probabilities PCFG: Maximum Likelihood Training

• Set of production rules can be taken directly • Given a set of sentences, induce a grammar that from the set of rewrites in the treebank. maximizes the probability that this data was generated from this grammar. • Parameters can be directly estimated from • Assume the number of non-terminals in the frequency counts in the treebank. grammar is specified. • Only need to have an unannotated set of sequences generated from the model. Does not need correct parse trees for these sentences. In this sense, it is unsupervised.

79 80

PCFG: Maximum Likelihood Training Vanilla PCFG Limitations

• Since probabilities of productions do not rely on specific words or concepts, only general structural Training Sentences S → NP VP 0.9 disambiguation is possible (e.g. prefer to attach John ate the apple S → VP 0.1 PPs to Nominals). A dog bit Mary NP → Det A N 0.5 Mary hit the dog NP → NP PP 0.3 NP → PropN 0.2 • Consequently, vanilla PCFGs cannot resolve John gave Mary the cat. PCFG A → ε 0.6 syntactic ambiguities that require semantics to . Training A → Adj A 0.4 . PP → Prep NP 1.0 resolve, e.g. ate with fork vs. meatballs. . VP → V NP 0.7 VP → VP PP 0.3 • In order to work well, PCFGs must be lexicalized, English i.e. productions must be specialized to specific words by including their head-word in their LHS non-terminals (e.g. VP-ate).

81 82

Example of Importance of Lexicalization Example of Importance of Lexicalization

• A general preference for attaching PPs to NPs • A general preference for attaching PPs to NPs rather than VPs can be learned by a vanilla PCFG. rather than VPs can be learned by a vanilla PCFG. • But the desired preference can depend on specific • But the desired preference can depend on specific words. words.

John put the dog in the pen. John put the dog in the pen. S → NP VP 0.9 S S → NP VP 0.9 S S → VP 0.1 S → VP 0.1 NP → Det A N 0.5 NP VP NP → Det A N 0.5 NP VP NP → NP PP 0.3 NP → NP PP 0.3 NP → PropN 0.2 PCFG John V NP PP NP → PropN 0.2 PCFG John V NP A → ε 0.6 Parser A → ε 0.6 Parser A → Adj A 0.4 put the dog in the pen A → Adj A 0.4 put the dog in the pen PP → Prep NP 1.0 PP → Prep NP 1.0 VP → V NP 0.7 VP → V NP 0.7 X VP → VP PP 0.3 VP → VP PP 0.3 English 83 English 84

14 Treebanks First WSJ Sentence

• English Penn Treebank: Standard corpus for ( (S testing syntactic parsing consists of 1.2 M words (NP-SBJ of text from the Wall Street Journal (WSJ). (NP (NNP Pierre) (NNP Vinken) ) (, ,) • Typical to train on about 40,000 parsed sentences (ADJP and test on an additional standard disjoint test set (NP (CD 61) (NNS years) ) (JJ old) ) of 2,416 sentences. (, ,) ) (VP (MD will) • Chinese Penn Treebank: 100K words from the (VP (VB join) Xinhua news service. (NP (DT the) (NN board) ) (PP-CLR (IN as) • Other corpora existing in many languages, see the (NP (DT a) (JJ nonexecutive) (NN director) )) Wikipedia article “Treebank” (NP-TMP (NNP Nov.) (CD 29) ))) (. .) ))

85 86

Parsing Evaluation Metrics Computing Evaluation Metrics

• PARSEVAL metrics measure the fraction of the

constituents that match between the computed and Correct Tree T Computed Tree P human parse trees. If P is the system’s parse tree and T S S VP is the human parse tree (the “gold standard”): VP – Recall = (# correct constituents in P) / (# constituents in T) Verb NP VP book Det Nominal – Precision = (# correct constituents in P) / (# constituents in P) Verb NP the Nominal PP PP • Labeled Precision and labeled recall require getting the book Det Nominal Noun Prep NP the Noun Prep NP non-terminal label on the constituent node correct to flight through Proper-Noun flight through Proper-Noun count as correct. Houston Houston • F is the harmonic mean of precision and recall. # Constituents: 12 # Constituents: 12 1 # Correct Constituents: 10 Recall = 10/12= 83.3% Precision = 10/12=83.3% F = 83.3% 87 1

Treebank Results Word Sense Disambiguation (WSD)

• Results of current state-of-the-art systems on the • Words in natural language usually have a English Penn WSJ treebank are slightly greater than fair number of different possible meanings. 90% labeled precision and recall. – Ellen has a strong interest in computational linguistics. – Ellen pays a large amount of interest on her credit card. • For many tasks (question answering, translation), the proper sense of each ambiguous word in a sentence must be determined.

89 90

15 Ambiguity Resolution Word Sense Disambiguation (WSD) is Required for Translation as Text Categorization • Syntactic and semantic ambiguities must be properly • Each sense of an ambiguous word is treated as a category. – “play” (verb) resolved for correct translation: • play-game – “John plays the guitar.” → “John toca la guitarra.” • play-instrument • play-role – “John plays soccer.” → “John juega el fútbol.” – “pen” (noun) • writing-instrument • An apocryphal story is that an early MT system gave • enclosure the following results when translating from English to • Treat current sentence (or preceding and current sentence) Russian and then back to English: as a document to be classified. – “play”: – “The spirit is willing but the flesh is weak.” ⇒ • play-game: “John played soccer in the stadium on Friday.” “The liquor is good but the meat is spoiled.” • play-instrument: “John played guitar in the band on Friday.” • play-role: “John played Hamlet in the theater on Friday.” – “Out of sight, out of mind.” ⇒ “Invisible idiot.” – “pen”: • writing-instrument: “John wrote the letter with a pen in New York.” • enclosure: “John put the dog in the pen in New York.” 91 92

Learning for WSD WSD “line” Corpus

• Assume part-of-speech (POS), e.g. noun, verb, • 4,149 examples from newspaper articles adjective, for the target word is determined. • Treat as a classification problem with the containing the word “line.” appropriate potential senses for the target word • Each instance of “line” labeled with one of given its POS as the categories. 6 senses from WordNet. • Encode context using a set of features to be used for disambiguation. • Each example includes a sentence • Train a classifier on labeled data encoded using containing “line” and the previous sentence these features. • Use the trained classifier to disambiguate future for context. instances of the target word given their contextual features.

93 94

Senses of “line” Experimental Data for WSD of “line”

• Product: “While he wouldn’t estimate the sale price, analysts have estimated that it would exceed $1 billion. Kraft also told analysts it plans • Sample equal number of examples of each to develop and test a line of refrigerated entrees and desserts, under the Chillery brand name.” sense to construct a corpus of 2,094. • Formation: “C-LD-R L-V-S V-NNA reads a sign in Caldor’s book department. The 1,000 or so people fighting for a place in line have no • Represent as simple binary vectors of word trouble filling in the blanks.” • Text: “Newspaper editor Francis P. Church became famous for a 1897 occurrences in 2 sentence context. editorial, addressed to a child, that included the line “Yes, Virginia, there is a Santa Clause.” – Stop words eliminated • Cord: “It is known as an aggressive, tenacious litigator. Richard D. Parsons, a partner at Patterson, Belknap, Webb and Tyler, likes the – Stemmed to eliminate morphological variation experience of opposing Sullivan & Cromwell to “having a thousand-pound tuna on the line.” • Final examples represented with 2,859 • Division: “Today, it is more vital than ever. In 1983, the act was entrenched in a new constitution, which established a tricameral parliament binary word features. along racial lines, whith separate chambers for whites, coloreds and Asians but none for blacks.” • Phone: “On the tape recording of Mrs. Guba's call to the 911 emergency line, played at the trial, the baby sitter is heard begging for an ambulance.” 95 96

16 Learning Algorithms Learning Curves for WSD of “line”

• Naïve Bayes – Binary features • K Nearest Neighbor – Simple instance-based algorithm with k=3 and Hamming distance • Perceptron – Simple neural-network algorithm. • C4.5 – State of the art decision-tree induction algorithm • PFOIL-DNF – Simple logical rule learner for Disjunctive Normal Form • PFOIL-CNF – Simple logical rule learner for Conjunctive Normal Form • PFOIL-DLIST – Simple logical rule learner for decision-list of conjunctive rules

97 98

Discussion of Learning Curves for WSD of “line” • Naïve Bayes and Perceptron give the best results. • Both use a weighted linear combination of evidence from many features. • Symbolic systems that try to find a small set of Other Syntactic Tasks relevant features tend to overfit the training data and are not as accurate. • Nearest neighbor method that weights all features equally is also not as accurate. • Of symbolic systems, decision lists work the best.

99

Word Segmentation Morphological Analysis

• Breaking a string of characters (graphemes) into a • Morphology is the field of linguistics that studies the sequence of words. internal structure of words. (Wikipedia) • In some written languages (e.g. Chinese) words • A morpheme is the smallest linguistic unit that has are not separated by spaces. semantic meaning (Wikipedia) • Even in English, characters other than white-space – e.g. “carry”, “pre”, “ed”, “ly”, “s” can be used to separate words [e.g. , ; . - : ( ) ] • Morphological analysis is the task of segmenting a word into its morphemes: • Examples from English URLs: – carried ⇒ carry + ed (past tense) – jumptheshark.com ⇒ jump the shark .com – independently in + (depend + ent) + ly – myspace.com/pluckerswingbar ⇒ ⇒ myspace .com pluckers wing bar – Googlers ⇒ (Google + er) + s (plural) ⊗⇒ myspace .com plucker swing bar – unlockable ⇒ un + (lock + able) ? ⇒ (un + lock) + able ?

17 Part Of Speech (POS) Tagging Phrase Chunking

• Annotate each word in a sentence with a • Find all non-recursive noun phrases (NPs) part-of-speech. and verb phrases (VPs) in a sentence. I ate the spaghetti with meatballs. – [NP I] [VP ate] [NP the spaghetti] [PP with] Pro V Det N Prep N [NP meatballs]. John saw the saw and decided to take it to the table. – [NP He ] [VP reckons ] [NP the current account PN V Det N Con V Part V Pro Prep Det N deficit ] [VP will narrow ] [PP to ] [NP only # • Useful for subsequent syntactic parsing and 1.8 billion ] [PP in ] [NP September ] word sense disambiguation.

Semantic Role Labeling (SRL)

• For each clause, determine the semantic role played by each noun phrase that is an to the verb. Other Semantic Tasks agent patient source destination instrument – John drove Mary from Austin to Dallas in his Toyota Prius. – The hammer broke the window. • Also referred to a “case role analysis,” “thematic analysis,” and “shallow semantic parsing”

106

Semantic Parsing Textual Entailment

• A semantic parser maps a natural-language • Determine whether one natural language sentence to a complete, detailed semantic sentence entails (implies) another under an representation (logical form). • For many applications, the desired output is ordinary interpretation. immediately executable by another program. • Example: Mapping an English database query to Prolog: How many cities are there in the US? answer(A, count(B, (city(B), loc(B, C), const(C, countryid(USA))), A))

107

18 Textual Entailment Problems from PASCAL Challenge

ENTAIL TEXT HYPOTHESIS MENT Eyeing the huge market potential, currently led by Google, Yahoo took over search Yahoo bought Overture. TRUE company Overture Services Inc last year. Microsoft's rival Sun Microsystems Inc. Pragmatics/Discourse Tasks bought Star Office last month and plans to boost its development as a Web-based Microsoft bought Star Office. FALSE device running over the Net on personal computers and Internet appliances. The National Institute for Psychobiology in Israel was established in May 1971 as the Israel was established in May FALSE Israel Center for Psychobiology by Prof. 1971. Joel. Since its formation in 1948, Israel fought Israel was established in many wars with neighboring Arab TRUE 1948. countries.

Anaphora Resolution/ Ellipsis Resolution Co-Reference

• Determine which phrases in a document refer • Frequently words and phrases are omitted to the same underlying entity. from sentences when they can be inferred – John put the carrot on the plate and ate it. from context.

"Wise men talk because they have something to say; – Bush started the war in Iraq. But the president foolsfools, talk because because they they have have to say to saysomething.“ something.“ (Plato) (Plato) needed the consent of Congress. • Some cases require difficult reasoning. • Today was Jack's birthday. Penny and Janet went to the store. They were going to get presents. Janet decided to get a kite. "Don't do that," said Penny. "Jack has a kite. He will make you take it back."

Information Extraction (IE)

• Identify phrases in language that refer to specific types of entities and relations in text. • Named entity recognition is task of identifying Other Tasks names of people, places, organizations, etc. in text. people organizations places – Michael Dell is the CEO of Dell Computer Corporation and lives in Austin Texas. • Relation extraction identifies specific relations between entities. – Michael Dell is the CEO of Dell Computer Corporation and lives in Austin Texas.

114

19 Question Answering Text Summarization

• Directly answer natural language questions • Produce a short summary of a longer document or based on information presented in a corpora article. – Article: With a split decision in the final two primaries and a flurry of of textual documents (e.g. the web). superdelegate endorsements, Sen. Barack Obama sealed the Democratic – When was Barack Obama born? (factoid) presidential nomination last night after a grueling and history-making campaign against Sen. Hillary Rodham Clinton that will make him the • August 4, 1961 first African American to head a major-party ticket. Before a chanting and cheering audience in St. Paul, Minn., the first-term senator from Illinois – Who was president when Barack Obama was savored what once seemed an unlikely outcome to the Democratic race born? with a nod to the marathon that was ending and to what will be another hard-fought battle, against Sen. John McCain, the presumptive Republican • John F. Kennedy nominee…. – How many presidents have there been since – Summary: Senator Barack Obama was declared the Barack Obama was born? presumptive Democratic presidential nominee. • 9

Machine Translation (MT) NLP Conclusions

• Translate a sentence from one natural • The need for disambiguation makes language understanding difficult. language to another. • Levels of linguistic processing: – Hasta la vista, bebé ⇒ – Syntax Until we see each other again, baby. – Semantics – Pragmatics • CFGs can be used to parse natural language but produce many spurious parses. • Statistical learning methods can be used to: – Automatically learn grammars from (annotated) corpora. – Compute the most likely interpretation based on a learned statistical model.

118

20