dimanzver/fast-fuzzy-search
最新稳定版本:v0.2.4
Composer 安装命令:
composer require dimanzver/fast-fuzzy-search
包简介
Fast fuzzy search in an array of strings for the most similiar ones
README 文档
README
FastFuzzySearch aimed to search an array of words for the most similiar to the specified one
The used algorythm is much faster than using levenstein distance, or similiar_text functions.
Usage:
require_once("./FastFuzzySearch.php"); //Get words array: (it's english names, starting from A,B,C) $words = array( 'Abbott', 'Abe', 'Addison', 'Adrian', 'Aiken', 'Ainsley', 'Al', 'Alan', 'Alaric', 'Alban', 'Albert', 'Albion', 'Aldrich', 'Alec', 'Alex', 'Alexander', 'Alexis', 'Alf', 'Alfie', 'Alfred', 'Alger', 'Algernon', 'Alick', 'Allan', 'Allen', 'Alton', 'Alvin', 'Ambrose', 'Andrew', 'Andy', 'Anthony', 'Archer', 'Armstrong', 'Arnold', 'Ashley', 'Aston', 'Atwater', 'Aubrey', 'Austin', 'Avery', 'Bailey', 'Baldwin', 'Barclay', 'Barrett', 'Bartholomew', 'Barton', 'Basil', 'Baxter', 'Baz', 'Benedict', 'Benjamin', 'Bennett', 'Benson', 'Bentley', 'Berkley', 'Bernard', 'Bert', 'Bill', 'Blake', 'Bob', 'Bobby', 'Bond', 'Brad', 'Bradley', 'Brent', 'Bret', 'Brewster', 'Brian', 'Brigham', 'Brooke', 'Bruce', 'Bruno', 'Bryant', 'Buck', 'Bud', 'Burgess', 'Burton', 'Byron', 'Cade', 'Caesar', 'Caldwell', 'Calvert', 'Calvin', 'Carl', 'Carlton', 'Carter', 'Carver', 'Cary', 'Casey', 'Cassian', 'Cecil', 'Cedric', 'Chad', 'Chandler', 'Chapman', 'Charles', 'Charlie', 'Charlton', 'Chase', 'Chester', 'Chris', 'Christian', 'Christopher', 'Chuck', 'Clarence', 'Claude', 'Clay', 'Clayton', 'Clement', 'Cliff', 'Clifford', 'Clifton', 'Clive', 'Clyde', 'Cole', 'Coleman', 'Colin', 'Conrad', 'Constant', 'Conway', 'Corwin', 'Courtney', 'Craig', 'Crispin', 'Crosby', 'Curtis', 'Cuthbert', 'Cyril' ); //Create FastFuzzySearch object: $ffs = new FastFuzzySearch($words); //Lets pretend, this is user's input: $input = "charter"; //Lets get three most similiar english names: $results = $ffs->find($input, 3); //End output it: print_r($results);
Results would be:
Array
(
[0] => Array
(
[word] => carter
[percent] => 0.75
)
[1] => Array
(
[word] => chad
[percent] => 0.33333333333333
)
[2] => Array
(
[word] => charlie
[percent] => 0.26666666666667
)
)
统计信息
- 总下载量: 2.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-01