Go implementation of Wagner-Fischer algorithm that computes the edit
distance between two strings of characters. The edit distance here is
Levenshtein distance, the minimum number of single-character edits
(insertions, deletions or substitutions) required to change one string into the
other.
packageld// The edit distances here is actually Levenshtein distance, minimum number of// single-character edits (insertions, deletions or substitutions) required to// change one string into the other.funcEditDistance(s,tstring)int{ss:=StringToRuneSlice(s)m:=len(ss)+1tt:=StringToRuneSlice(t)n:=len(tt)+1d:=make([][]int,m)fori:=ranged{d[i]=make([]int,n)}fori:=0;i<m;i++{d[i][0]=i}forj:=0;j<n;j++{d[0][j]=j}forj:=1;j<n;j++{fori:=1;i<m;i++{varsubstitutionCostintifss[i-1]==tt[j-1]{substitutionCost=0}else{substitutionCost=1}d[i][j]=minimum(d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+substitutionCost,)}}returnd[m-1][n-1]}