Download the PHP package celestial/lexicology without Composer
On this page you can find all versions of the php package celestial/lexicology. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download celestial/lexicology
More information about celestial/lexicology
Files in celestial/lexicology
Informations about the package lexicology
Lexicology
PHP lexicology library.
While we only test PHP 7+, this library does work with PHP 5.x. PHP Sorting methods changed how they deal with equal sort values in 7+ - so suggestion arrays will differ.
- Suggests values from an array based on a lexical comparison
- Return sorted array based on lexical comparison
- Pick best match from an array
- Pick best match associations between arrays
Core Lexical Comparisons
- levenshtein using
LevenshteinDistance
- preg_grep using
PregGrep
- similar_text using
Similarity
- soundex using
Soundex
Also allows custom lexical comparison by extending Celestial\Lexicology\Method\AbstractMethod
and implementing Celestial\Lexicology\Method\MethodInterface
. See Custom Method
Install
Composer
or composer.json
Use
Suggestion
The Suggestion
class will suggest an array or value that match closely to a needle.
The default method is PregGrep but that can be changed to one of the other methods or a custom method.
Attempting to get a single 'best' suggestion value will return a string or throw an exception. If you need to suppress the exception and return a non-standard or shared value (such as a meta field or constant) use the fourth parameter to override the result.
Supressing an exception:
Custom Method
A custom Method definition must implement either a FilterInterface
or RateInterface
While this custom method doesn't do anything extraordinary, it's a basic example of the interfaces for a lexical method.