530 likes | 658 Views
CMSC 723 / LING 645: Intro to Computational Linguistics. September 8, 2004: Dorr MT (continued), MT Evaluation Prof. Bonnie J. Dorr Dr. Christof Monz TA: Adam Lee. MT Challenges: Ambiguity. Syntactic Ambiguity I saw the man on the hill with the telescope Lexical Ambiguity E: book
E N D
CMSC 723 / LING 645: Intro to Computational Linguistics September 8, 2004: Dorr MT (continued), MT Evaluation Prof. Bonnie J. DorrDr. Christof MonzTA: Adam Lee
MT Challenges: Ambiguity • Syntactic AmbiguityI saw the man on the hill with the telescope • Lexical Ambiguity E: book S: libro, reservar • Semantic Ambiguity • Homography:ball(E) = pelota, baile(S) • Polysemy:kill(E), matar, acabar (S) • Semantic granularityesperar(S) = wait, expect, hope (E)be(E) = ser, estar(S)fish(E) = pez, pescado(S)
MT Challenges: Divergences • Meaning of two translationally equivalent phrases is distributed differently in the two languages • Example: • English: [RUN INTO ROOM] • Spanish: [ENTER IN ROOM RUNNING]
Divergence Frequency • 32% of sentences in UN Spanish/English Corpus (5K) • 35% of sentences in TREC El Norte Corpus (19K) • Divergence Types • Categorial (X tener hambre X have hunger) [98%] • Conflational (X dar puñaladas a Z X stab Z) [83%] • Structural (X entrar en Y X enter Y) [35%] • Head Swapping (X cruzar Y nadando X swim across Y) [8%] • Thematic (X gustar a Y Y like X) [6%]
Spanish/Arabic Divergences Divergence E/E’ (Spanish) E/E’ (Arabic) Categorial be jealous when he returns have jealousy [tener celos] upon his return [ﻋﻧﺩ ﺮﺠﻭﻋﻪ] Conflational float come again go floating [ir flotando] return [ﻋﺎﺪ] Structural enter the house seek enter in the house [entrar en la casa] search for [ﺒﺣﺙ ﻋﻦ] Head Swap run in do something quickly enter running [entrar corriendo] go-quickly in doing something [ﺍﺴﺭﻉ] Thematic I have a headache my-head hurts me [me duele la cabeza] — [Arg1 [V]] Þ [Arg1 [MotionV] Modifier(v)] “The boat floated’’ Þ “The boat went floating’’
Automatic Divergence Detection (using narrowly defined divergence detection rules) LanguageDetectedHumanSampleCorpus ConfirmedSizeSize Spanish – Total 11.1% 10.5% 19K 150K Arabic – Total 31.9 12.5% 1K 28K
Application of Divergence Detection: Bilingual Alignment for MT • Word-level alignments of bilingual texts are an integral part of MT models • Divergences present a great challenge to the alignment task • Common divergence types can be found in multiple language pairs, systematically identified, and resolved
The Problem:Alignment & Projection I began to eat the fish Yo empecé a comer el pescado
Why is this a hard problem? I run into the room Yo entro en el cuarto corriendo
Divergences! English: [RUN INTO ROOM] Spanish: [ENTER IN ROOM RUNNING]
Our Goal: Improved Alignment & Projection • Induce higher interannotator agreement rate • Increase the number of aligned words • Decrease multiple alignments
E: I run into the room E¢: I move-in running the room S: Yo entro en el cuarto corriendo DUSTer Approach: Divergence Unraveling
enter run John room into John running room Ex: John ran into the room → John entered the room running Word-Level Alignment (1): Test Setup • Divergence Detection: Categorize English sentences into one of 5 divergence types • Divergence Correction: Apply appropriate structural transformation [E → E¢]
Word-Level Alignment (2): Testing Impact of Divergence Correction • Human align English and foreign sentence • Human align English¢ and foreign sentence • Compare inter-annotator agreement, unaligned units, multiple alignments
Word-Level Alignment Results • Inter-Annotator Agreement: • English-Spanish: agreement increased from 80.2% to 82.9% • English-Arabic: agreement increased from 69.7% to 75.1% • Number of aligned words: • English-Spanish: aligned words increased from 82.8% to 86% • English-Arabic: aligned words increased from 61.5% to 88.1% • Multiple Alignments: • English-Spanish: number of links went from 1.35 to 1.16 • English-Arabic: number of links increased from 1.48 to 1.72
Divergence Unraveling Conclusions • Divergence handling shows promise for improvement of automatic alignment • Conservative lower bound on divergence frequency • Effective solution: syntactic transformation of English • Validity of solution shown through alignment experiments
How do we evaluate MT? • Human-based Metrics • Semantic Invariance • Pragmatic Invariance • Lexical Invariance • Structural Invariance • Spatial Invariance • Fluency • Accuracy • “Do you get it?” • Automatic Metrics: Bleu
BiLingual Evaluation Understudy (BLEU —Papineni, 2001) http://www.research.ibm.com/people/k/kishore/RC22176.pdf • Automatic Technique, but …. • Requires the pre-existence of Human (Reference) Translations • Approach: • Produce corpus of high-quality human translations • Judge “closeness” numerically (word-error rate) • Compare n-gram matches between candidate translation and 1 or more reference translations
Bleu Comparison Chinese-English Translation Example: Candidate 1: It is a guide to action which ensures that the military always obeys the commands of the party. Candidate 2: It is to insure the troops forever hearing the activity guidebook that party direct. Reference 1: It is a guide to action that ensures that the military will forever heed Party commands. Reference 2: It is the guiding principle which guarantees the military forces always being under the command of the Party. Reference 3: It is the practical guide for the army always to heed the directions of the party.
How Do We Compute Bleu Scores? • Key Idea: A reference word should be considered exhausted after a matching candidate word is identified. • For each word compute: (1) candidate word count (2) maximum ref count • Add counts for each candidate word using the lower of the two numbers . • Divide by number of candidate words..
Modified Unigram Precision: Candidate #1 It(1) is(1) a(1) guide(1) to(1) action(1) which(1) ensures(1) that(2) the(4) military(1) always(1) obeys(0) the commands(1) of(1) the party(1) Reference 1: It is a guide to action that ensures that the military will forever heed Party commands. Reference 2: It is the guiding principle which guarantees the military forces always being under the command of the Party. Reference 3: It is the practical guide for the army always to heed the directions of the party. What’s the answer?????? 17/18
Modified Unigram Precision: Candidate #2 It(1) is(1) to(1) insure(0) the(4) troops(0) forever(1) hearing(0) the activity(0) guidebook(0) that(2) party(1) direct(0) Reference 1: It is a guide to action that ensures that the military will forever heed Party commands. Reference 2: It is the guiding principle which guarantees the military forces always being under the command of the Party. Reference 3: It is the practical guide for the army always to heed the directions of the party. What’s the answer?????? 8/14
Modified Bigram Precision: Candidate #1 It is(1) is a(1) a guide(1) guide to(1) to action(1) action which(0) which ensures(0) ensures that(1) that the(1) the military(1) military always(0) always obeys(0) obeys the(0) the commands(0) commands of(0) of the(1) the party(1) Reference 1: It is a guide to action that ensures that the military will forever heed Party commands. Reference 2: It is the guiding principle which guarantees the military forces always being under the command of the Party. Reference 3: It is the practical guide for the army always to heed the directions of the party. What’s the answer?????? 10/17
Modified Bigram Precision: Candidate #2 It is(1) is to(0) to insure(0) insure the(0) the troops(0) troops forever(0) forever hearing(0) hearing the(0) the activity(0) activity guidebook(0) guidebook that(0) that party(0) party direct(0) Reference 1: It is a guide to action that ensures that themilitary will forever heed Party commands. Reference 2: It is the guiding principle which guarantees the military forces always being under the command of the Party. Reference 3: It is the practical guide for the army always to heed the directions of the party. What’s the answer?????? 1/13
Catching Cheaters the(2) the the the(0) the(0) the(0) the(0) Reference 1: The cat is on the mat Reference 2: There is a cat on the mat What’s the unigram answer? 2/7 What’s the bigram answer? 0/7
CMSC 723 / LING 645: Intro to Computational Linguistics September 8, 2004: Monz Regular Expressions and Finite State Automata (J&M 2) Prof. Bonnie J. DorrDr. Christof MonzTA: Adam Lee
Regular Expressions and Finite State Automata • REs: Language for specifying text strings • Search for document containing a string • Searching for “woodchuck” • How much wood would a woodchuckchuck if a woodchuck would chuck wood? • Searching for “woodchucks” with an optional final “s” • Finite-state automata (FSA)(singular: automaton)
Regular Expressions • Basic regular expression patterns • Perl-based syntax (slightly different from other notations for regular expressions) • Disjunctions /[wW]oodchuck/
Regular Expressions • Ranges [A-Z] • Negations [^Ss]
*+ Stephen Cole Kleene Regular Expressions • Optional characters ? ,* and + • ? (0 or 1) • /colou?r/ colororcolour • * (0 or more) • /oo*h!/ oh! or Ooh! or Ooooh! • + (1 or more) • /o+h!/ oh! or Ooh! or Ooooh! • Wild cards .- /beg.n/ begin or began or begun
Regular Expressions • Anchors ^ and $ • /^[A-Z]/ “Ramallah, Palestine” • /^[^A-Z]/ “¿verdad?” “really?” • /\.$/ “It is over.” • /.$/ ? • Boundaries \b and \B • /\bon\b/ “on my way” “Monday” • /\Bon\b/ “automaton” • Disjunction | • /yours|mine/ “it is either yours or mine”
Disjunction, Grouping, Precedence • Column 1 Column 2 Column 3 …How do we express this? /Column [0-9]+ */ /(Column [0-9]+ *)*/ • Precedence • Parenthesis () • Counters * + ? {} • Sequences and anchors the ^my end$ • Disjunction | • REs are greedy!
Perl Commands While ($line=<STDIN>){ if ($line =~ /the/){ print “MATCH: $line”; } }
Writing correct expressions Exercise: Write a Perl regular expression to match the English article “the”: /the/ /[tT]he/ /\b[tT]he\b/ /[^a-zA-Z][tT]he[^a-zA-Z]/ /(^|[^a-zA-Z])[tT]he[^a-zA-Z]/
A more complex example Exercise: Write a regular expression that will match “any PC with more than 500MHz and 32 Gb of disk space for less than $1000”: /$[0-9]+/ /$[0-9]+\.[0-9][0-9]/ /\b$[0-9]+(\.[0-9][0-9])?\b/ /\b$[0-9][0-9]?[0-9]?(\.[0-9][0-9])?\b/ /\b[0-9]+ *([MG]Hz|[Mm]egahertz| [Gg]igahertz)\b/ /\b[0-9]+ *(Mb|[Mm]egabytes?)\b/ /\b[0-9](\.[0-9]+) *(Gb|[Gg]igabytes?)\b/
Substitutions and Memory Substitute as many times as possible! • Substitutions s/colour/color/ s/colour/color/g Case insensitive matching s/colour/color/i • Memory (\1,\2, etc. refer back to matches) s/([0-9]+)/<\1>/ /the (.*)er they were, the \1er they will be/ /the (.*)er they (.*), the \1er they \2/
Eliza [Weizenbaum, 1966] 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
Eliza-style regular expressions Step 1: replace first person references with second person references s/.* YOU ARE (depressed|sad) .*/I AM SORRY TO HEAR YOU ARE \1/ s/.* YOU ARE (depressed|sad) .*/WHY DO YOU THINK YOU ARE \1/ s/.* all .*/IN WHAT WAY/ s/.* always .*/CAN YOU THINK OF A SPECIFIC EXAMPLE/ s/\bI(’m| am)\b/YOU ARE/g s/\bmy\b/YOUR/g S/\bmine\b/YOURS/g Step 2: use additional regular expressions to generate replies Step 3: use scores to rank possible transformations
Finite-state Automata • Finite-state automata (FSA) • Regular languages • Regular expressions
baa! baaa! baaaa! baaaaa! ... /baa+!/ a b a a ! q0 q1 q2 q3 q4 finalstate state transition Finite-state Automata (Machines)
q0 a b a ! b a b a a ! 0 1 2 3 4 Input Tape REJECT
q4 q0 q1 q2 q3 q3 a b a a a b a a ! ! 0 1 2 3 4 Input Tape ACCEPT
Finite-state Automata • Q: a finite set of N states • Q = {q0, q1, q2, q3, q4} • : a finite input alphabet of symbols • = {a, b, !} • q0: the start state • F: the set of final states • F = {q4} • (q,i): transition function • Given state q and input symbol i, return new state q' • (q3,!) q4
D-RECOGNIZE function D-RECOGNIZE (tape, machine) returns accept or rejectindex Beginning of tapecurrent-state Initial state of machineloopif End of input has been reached thenif current-state is an accept state thenreturn acceptelsereturn rejectelsiftransition-table [current-state, tape[index]] is empty thenreturn rejectelsecurrent-state transition-table [current-state, tape[index]]index index + 1end
! ! b ! b ! b b a a qF Adding a failing state a b a a ! q0 q1 q2 q3 q4
a b a a ! q0 q1 q2 q3 q4 = = = = qF Adding an “all else” arc
Languages and Automata • Can use FSA as a generator as well as a recognizer • Formal language L: defined by machine M that both generates and recognizes all and only the strings of that language. • L(M) = {baa!, baaa!, baaaa!, …} • Regular languages vs. non-regular languages
Languages and Automata • Deterministic vs. Non-deterministic FSAs • Epsilon () transitions