This is an implementation of the Double Metaphone algorithm in Swift. The algorithm was originally coded by Lawrence Philips.
Import DoubleMetaphoneSwift at the top of the Swift file.
import DoubleMetaphoneSwift
The returned Double Metaphone calculation returns the primary and secondary calculations as a tuple.
guard let (primary, secondary) = DoubleMetaphoneSwift.calculate(input: "Hello World!") else {
print("Failed to calculate...")
return
}
print("Primary: \(primary)") // Primary: HLRL
print("Secondary: \(secondary)") // Secondary: HLRL