Download the PHP package designbycode/levenshtein-distance without Composer
On this page you can find all versions of the php package designbycode/levenshtein-distance. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download designbycode/levenshtein-distance
More information about designbycode/levenshtein-distance
Files in designbycode/levenshtein-distance
Package levenshtein-distance
Short Description The LevenshteinDistance class provides a method to calculate the Levenshtein distance between two strings. The Levenshtein distance is a measure of the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other.
License MIT
Homepage https://github.com/designbycode/levenshtein-distance
Informations about the package levenshtein-distance
Levenshtein Distance
The LevenshteinDistance class provides a method to calculate the Levenshtein distance between two strings. The Levenshtein distance is a measure of the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other.
Installation
You can install the package via composer:
Method: calculate
Parameters
- mixed $str1: The first string.
- mixed $str2: The second string.
-
Return Value
- int: The Levenshtein distance between the two strings.
Description
- Calculates the Levenshtein distance between two strings. The method throws a TypeError if either of the input parameters is not a string.
Use Cases
- Spell Checking: Calculate the Levenshtein distance between a user's input and a list of known words to suggest corrections.
- Text Similarity: Measure the similarity between two pieces of text by calculating the Levenshtein distance.
- Data Validation: Verify the correctness of user input by calculating the Levenshtein distance between the input and a known valid value.
Usage
Example 1: Calculating the Levenshtein distance between two strings
Example 2: Handling non-string input
Example 3: Using Levenshtein distance for spell checking
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.