• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ PHP Similar Text Finder aka Fuzzy search. `Did you mean "banana"?`

Similar Text Finder

Packagist Scrutinizer Code Quality Build Status Code Coverage SensioLabsInsight 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.

More Repositories

1

laravel-log-viewer

๐Ÿช Laravel log viewer
PHP
3,041
star
2

fast-excel

๐Ÿฆ‰ Fast Excel import/export for Laravel
PHP
1,784
star
3

vue-picture-swipe

๐Ÿ–ผ Vue Picture Swipe Gallery (a gallery of image with thumbnails, lazy-load and swipe) backed by photoswipe
Vue
383
star
4

pg-anonymizer

Dump anonymized PostgreSQL database with a NodeJS CLI
TypeScript
154
star
5

laravel-stripe-connect

๐Ÿฆ“ Stripe Connect binding for Laravel
PHP
73
star
6

mysql-xplain-xplain

๐Ÿญ Explain Explainer for MySQL Queries.
PHP
53
star
7

laravel-epilog

๐Ÿˆ IP, referer, user ID and more in Laravel logs
PHP
25
star
8

taskz

๐Ÿก Sequential and parallel task list runner for terminal
JavaScript
23
star
9

laravel-prod-server

Install and run a production server for a Laravel application
22
star
10

create-user-command

๐Ÿฆ€ Create User with artisan
PHP
21
star
11

vue-quiz

Create a quiz withย Vue.js
HTML
20
star
12

laravel-credit-card-validator

๐Ÿฅ Laravel Credit Card Validator
PHP
19
star
13

landscape

Procedural landscape
Rust
17
star
14

jacky

๐Ÿ„ HTTP JSON API Client for Laravel & Lumen
PHP
17
star
15

llamassacre

Uncommented-spaghettiesque-dirty code. RUN AWAY.
Rust
15
star
16

remove-stop-words

Remove stop words from a string
PHP
15
star
17

htmltopdf

html to pdf website using wkhtmltopdf
Rust
9
star
18

vue-calendar

HTML
8
star
19

mongodb-anonymizer

Anonymize MongoDB database with a NodeJS CLI
TypeScript
8
star
20

uuid-rule

UUID validation rule for Laravel
PHP
7
star
21

mongodb-elasticsearch-sync

Copy data from MongoDB to Elasticsearch with a NodeJS CLI
TypeScript
6
star
22

voltaire

Proof-reading tool for PHP (spell checker, grammar fixer using LanguageTool)
PHP
6
star
23

facteur

Laravel deployer
Rust
4
star
24

nestor

๐Ÿน Do task, rollback if something goes wrong. Just like database transactions.
PHP
4
star
25

convert-accent-characters

Converts all UTF-8 accent characters to ASCII characters
PHP
4
star
26

midikaos

๐ŸŽท Standard MIDI Files Library website
TypeScript
3
star
27

glitcher-web

๐ŸŽต WAV glitcher, generate broken beats from sample loops
TypeScript
3
star
28

csv-to-associative-array

Get your CSV as an associative array
PHP
3
star
29

ortf

Statistiques de /r/france
TypeScript
2
star
30

react-fairy-tale-emoji

JavaScript
2
star
31

fuzzy-dubstep

Jeu HTML5/JS avec Quintus (+PHP pour generation) : simulation de prรฉparation de mariage
PHP
2
star
32

mynia

Unicorn name generator
Rust
1
star
33

drum-loop-glitcher-sonic-pi

work in progress
Ruby
1
star
34

find-the-cat

Find and click the cat.
JavaScript
1
star
35

indice

Hints for Laravel errors
Blade
1
star
36

420-bot

PHP
1
star
37

create-elasticsearch-dataset

Create a sample dataset for Elasticsearch with one command
TypeScript
1
star
38

drum-beats

Procedural Drum Beats website
Rust
1
star
39

starfield

Rust
1
star