### Get Jaro Distance for Strings (Alias) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html An alias for the Jaro-Winkler distance calculation, providing the similarity score between two strings. ```swift public func distance(between target: String) -> Double ``` -------------------------------- ### Get Hamming Distance for Strings Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Hamming distance between two strings. This is only applicable when the strings are of equal length. ```swift public func distanceHamming(between target: String) -> Int ``` -------------------------------- ### Get Most Frequent K Distance for Strings Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates a distance metric based on the K most frequent characters in two strings. A maximum distance limit can be specified. ```swift public func distanceMostFreqK(between target: String, K: Int, maxDistance: Int = 10) -> Int ``` -------------------------------- ### Get Damerau-Levenshtein Distance for Strings Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Damerau-Levenshtein distance between two strings, which accounts for adjacent transpositions. ```swift public func distanceDamerauLevenshtein(between target: String) -> Int ``` -------------------------------- ### Get Normalized Most Frequent K Distance for Strings Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates a normalized version of the most frequent K distance, where 0 indicates no similarity and 1 indicates an exact match. ```swift public func distanceNormalizedMostFrequentK(between target: String, k: Int) -> Double ``` -------------------------------- ### Get Jaro-Winkler Distance for Strings Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Jaro-Winkler distance between two strings. The score ranges from 0 (no similarity) to 1 (exact match). ```swift public func distanceJaroWinkler(between target: String) -> Double ``` -------------------------------- ### Get Levenshtein Distance for Strings Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Levenshtein distance between two strings, representing the minimum number of single-character edits required to change one word into the other. ```swift public func distanceLevenshtein(between target: String) -> Int ``` -------------------------------- ### Add StringMetric.swift as Dependency Source: https://autozimu.github.io/StringMetric.swift/index.html For Swift Package Manager users, add this module as a dependency in your Package.swift file. ```swift .Package(url: "https://github.com/autozimu/StringMetric.swift.git", majorVersion: 0) ``` -------------------------------- ### String Extension Declaration Source: https://autozimu.github.io/StringMetric.swift/Extensions.html Declares an extension for the String type in Swift. This is a foundational step for adding new functionality. ```swift extension String ``` -------------------------------- ### distance(between:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Jaro-Winkler distance between two strings. This is an alias for `distanceJaroWinkler(between:)`. ```APIDOC ## distance(between:) ### Description Get distance between target. (alias of `distanceJaroWinkler(between:)`.) ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "example" let str2 = "sample" let dist = str1.distance(between: str2) ``` ### Response #### Success Response (200) - **distance** (Double) - The Jaro-Winkler distance between the receiver and target. #### Response Example ```json { "distance": 0.75 } ``` ``` -------------------------------- ### distanceMostFreqK(between:K:maxDistance:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the most frequent K distance between two strings, using a specified number of most frequent characters and an optional maximum distance limit. ```APIDOC ## distanceMostFreqK(between:K:maxDistance:) ### Description Get most frequent K distance. Reference https://web.archive.org/web/20191117082524/https://en.wikipedia.org/wiki/Most_frequent_k_characters ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "programming" let str2 = "program" let k = 3 let maxDist = 5 let dist = str1.distanceMostFreqK(between: str2, K: k, maxDistance: maxDist) ``` ### Response #### Success Response (200) - **distance** (Int) - The most frequent K distance between the receiver and target. #### Response Example ```json { "distance": 1 } ``` ``` -------------------------------- ### distanceJaroWinkler(between:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Jaro-Winkler distance between two strings, providing a score from 0 (no similarity) to 1 (exact match). ```APIDOC ## distanceJaroWinkler(between:) ### Description Get Jaro-Winkler distance. (Score is normalized such that 0 equates to no similarity and 1 is an exact match). Reference https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "martha" let str2 = "marhta" let dist = str1.distanceJaroWinkler(between: str2) ``` ### Response #### Success Response (200) - **distance** (Double) - The Jaro-Winkler distance between the receiver and target. #### Response Example ```json { "distance": 0.944 } ``` ``` -------------------------------- ### distanceDamerauLevenshtein(between:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Damerau-Levenshtein distance between two strings, which accounts for adjacent transpositions. ```APIDOC ## distanceDamerauLevenshtein(between:) ### Description Get Damerau-Levenshtein distance. Reference https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#endnote_itman#Distance_with_adjacent_transpositions ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "kitten" let str2 = "sitting" let dist = str1.distanceDamerauLevenshtein(between: str2) ``` ### Response #### Success Response (200) - **distance** (Int) - The Damerau-Levenshtein distance between the receiver and target. #### Response Example ```json { "distance": 3 } ``` ``` -------------------------------- ### distanceHamming(between:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Hamming distance between two strings. This is only applicable when the strings are of equal length. ```APIDOC ## distanceHamming(between:) ### Description Get Hamming distance. Note: Only applicable when string lengths are equal. Reference https://en.wikipedia.org/wiki/Hamming_distance. ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "karolin" let str2 = "kathrin" let dist = str1.distanceHamming(between: str2) ``` ### Response #### Success Response (200) - **distance** (Int) - The Hamming distance between the receiver and target. #### Response Example ```json { "distance": 3 } ``` ``` -------------------------------- ### distanceLevenshtein(between:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the Levenshtein distance between two strings, representing the minimum number of single-character edits required to change one word into the other. ```APIDOC ## distanceLevenshtein(between:) ### Description Get the Levenshtein distance. Reference https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_matrix_rows ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "book" let str2 = "back" let dist = str1.distanceLevenshtein(between: str2) ``` ### Response #### Success Response (200) - **distance** (Int) - The Levenshtein distance between the receiver and target. #### Response Example ```json { "distance": 2 } ``` ``` -------------------------------- ### Calculate String Distance Source: https://autozimu.github.io/StringMetric.swift/index.html Calculate the distance between two strings using the default distance function (alias for distanceJaroWinkler). Supports Unicode characters. ```swift "kitten".distance(between: "sitting") // => 0.746 "君子和而不同".distance(between: "小人同而不和") // => 0.555 ``` -------------------------------- ### distanceNormalizedMostFrequentK(between:k:) Source: https://autozimu.github.io/StringMetric.swift/Extensions/String.html Calculates the normalized most frequent K distance, providing a score from 0 (no similarity) to 1 (exact match). ```APIDOC ## distanceNormalizedMostFrequentK(between:k:) ### Description Get normalized most frequent K distance. (Score is normalized such that 0 equates to no similarity and 1 is an exact match). Reference https://www.semanticscholar.org/paper/A-high-performance-approach-to-string-similarity-K-Valdestilhas-Soru/2ce037c9b5d77972af6892c170396c82d883dab9 ### Method Swift ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift let str1 = "apple" let str2 = "apricot" let k = 2 let dist = str1.distanceNormalizedMostFrequentK(between: str2, k: k) ``` ### Response #### Success Response (200) - **distance** (Double) - The normalized most frequent K distance between the receiver and target. #### Response Example ```json { "distance": 0.85 } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.