0 people like it.

Jaro-Winkler in F#, Extended

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
let jaroWinklerMI (t1:string) (t2:string) = 
    // Optimizations for easy to calculate cases
    if t1.Length = 0 || t2.Length = 0 then 0.0
    elif t1 = t2 then 1.0
    else
        // Even more weight for the first char
        let score = jaroWinkler t1 t2
        let p = 0.2 //percentage of score from new metric
        let b = if t1.[0] = t2.[0] then 1.0 else 0.0
        ((1.0 - p) * score) + (p * b)

let scoreNamePairs (t1:string) (t2:string) =  
    //Raise jaro to a power in order to over-weight better matches        
    jaroWinklerMI t1 t2 ** 2.0
val jaroWinklerMI : t1:string -> t2:string -> float

Full name: Script.jaroWinklerMI
val t1 : string
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string
val t2 : string
property System.String.Length: int
val score : float
val p : float
val b : float
val scoreNamePairs : t1:string -> t2:string -> float

Full name: Script.scoreNamePairs
Raw view Test code New version

More information

Link:http://fssnip.net/7R
Posted:14 years ago
Author:
Tags: