Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMSC 723 / LING 645: Intro to Computational Linguistics November 3, 2004 Lecture 9 (Dorr): Word Classes, POS Tagging (Chapter 8) Intro to Syntax (Start.

Similar presentations


Presentation on theme: "CMSC 723 / LING 645: Intro to Computational Linguistics November 3, 2004 Lecture 9 (Dorr): Word Classes, POS Tagging (Chapter 8) Intro to Syntax (Start."— Presentation transcript:

1 CMSC 723 / LING 645: Intro to Computational Linguistics November 3, 2004 Lecture 9 (Dorr): Word Classes, POS Tagging (Chapter 8) Intro to Syntax (Start chapter 9) Prof. Bonnie J. Dorr Dr. Christof Monz TA: Adam Lee

2 Administrivia  Assignment 2 extension: Now due one week later. NOVEMBER 17, 2004

3 Word Classes and Part-of-Speech Tagging  Definition and Example  Motivation  Word Classes  Rule-based Tagging  Stochastic Tagging  Transformation-Based Tagging  Tagging Unknown Words

4 Definition “The process of assigning a part-of-speech or other lexical class marker to each word in a corpus” (Jurafsky and Martin) the girl kissed the boy on the cheek WORDS TAGS N V P DET

5 An Example the girl kiss the boy on the cheek LEMMATAG +DET +NOUN +VPAST +DET +NOUN +PREP +DET +NOUN the girl kissed the boy on the cheek WORD From: http://www.xrce.xerox.com/competencies/content-analysis/fsnlp/tagger.en.html

6 Motivation  Speech synthesis — pronunciation  Speech recognition — class-based N-grams  Information retrieval — stemming, selection high-content words  Word-sense disambiguation  Corpus analysis of language & lexicography

7 Word Classes  Basic word classes: Noun, Verb, Adjective, Adverb, Preposition, …  POS based on morphology and syntax  Open vs. Closed classes –Open: Nouns, Verbs, Adjectives, Adverbs. –Closed: determiners: a, an, the pronouns: she, he, I prepositions: on, under, over, near, by, …

8 Open Class Words  Every known human language has nouns and verbs  Nouns: people, places, things –Classes of nouns proper vs. common count vs. mass  Verbs: actions and processes  Adjectives: properties, qualities  Adverbs: hodgepodge! –Unfortunately, John walked home extremely slowly yesterday

9 Closed Class Words  Idiosyncratic  Examples: –prepositions: on, under, over, … –particles: up, down, on, off, … –determiners: a, an, the, … –pronouns: she, who, I,.. –conjunctions: and, but, or, … –auxiliary verbs: can, may should, … –numerals: one, two, three, third, …

10 Prepositions from CELEX

11 English Single-Word Particles

12 Pronouns in CELEX

13 Conjunctions

14 Auxiliaries

15 Word Classes: Tag Sets  Vary in number of tags: a dozen to over 200  Size of tag sets depends on language, objectives and purpose –Some tagging approaches (e.g., constraint grammar based) make fewer distinctions e.g., conflating prepositions, conjunctions, particles –Simple morphology = more ambiguity = fewer tags

16 Word Classes: Tag set example PRP PRP$

17 Example of Penn Treebank Tagging of Brown Corpus Sentence The/DT grand/JJ jury/NN commented/VBD on/IN a/DT number/NN of/IN other/JJ topics/NNS./. VB DT NN. Book that flight. VBZ DT NN VB NN ? Does that flight serve dinner ?

18 The Problem  Words often have more than one word class: this –This is a nice day = PRP –This day is nice = DT –You can go this far = RB

19 Word Class Ambiguity (in the Brown Corpus) Unambiguous (1 tag): 35,340 Ambiguous (2-7 tags): 4,100 2 tags3,760 3 tags264 4 tags61 5 tags12 6 tags2 7 tags1 (Derose, 1988)

20 Part-of-Speech Tagging  Rule-Based Tagger: ENGTWOL  Stochastic Tagger: HMM-based  Transformation-Based Tagger: Brill

21 Rule-Based Tagging  Basic Idea: –Assign all possible tags to words –Remove tags according to set of rules of type: if word+1 is an adj, adv, or quantifier and the following is a sentence boundary and word-1 is not a verb like “consider” then eliminate non-adv else eliminate adv. –Typically more than 1000 hand-written rules, but may be machine-learned.

22 Sample ENGTWOL Lexicon

23 Stage 1 of ENGTWOL Tagging  First Stage: Run words through Kimmo-style morphological analyzer to get all parts of speech.  Example: Pavlov had shown that salivation … PavlovPAVLOV N NOM SG PROPER hadHAVE V PAST VFIN SVO HAVE PCP2 SVO shownSHOW PCP2 SVOO SVO SV thatADV PRON DEM SG DET CENTRAL DEM SG CS salivationN NOM SG

24 Stage 2 of ENGTWOL Tagging  Second Stage: Apply constraints.  Constraints used in negative way.  Example: Adverbial “that” rule Given input: “that” If (+1 A/ADV/QUANT) (+2 SENT-LIM) (NOT -1 SVOC/A) Then eliminate non-ADV tags Else eliminate ADV

25 Stochastic Tagging  Based on probability of certain tag occurring given various possibilities  Necessitates a training corpus  No probabilities for words not in corpus.  Training corpus may be too different from test corpus.

26 Stochastic Tagging (cont.) Simple Method: Choose most frequent tag in training text for each word! –Result: 90% accuracy –Why? –Baseline: Others will do better –HMM is an example

27 HMM Tagger  Intuition: Pick the most likely tag for this word.  HMM Taggers choose tag sequence that maximizes this formula: –P(word|tag) × P(tag|previous n tags)  Let T = t 1,t 2,…,t n Let W = w 1,w 2,…,w n Find POS tags that generate a sequence of words, i.e., look for most probable sequence of tags T underlying the observed words W.

28 Start with Bigram-HMM Tagger  argmax T P(T|W)  argmax T P(T)P(W|T)  argmax t P(t 1 …t n )P(w 1 …w n |t 1 …t n )  argmax t [P(t 1 )P(t 2 |t 1 )…P(t n |t n-1 )][P(w 1 |t 1 )P(w 2 |t 2 )…P(w n |t n )]  To tag a single word: t i = argmax j P(t j |t i-1 )P(w i |t j )  How do we compute P(t i |t i-1 )? –c(t i-1 t i )/c(t i-1 )  How do we compute P(w i |t i )? –c(w i,t i )/c(t i )  How do we compute the most probable tag sequence? –Viterbi

29 An Example  Secretariat/NNP is/VBZ expected/VBN to/TO race/VB tomorrow/NN  People/NNS continue/VBP to/TO inquire/VB the DT reason/NN for/IN the/DT race/NN for/IN outer/JJ space/NN  to/TOrace/??? the/DTrace/???  t i = argmax j P(t j |t i-1 )P(w i |t j ) –max[P(VB|TO)P(race|VB), P(NN|TO)P(race|NN)]  Brown: –P(NN|TO) =.021 × P(race|NN) =.00041=.000007 –P(VB|TO) =.34 × P(race|VB) =.00003=.00001

30 An Early Approach to Statistical POS Tagging  PARTS tagger (Church, 1988): Stores probability of tag given word instead of word given tag.  P(tag|word) × P(tag|previous n tags)  Compare to: P(word|tag) × P(tag|previous n tags)  Consider this alternative (on your own). http://www.comp.lancs.ac.uk/ucrel/claws/trial.html

31 Transformation-Based Tagging (Brill Tagging)  Combination of Rule-based and stochastic tagging methodologies –Like rule-based because rules are used to specify tags in a certain environment –Like stochastic approach because machine learning is used—with tagged corpus as input  Input: –tagged corpus –dictionary (with most frequent tags)

32 Transformation-Based Tagging (cont.)  Basic Idea: –Set the most probable tag for each word as a start value –Change tags according to rules of type “if word-1 is a determiner and word is a verb then change the tag to noun” in a specific order  Training is done on tagged corpus: –Write a set of rule templates –Among the set of rules, find one with highest score –Continue from 2 until lowest score threshold is passed –Keep the ordered set of rules  Rules make errors that are corrected by later rules

33 TBL Rule Application  Tagger labels every word with its most-likely tag –For example: race has the following probabilities in the Brown corpus: P(NN|race) =.98 P(VB|race)=.02  Transformation rules make changes to tags –“Change NN to VB when previous tag is TO” … is/VBZ expected/VBN to/TO race/NN tomorrow/NN becomes … is/VBZ expected/VBN to/TO race/VB tomorrow/NN

34 TBL: Rule Learning  2 parts to a rule –Triggering environment –Rewrite rule  The range of triggering environments of templates (from manning & Schutze 1999:363) Schemat i-3 t i-2 t i-1 t i t i+1 t i+2 t i+3 1* 2* 3* 4* 5* 6* 7* 8* 9*

35 TBL: The Algorithm  Step 1: Label every word with most likely tag (from dictionary)  Step 2: Check every possible transformation & select one which most improves tagging  Step 3: Re-tag corpus applying the rules  Repeat 2-3 until some criterion is reached, e.g., X% correct with respect to training corpus  RESULT: Sequence of transformation rules

36 TBL: Rule Learning (cont.)  Problem: Could apply transformations ad infinitum!  Constrain the set of transformations with “templates”: –Replace tag X with tag Y, provided tag Z or word Z’ appears in some position  Rules are learned in ordered sequence  Rules may interact.  Rules are compact and can be inspected by humans

37 Templates for TBL

38 TBL: Problems  First 100 rules achieve 96.8% accuracy First 200 rules achieve 97.0% accuracy  Execution Speed: TBL tagger is slower than HMM approach  Learning Speed: Brill’s implementation can take over a day (600k tokens) BUT … (1) Learns small number of simple, non-stochastic rules (2) Can be made to work faster with FST (3) Best performing algorithm on unknown words

39 Tagging Unknown Words  New words added to (newspaper) language 20+ per month  Plus many proper names …  Increases error rates by 1-2%  Method 1: assume they are nouns  Method 2: assume the unknown words have a probability distribution similar to words only occurring once in the training set.  Method 3: Use morphological information, e.g., words ending with –ed tend to be tagged VBN.

40 Evaluation  The result is compared with a manually coded “Gold Standard” –Typically accuracy reaches 96-97% –This may be compared with result for a baseline tagger (one that uses no context).  Important: 100% is impossible even for human annotators.

41 Why do we need to learn POS?  Grammar induction for different languages  Parser induction for different languages Note: Grammars and Parsing are the next two topics.

42 What is Grammar?  A vogue in the 19 th century to describe the structures of an area of knowledge (e.g., Busby’s “ A Grammar of Music” Field’s “A Grammar of Colouring”)  The meaning of grammar has changed: –Used to be: “A listing of principles or structures” –Now: “principles or structures as a field of inquiry” –The grammar of syntax  Children’s syntax  Not meaning

43 Who cares?  Grammar checkers  Question answering / database access  Information extraction  Generation  Translation

44 Syntax  We just covered: POS categories  To be covered: –Constituency –Grammatical relations –Subcategorization and dependencies

45 What is a constituent?  The idea: groups of words may behave as a single unit or phrase  Examples: –“she” –“Michael” –“well-weathered three-story structure”  How can we model the constituency? –With context-free grammars

46 Context Free Grammars  Chomsky (1956) Backus (1959)  Capture constituents and ordering –Need something else for grammatical relations and dependency relations  Consists of –Set of terminals (either lexical items or POS) –Set of non-terminal (the constituent of language) –Sets of rules of the form A → , where  is a string of zero or more terminals and non-terminals  They are equivalent to Backus-Naur form grammars

47 Context-Free Grammars  Set of rules (productions) – expressing the way symbols of the language can be grouped together –NP → Det Nominal –NP → Proper Noun –Nominal → Noun | Noun Nominal  Lexicon –Det → a –Det → the –Noun → flight

48 Another Example S → NP VP NP → Det Nominal Nominal → Noun VP → V Det → a Noun → flight V → left

49 Grammar L 0

50 Lexicon L 0

51 Derivations and Trees S NPVP NP Nom Noun DetVerbPro flightmorninga preferI [ S [ NP [ Pro I]] [ VP [ V prefer] [ NP [ Det a] [ Nom [ N morning] [ N flight]]]]] S → NP VP, NP → Pro, Pro → I, VP → V NP, V → prefer, NP → Det Nom, Det → a, Nom → Noun Nom, Noun → morning, Noun → flight

52 Formal Definition of CFG  Set of non-terminal symbols N  Set of terminals   Set of productions A →  A  N,  -string  (  N)*  A designated start symbol

53 As Opposed to What?  Regular expressions  Context sensitive grammars  Turing Machines

54 Chomsky Hierarchy

55 Rule Skeletons for Chomsky Hierarchy

56 What does Context-Free Mean? Lefthand side of rule sits there all by itself!

57 Grammar Development

58 Key Constituents  Sentences  Noun phrases  Verb phrases  Prepositional phrases

59 Sentence Types  Declaratives S → NP VP (e.g., John left)  Imperatives S → VP (e.g., Leave!)  Yes-No Questions S → Aux NP VP (e.g., Did John leave?)  WH Questions S → Wh-word VP (e.g., who left?) S → Wh –word Aux NP VP (e.g., When did John leave? )

60 Noun Phrase  Head  Pre-nominal modifiers  Post-nominal modifiers

61 Before the Noun  Determiner: a, the, that, this, those, any, some  No determiner (e.g., in plural, mass nouns “dinner”)  Predeterminers: all (e.g., all the flights)  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 (Adjective phrase): the least expensive fare  NP → (Det) (Card) (Ord) (Quant) (AP) Nominal

62 After the Noun  Prepositional phrases any stopovers [for Delta seven fifty one] all flights [from Cleveland] [to Newark] Nominal → Nominal PP (PP) (PP)  Non-finite clauses: gerundive, -ed, infinitive Any flights arriving after 11:00 am.  Relative clauses A flight that serves breakfast

63 Gerunds  any flights [arriving after ten p.m]  General Form: Nominal → Nominal GerundVP  GerundVP → GerundV NP | GerundV PP | GerundV | GerundV NP PP  GerundV → being | preferring | arriving …

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

65 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

66 Combining post-modifiers  A flight from Phoenix to Detroit leaving Monday evening  Evening flights from Nashville to Houston that serve dinner  The earliest American Airlines flight that I can get

67 Recursive Structure  Rules where the non-terminal on the left- hand side also appears on the right-hand side. –NP → NP PP (The flight to Boston) –VP → VP PP (departed Miami at noon)

68 More Recursive Structures  Allow us to do the following: –Flights to Miami –Flights to Miami from Boston –Flights to Miami from Boston in April –Flights to Miami from Boston in April on Friday –Flights to Miami from Boston in April on Friday under $300 –….

69 Conjunctions  Any phrasal constituent can be conjoined with a constituent of the same type to form a new constituent of that type –NP → NP and NP –S → S and S  X → X and X

70 Next Time  Finish Chapters 8, 9  Read Chapter 10.


Download ppt "CMSC 723 / LING 645: Intro to Computational Linguistics November 3, 2004 Lecture 9 (Dorr): Word Classes, POS Tagging (Chapter 8) Intro to Syntax (Start."

Similar presentations


Ads by Google