承接 rap2hpoutre/similar-text-finder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rap2hpoutre/similar-text-finder

最新稳定版本:1.1.0

Composer 安装命令:

composer require rap2hpoutre/similar-text-finder

包简介

Fuzzy Search, similar text finder: "Did you mean `foo` ?"

README 文档

README

Packagist Code Coverage Packagist

TL;DR

Similar text finder. Install via composer, works with any framework: Laravel, Slim, Symfony, etc.

screenshot

// Init Similar Text Finder with a needle and a haystack
$text_finder = new \SimilarText\Finder('bananna', ['apple', 'banana', 'kiwi']);

// Get first similar word (it's banana)
echo $text_finder->first();

Installation

Install with composer composer require rap2hpoutre/similar-text-finder. That's all.

You can now use it in your framework's controller, or wherever you want (you don't need a framework anyway).

Usage

Quick start

Just build a new Similar Text Finder like this:

$tf = new \SimilarText\Finder($needle, $haystack);

$needle may be the user input and $haystack should be an array with all your suggestion. You can display the closest response like this:

echo 'Did you mean ' $tf->first() . ' ?';

Or use it in your favorite template engine (Twig, Blade, etc.)

You can get all your suggestion ordered by most approching words like this:

$all = $tf->all();

Example in raw PHP

use SimilarText\Finder;

// User input with a typo (you could get it from $_GET)
$needle = 'tmatoes';

// Your list (from your database or an API)
$haystack = ['salad', 'tomatoes', 'onions', 'mates'];

// Init Text Finder
$finder = new Finder($needle, $haystack);

// Display all results ordered by the most approching
$results = $finder->all();
echo implode(', ', $results);

// You should see something like "tomatoes, mates, onions, salad", yohoo.

统计信息

  • 总下载量: 77.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 142
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 137
  • Watchers: 10
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-21