Author: Chris Lattner
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
/// The Jaro-Winkler edit distance between two strings (0 - 1) | |
func editDistance(_ lhs: String, _ rhs: String) -> Double { | |
return 1 - jaroWinklerSimilarity(Array(lhs), Array(rhs)) | |
} | |
/// Jaro-Winkler similarity between two strings (0 - 1) | |
/// https://www.geeksforgeeks.org/jaro-and-jaro-winkler-similarity/ | |
private func jaroWinklerSimilarity(_ s1: [Character], _ s2: [Character]) -> Double { | |
var jaro = jaroSimilarity(s1, s2) |