Download the PHP package designbycode/fuzzy-search without Composer
On this page you can find all versions of the php package designbycode/fuzzy-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download designbycode/fuzzy-search
More information about designbycode/fuzzy-search
Files in designbycode/fuzzy-search
Package fuzzy-search
Short Description The Fuzzy Search package provides a simple and efficient way to perform fuzzy searches on a collection of texts using the Levenshtein distance algorithm. This package is useful when you need to search for texts that may contain typos or slight variations.
License MIT
Homepage https://github.com/designbycode/fuzzy-search
Informations about the package fuzzy-search
Fuzzy Search
Introduction
The Fuzzy Search package provides a simple and efficient way to perform fuzzy searches on a collection of texts using the Levenshtein distance algorithm. This package is useful when you need to search for texts that may contain typos or slight variations.
Installation
To install the Fuzzy Search package, simply require it in your PHP project using Composer:
Usage
Creating a Fuzzy Search Instance
To create a Fuzzy Search instance, you need to pass an array of texts to search and an optional flag for case-insensitive search:
Performing a Fuzzy Search
To perform a fuzzy search, call the search
method and pass the search query and an optional maximum Levenshtein distance:
The search method returns an array of matching texts, sorted by their Levenshtein distance from the search query.
Getting the Best Match
To get the best match from the search results, call the getBestMatch method:
Levenshtein Distance Calculator
The Levenshtein Distance Calculator is a utility class that calculates the Levenshtein distance between two strings. This class is used internally by the Fuzzy Search package.
Calculating the Levenshtein Distance
To calculate the Levenshtein distance between two strings, call the calculate method:
Examples
Example 1: Fuzzy Search with Case-Insensitive Search
Example 2: Fuzzy Search with Case-Sensitive Search
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Claude Myburgh
- All Contributors
License
The MIT License (MIT). Please see License File for more information.