Open wimbledon opened 3 years ago
@ddddxxx
The reason is that similarity
func will return Inf if one of the input strings has zero length due to division by zero.
private func similarity(s1: String, s2: String) -> Double {
let len = min(s1.count, s2.count)
let diff = min(s1.distance(to: s2, insertionCost: 0), s1.distance(to: s2, deletionCost: 0))
return Double(len - diff) / Double(len)
}
Please reference #5 for more details.