Presentation is loading. Please wait.

Presentation is loading. Please wait.

Word classes and part of speech tagging 09/28/2004 Reading: Chap 8, Jurafsky & Martin Instructor: Rada Mihalcea Note: Some of the material in this slide.

Similar presentations


Presentation on theme: "Word classes and part of speech tagging 09/28/2004 Reading: Chap 8, Jurafsky & Martin Instructor: Rada Mihalcea Note: Some of the material in this slide."— Presentation transcript:

1 Word classes and part of speech tagging 09/28/2004 Reading: Chap 8, Jurafsky & Martin Instructor: Rada Mihalcea Note: Some of the material in this slide set was adapted from Chris Brew’s (OSU) slides on part of speech tagging

2 Slide 1 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

3 Slide 2 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

4 Slide 3 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

5 Slide 4 Word Classes Basic word classes: Noun, Verb, Adjective, Adverb, Preposition, … Open vs. Closed classes Open: Nouns, Verbs, Adjectives, Adverbs. Why “open”? Closed: determiners: a, an, the pronouns: she, he, I prepositions: on, under, over, near, by, …

6 Slide 5 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

7 Slide 6 Closed Class Words Differ more from language to language than open class words 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, …

8 Slide 7 Prepositions from CELEX

9 Slide 8 English Single-Word Particles

10 Slide 9 Pronouns in CELEX

11 Slide 10 Conjunctions

12 Slide 11 Auxiliaries

13 Slide 12 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

14 Slide 13 Word Classes: Tag set example PRP PRP$

15 Slide 14 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 ?

16 Slide 15 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

17 Slide 16 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)

18 Slide 17 Part-of-Speech Tagging Rule-Based Tagger: ENGTWOL (ENGlish TWO Level analysis) Stochastic Tagger: HMM-based Transformation-Based Tagger (Brill)

19 Slide 18 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.

20 Slide 19 Sample ENGTWOL Lexicon Demo: http://www.lingsoft.fi/cgi-bin/engtwolhttp://www.lingsoft.fi/cgi-bin/engtwol

21 Slide 20 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

22 Slide 21 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 Example constraint for clear

23 Slide 22 Stochastic Tagging Based on probability of certain tag occurring given various possibilities Requires a training corpus No probabilities for words not in corpus. Training corpus may be different from test corpus.

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

25 Slide 24 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. XRCE Part-of-Speech TaggerPart-of-Speech Tagger

26 Slide 25 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

27 Slide 26 Markov Model Taggers Bigram tagger Make predictions based on the preceding tag The basic unit is the preceding tag and the current tag Trigram tagger We would expect more accurate predictions if more context is taken into account RB(adverb) VBD(past tense) Vs RB VBN(past participle) ? Ex) “clearly marked” Is clearly marked : P(BEZ RB VBN) > P(BEZ RB VBD) He clearly marked : P(PN RB VBD) > P(PN RB VBN)

28 Slide 27 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

29 Slide 28 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)

30 Slide 29 PARTS vs HMM What is the main difference between PARTS tagger (Church) and the HMM tagger? Give an example where the two taggers produce different output.

31 Slide 30 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) Usually constructed from the tagged corpus

32 Slide 31 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 Slide 32 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 Slide 33 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 Slide 34 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 Slide 35 TBL: Rule Learning (cont’d) 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 Slide 36 Templates for TBL

38 Slide 37 TBL: Problems Execution Speed: TBL tagger is slower than HMM approach –Solution: compile the rules to a Finite State Transducer (FST) Learning Speed: Brill’s implementation over a day (600k tokens)

39 Slide 38 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 Slide 39 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. Factors that affects the performance –The amount of training data available –The tag set –The difference between training corpus and test corpus –Dictionary –Unknown words


Download ppt "Word classes and part of speech tagging 09/28/2004 Reading: Chap 8, Jurafsky & Martin Instructor: Rada Mihalcea Note: Some of the material in this slide."

Similar presentations


Ads by Google