insolita/metaphone

Metaphone algorithm implementation adopted to russian

1.0.0 2020-11-01 20:55 UTC

This package is auto-updated.

Last update: 2020-12-31 21:22:14 UTC


README

metaphone 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