Fuzzy Search Algorithms in Multiple Programming Languages

Have you ever wondered how modern editors like Sublime Text, VSCode, and others, manage to implement that cool feature known as Fuzzy Searching, where you only need to type a few characters to obtain increasingly accurate matching results?

Sublime Text 2 screenshot

In 2017, Forrest Smith wrote an article entitled Reverse Engineering Sublime Text’s Fuzzy Match, where he presented his own algorithms to implement fuzzy searching in C++ and JavaScript. Both his article and algorithms soon gained popularity and inspired other users to implement their own ports in other languages too, especially after Sublime Text author Jon Skinner replied to the article, adding some suggestions for further improvements.

The beauty of Forrest’s algorithm lies in its simplicity, and the fact that it was released into the public domain. It’s an entry-level approach to a complex subject, and although there are more sophisticated algorithms in the wild to implement fuzzy searching, Forrest’s implementation is the ideal solution to get one’s feet wet with the topic, without the complexity.

Many projects have used Forrest’s fts_fuzzy_match as their first fuzzy searching algorithm, and then later on adopted more complex algorithms instead.

Time to meet fuzzy-search, a repository built around Forrest’s fts_fuzzy_match algorithms, with numerous new ports to other languages, and which needs help to grow even further:

Fuzzy Search implementations are available in C#, C++, Delphi/FreePascal, Elixir, F#, JavaScript, Lua, PHP and Python — and the list is steadily growing.

The project has recently re-published the original article by Forrest Smith, in AsciiDoc format, with kind permission of its original author.

Today I’ve just added to the repository test data to help porters of the algorithms ensure their implementation are producing correct matches.

I hope that this project will inspire others to explore the beauty of Fuzzy Search user interfaces and the algorithms that power them, and that this announcement will increase awareness of the project and attract more contributors, for it’s a community oriented project trying to cover as many languages as possible.

Anyone willing to pick up the Fuzzy Matching challenge, and implement his/her own take on the algorithm in yet another programming language? It’s fun, and you’ll be learning the magic behind those cool user editors’ interfaces which make a programmer’s life so much easier and more productive, and start using them in your applications too.

Contributions to the project are most welcome and, indeed, needed. Managing so many different languages in one repository it’s not easy, and demands community support.

Don’t forget to :star: the repository, if you like what you see!