0% found this document useful (0 votes)
145 views8 pages

Compu'ng Minimum Edit Distance

The document discusses computing minimum edit distance, which is a measure of similarity between two strings. It describes using dynamic programming to build a table to calculate the minimum number of operations (insertions, deletions, substitutions) needed to change one string into the other. The table is built from smallest to largest subproblems and each cell represents the edit distance between prefixes of the two strings.

Uploaded by

Advay Rajhansa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views8 pages

Compu'ng Minimum Edit Distance

The document discusses computing minimum edit distance, which is a measure of similarity between two strings. It describes using dynamic programming to build a table to calculate the minimum number of operations (insertions, deletions, substitutions) needed to change one string into the other. The table is built from smallest to largest subproblems and each cell represents the edit distance between prefixes of the two strings.

Uploaded by

Advay Rajhansa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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.  
•  BoCom-­‐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  

Defining  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) + 2; if X(i) ≠ Y(j) !
0; if X(i) = Y(j)!
•  Termina'on:  
D(N,M) is distance !
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 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  

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 8
N 2 3 4 5 6 7 8 7 8 7
I 1 2 3 4 5 6 7 6 7 8
# 0 1 2 3 4 5 6 7 8 9
# E X E C U T I O N
Minimum  Edit  
Distance  
 
Compu'ng  Minimum  
Edit  Distance  
 

You might also like