insolita / metaphone
Metaphone algorithm implementation adopted to russian
1.0.0
2020-11-01 20:55 UTC
Requires
- php: >=7.1
- voku/portable-utf8: ^5.4
Requires (Dev)
- phpunit/phpunit: ^7.0|^8.0|^9.4
README
port of ruby's https://github.com/pavlo/russian_metaphone
https://en.wikipedia.org/wiki/Metaphone
see http://forum.aeroion.ru/topic461.html (Russian algorithm description)
Installation
composer require insolita/metaphone
Usage
<?php
$word = 'вода';
$phonetic = (new Metaphone())->processWord($word); //вада
Default set of filters include filter for lastname endings, if you want exclude only these filter, you can use helper
$withLastnames = (new Metaphone())->processWord('Чернышевский'); //чирнаш#
$withoutLastnames = (new Metaphone())->skipLastnames()->processWord('Чернышевский'); //чирнашифский
Provide custom filters. Each filter must implement insolita\metaphone\Filter
$metaphone = new Metaphone([Normalize::class, new CustomFilter($params), new HandleConsonants(true), ...])
$phonetic = $metaphone->processWord($word);
See tests folder for better understanding filters