# We cant aord to navigate navely lots of disnct paths

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ) from the start string to the ﬁnal string: •  •  •  •  8 Ini9al state: the word we’re transforming Operators: insert, delete, subs'tute Goal state: the word we’re trying to get to Path cost: what we want to minimize: the number of edits Dan Jurafsky Minimum Edit as Search •  But the space of all edit sequences is huge! •  We can’t aﬀord to navigate naïvely •  Lots of dis'nct paths wind up at the same state. •  We don’t have to keep track of all of them •  Just the shortest path to each of those revisted states. 9 Dan Jurafsky Deﬁning Min Edit Distance •  For two strings •  X of length n •  Y of length m •  We deﬁne D(i,j) •  the edit distance between X[1..i] and Y[1..j] •  i.e., the ﬁrst i characters of X and the ﬁrst j characters of Y •  The edit distance between X and Y is thus D(n,m) Minimum Edit Distance Deﬁni'on of Minimum Edit Distance Minimum Edit Distance Compu'ng Minimum Edit Distance Dan Jurafsky Dynamic Programming for Minimum Edit Distance •  Dynamic programming: A tabular computa'on of D(n,m) •  Solving problems by combining solu'ons to subproblems. •  BoXom ­up •  We compute D(i,j) for small i,j •  And compute larger D(i,j) based on previously computed smaller values •  i.e., compute D(i,j) for all i (0 < i < n) and j (0 < j < m) Dan Jurafsky Deﬁning Min Edit Distance (Levenshtein) •  Ini'aliza'on D(i,0) = i! D(0,j) = j •  Recurrence Rela'on: For each i = 1…M! ! For each j = 1…N D(i-1,j) + 1! D(i,j)= min D(i,j-1) + 1! D(i-1,j-1) + •  Termina'on: D(N,M) is distance ! ! 2; if X(i) ≠ Y(j) 0; if X(i) = Y(j)! ! Dan Jurafsky The Edit Distance Table N 9 O 8 I 7 T 6 N 5 E 4 T 3 N 2 I 1 # 0 1 2 3 4 5 6 7 8 9 # E X E C U T I O N Dan Jurafsky The Edit Distance Table N O I 9 8 7 T N E T N I # 6 5 4 3 2 1 0 # 1 E 2 X 3 E 4 C 5 U 6 T 7 I 8 O 9 N Dan Jurafsky Edit Distance N 9 O 8 I 7 T 6 N 5 E 4 T 3 N 2 I 1 # 0 1 2 3 4 5 6 7 8 9 # E X E C U T I O N Dan Jurafsky The Edit Distance Table N 9 8 9 10 11 12 11 10 9 8 O 8 7 8 9 10 11 10 9 8 9 I 7 6 7 8 9 10 9 8 9 10 T 6 5 6 7 8 9 8 9 10 11 N 5 4 5 6 7 8 9 10 11 10 E 4 3 4 5 6 7 8 9 10 9 T 3 4 5 6 7 8 7 8 9...
View Full Document

## This document was uploaded on 02/14/2014.

Ask a homework question - tutors are online