PHP Classes

Russian PHP Metaphone: Generate a phonetic representation of Russian word

Recommend this page to a friend!
  Info   View files Documentation   View files View files (17)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 37 This week: 1All time: 10,888 This week: 560Up
Version License PHP version Categories
metaphone 1.0MIT/X Consortium ...5Algorithms, PHP 5, Text processing, A...
Description 

Author

This package is specific mainly for applications used in Russian Federation Russian Federation .

This package can generate a phonetic representation of Russian word.

It can take a string with Russian words and returns another string that is the result of applying the Metaphone algorithm considering the way the words are spelled in Russian.

The package an apply several types of filters to the words that consider several aspects like consonants, last name endings and double characters.

Innovation Award
PHP Programming Innovation award nominee
November 2020
Number 2


Prize: 1 year subscription to the Basic Plan of an API product of choice
Metaphone is popular algorithm that is used to convert words in a given language to the phonetic representation of the words.

This allows to compare two words or two sentences to detect how similar they may be in terms of pronunciation.

This way it is possible to detect if the user has written a given word or sentence with spelling mistakes.

The pronunciation rules are different from language to language. The most common implementations of the algorithm are meant to be used with sentences in the English language.

This package provides an implementation of the Metaphone algorithm that works well in Russian.

Manuel Lemos
Picture of Insolita
  Performance   Level  
Name: Insolita <contact>
Classes: 20 packages by
Country: Russian Federation Russian Federation
Age: 38
All time rank: 335492 in Russian Federation Russian Federation
Week rank: 411 Up22 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 14x

Documentation

Russian metaphone phonetic algorithm implementation for PHP

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


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files, 1 directory)
Files folder imagetests (6 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imagefilters (5 files)
  Plain text file Filter.php Class Class source
  Plain text file Metaphone.php Class Class source

  Files folder image Files  /  src  /  filters  
File Role Description
  Plain text file HandleConsonants.php Class Class source
  Plain text file HandleLastnameEndings.php Class Class source
  Plain text file Normalize.php Class Class source
  Plain text file RemoveDoubleChars.php Class Class source
  Plain text file Replacements.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file HandleConsonantsTest.php Class Class source
  Plain text file HandleLastnameEndingsTest.php Class Class source
  Plain text file MetaphoneTest.php Class Class source
  Plain text file NormalizeTest.php Class Class source
  Plain text file RemoveDoubleCharsTest.php Class Class source
  Plain text file ReplacementsTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:37
This week:1
All time:10,888
This week:560Up