8 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
' lehvenshsteinsche distance
' http://de.wikipedia.org/wiki/Levenshtein-Distanz
Function match (str1, str2)
Dim Matrix (), str1len, str2len, i, j, cost, m1, m2, m3
If (Not ((IsNull (str1) Or IsNull (str2)))) Then
str1len = Len (str1)
str2len = Len (str2)
ReDim Matrix (str1len + 1, str2len + 1)
' populate the matrix
For i=0 To str1len
Matrix(i, 0) = i
Next
For j=0 To str2len
Matrix(0, j) = j
Next
For i=1 To str1len
For j=1 to str2len
If (Mid (str1, i, 1) = Mid (str2, j, 1)) Then
cost = 0
Else
cost = 1
End If
m1 = Matrix (i-1, j) + 1
m2 = Matrix (i, j-1) + 1
m3 = Matrix (i-1, j-1) + cost
If ((m1 <= m2) And (m1 <= m3)) Then
Matrix (i, j) = m1
End If
If ((m2 <= m1) And (m2 <= m3)) Then
Matrix (i, j) = m2
End If
If ((m3 <= m2) And (m3 <= m1)) Then
Matrix (i, j) = m3
End If
Next
Next
match = Matrix(str1len - 1, str2len - 1)
Else
match = 667
End If
End Function
8 Einträge, 1 Seite |