Skip to content

cyrilchandelier/String-Levenshtein

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

String+Levenshtein.swift

A Swift extension on String to compute Levenshtein distance between words.

Installation

Copy the String+Levenshtein.swift file into your project.

Usage

To retrieve the Levenshtein distance between two words, simply call the levenshteinDistance method on one word with the other.

Example:

let firstWord: String = "Hello"
let secondWord: String = "Help"
let levenshteinDistance: Int = firstWord.levenshteinDistance(with: secondWord)
print(levenshteinDistance) // Prints "2"

Sample

Have a look to the sample project to see how this extension can be use to display a "Did you mean?" hint to users in search results.

About

Swift extension on String to compute Levenshtein distance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages