| |
|
|
| Peter woodpecker has Levenshtein-Distance [...] for XProfan vorgemacht: [...]
Peter woodpecker (07.11.10)
Well, the yellow of egg is the Original-Levenshtein not yet: CompileMarkSeparationWindowTitle "Levenshtein-Distanz (Stringvergleich)"
Cls @rgb(200,200,100)
proc LD' Compute Levenshtein-Distance
parameters s$,t$
s$=lower$(s$):var m&=len(s$)
t$=lower$(t$):var n&=len(t$)
declare d&[m&,n&],i&,j&,cost&,mi&,c&
case m& = 0 : return n&
case n& = 0 : return m&
i&=0 : while i&<=m& : d&[i&,0]=i& : inc i& : endwhile
j&=0 : while j&<=n& : d&[0,j&]=j& : inc j& : endwhile
i&=1
WHILE i&<=m&
j&=1
While j&<=n&
cost&=1
case Mid$(s$,i&,1)=Mid$(t$,j&,1):cost& = 0
mi&=d&[i&-1,j&]+1
c&=d&[i&,j&-1]+1
case c&<mi& : mi&=c&
c&=d&[i&-1,j&-1]+cost&
case c&<mi& : mi&=c&
d&[i&,j&]=mi&
inc j&
EndWhile
inc i&
ENDWHILE
return d&[m&,n&]
Endproc
' Input Loop
declare str1$,str2$
While 1
Locate 10,10 : print "String1 = ";
Locate 12,10 : print "String2 = ";
Locate 14,10 : print "Ergebnis = ";
Locate 10,21 : input str1$ : case str1$="" : End
Locate 12,21 : input str2$
Locate 14,21 : Print LD(str1$,str2$)
WaitInput
EndWhile
'./../../function-references/XProfan/end/'>END
it missing z.B. a Änderung the Kostenbewerung in dependence of possible Hörfehlern (y,ü,i,j ; sh sch ; t d ; p b; k g; h _ ) u.v.a. More... |
|
|
| |
|
|