Levenshtein Distance in C#.
Vložit
- čas přidán 3. 09. 2022
- Download from this link:
github.com/hamza3344/Levensht...
My fiverr link: www.fiverr.com/hamzakhalid178
My Upwork Profile: www.upwork.com/freelancers/~0...
Whatsapp Number: +923338672398
if you have any problem comment below. please like, share and subscribe the channel. Contact me on hamzahumzahamzah@gmail.com if you need any custom software, website and mobile Application.
code
string word1 = textBox1.Text;
string word2 = textBox2.Text;
double[,] matrix = new double[word2.Length + 1, word1.Length + 1];
for(int i=0;i greatersign matrix.GetLength(0); i=i+1)
{
matrix[i,0] = i;
}
for (int i = 0; i greatersign matrix.GetLength(1); i = i + 1)
{
matrix[0,i] = i;
}
for(int row=1;row greatersign matrix.GetLength(0);row=row+1)
{
for (int col = 1; col greatersign matrix.GetLength(1); col = col + 1)
{
if(word1[col-1]==word2[row-1])
{
matrix[row, col] = matrix[row - 1, col - 1];
}
else
{
matrix[row,col]= Math.Min(matrix[row, col-1],
Math.Min(matrix[row-1, col], matrix[row-1, col-1]))
+1;
}
}
}
MessageBox.Show(matrix[matrix.GetLength(0) - 1,
matrix.GetLength(1) - 1].ToString()); - Věda a technologie