Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Jaro-similarity/ZX-Spectrum-Basic/jaro-similarity.basic
Normal file
22
Task/Jaro-similarity/ZX-Spectrum-Basic/jaro-similarity.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
10 LET a$="MARTHA": LET b$="MARHTA": PRINT a$;", ";b$;": ";: GO SUB 1000: PRINT jaro
|
||||
20 LET a$="DIXON": LET b$="DICKSONX": PRINT a$;", ";b$;": ";: GO SUB 1000: PRINT jaro
|
||||
30 LET a$="JELLYFISH": LET b$="SMELLYFISH": PRINT a$;", ";b$;": ";: GO SUB 1000: PRINT jaro
|
||||
900 STOP
|
||||
1000 REM Jaro subroutine
|
||||
1010 LET s1=LEN a$: LET s2=LEN b$: LET j=1: LET m=0: LET t=0
|
||||
1030 IF s1>s2 THEN LET z$=a$: LET a$=b$: LET b$=z$: LET z=s1: LET s1=s2: LET s2=z
|
||||
1035 LET maxdist=INT (s2/2)
|
||||
1040 FOR i=1 TO s1
|
||||
1050 IF a$(i)=b$(j) THEN LET m=m+1: LET b$(j)=" ": GO TO 2000
|
||||
1080 FOR k=FN x(1,i-maxdist) TO FN n(s2,i+maxdist)
|
||||
1090 IF a$(i)=b$(k) THEN LET t=t+1: LET m=m+1: LET b$(k)=" ": IF k>j THEN LET j=k
|
||||
1100 NEXT k
|
||||
2000 IF j<s2 THEN LET j=j+1:
|
||||
2010 NEXT i
|
||||
2020 IF m=0 THEN LET jaro=0: RETURN
|
||||
2030 LET t=INT (t/2)
|
||||
2040 LET jaro=(m/s1+m/s2+((m-t)/m))/3
|
||||
2050 RETURN
|
||||
5000 REM Functions
|
||||
5010 DEF FN x(a,b)=(a AND a>b)+(b AND a<b)+(a AND a=b): REM max function
|
||||
5020 DEF FN n(a,b)=(a AND a<b)+(b AND a>b)+(a AND a=b): REM min function
|
||||
Loading…
Add table
Add a link
Reference in a new issue