Skip to content

Instantly share code, notes, and snippets.

@nicklockwood
nicklockwood / JaroWinkler.swift
Created December 21, 2020 18:52
Swift code to calculate the Jaro-Winkler edit distance between two strings
/// 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)
@lattner
lattner / TaskConcurrencyManifesto.md
Last active November 15, 2024 05:45
Swift Concurrency Manifesto