Created
February 4, 2016 07:25
-
-
Save pjazdzewski1990/b495b335a22c527a7ae7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def scoreSimilarity(s1: String, s2: String): Double = { | |
val len = Math.min(s1.length, s2.length) | |
val sum: Double = (for { | |
i <- 0 until len | |
v = if(s1.charAt(i) == s2.charAt(i)) 1.0 else 0.0 | |
} yield v).sum | |
Math.pow(sum, 2.0)/Math.pow(len, 2.0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment