2017 © Pedro Peláez
 

library similar-text-finder

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

image

rap2hpoutre/similar-text-finder

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

  • Sunday, June 10, 2018
  • by rap2hpoutre
  • Repository
  • 10 Watchers
  • 91 Stars
  • 15,663 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 9 Versions
  • 8 % Grown

The README.md

Similar Text Finder

Packagist Code Coverage Packagist, (*1)

TL;DR

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

screenshot, (*3)

// 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., (*4)

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

Usage

Quick start

Just build a new Similar Text Finder like this:, (*6)

$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:, (*7)

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

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

You can get all your suggestion ordered by most approching words like this:, (*9)

$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.

The Versions

10/06 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Development Requires

by Avatar rap2hpoutre

laravel search text levenshtein find fuzzy similar_text

12/05 2017

dev-composerci6081

dev-composerci6081

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

  Sources   Download

MIT

The Development Requires

by Avatar rap2hpoutre

laravel search text levenshtein find fuzzy similar_text

12/05 2017

dev-composerci1871

dev-composerci1871

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

  Sources   Download

MIT

The Development Requires

by Avatar rap2hpoutre

laravel search text levenshtein find fuzzy similar_text

10/06 2016

v0.2.0

0.2.0.0

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

  Sources   Download

MIT

The Development Requires

by Avatar rap2hpoutre

laravel search text levenshtein find fuzzy similar_text

08/05 2015

v0.1.2

0.1.2.0

Similar text finder: "Did you mean `foo` ?"

  Sources   Download

MIT

The Development Requires

by Avatar rap2hpoutre

laravel search text levenshtein find similar_text

08/05 2015

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1

Similar text finder: "Did you mean `foo` ?"

  Sources   Download

MIT

The Development Requires

by Avatar rap2hpoutre

laravel search text levenshtein find similar_text

21/04 2015

v0.1.1

0.1.1.0

Similar text finder: "Did you mean `foo` ?"

  Sources   Download

MIT

by Raphael Huchet

21/04 2015

v0.1.0

0.1.0.0

Similar text finder: "Did you mean `foo` ?"

  Sources   Download

MIT

by Raphael Huchet

21/04 2015

v0.0.1

0.0.1.0

Similar text finder: "Did you mean `foo` ?"

  Sources   Download

MIT

by Raphael Huchet