This is a fork of Beider-Morse and Daitch-Mokotoff soundex algorithms. Merged and reforged in object-oriented way for more convenient usage and development.
composer require dautkom/bmdm composer update --no-dev
I suggest to use library with composer autoloader. As an argument for BMDM()
constructor it's
possible to use 'sep' or 'ash' argument to initialize Sephardic or Ashkenazic phonetic subsystem. By default
'gen' for general ruleset is initialized.
require "../vendor/autoload.php"; $bmdm = new \dautkom\bmdm\BMDM();
Retrieve all supported languages
/** @var array */ $l = $bmdm->getLanguages();
Guess language for given string
/** @var array */ $g = $bmdm->set('Slim Shady')->guess();
Retrieve full soundex data
/** @var array */ $s = $bmdm->set('Slim Shady')->soundex();
Enable or disable debug mode
$bmdm->setDebug(true); $bmdm->setDebug(false);
Also you can call set()
once and use it as an object to call specific methods
$bmdm->set('Slim Shady'); $g = $bmdm->guess(); // array // OR $obj = $bmdm->set('Slim Shady'); $g = $obj->guess(); // array
There's only one method available for D-M soundex. Please note, that it's possible to parse only latin strings for D-M.
/** @var array */ $s = $bmdm->set('Slim Shady')->dm->soundex();
I suggest using generic methods to retrieve soundex data. However it's possible to call B-M methods directly.
Retrieve soundex data, phonetic keys only
/** @var array */ $p = $bmdm->set('Slim Shady')->bm->soundex();
Retrieve possible language names for given string
/** @var array */ $l = $bmdm->set('Slim Shady')->bm->getLanguageNames();
Retrieve list of languages from given internal code
/** @var array */ $l = $bmdm->bm->getLanguagesFromCode(12);
Retrieve language internal code from its' name
/** @var int */ $c = $bmdm->bm->getLanguageCodeFromName('arabic');
© 2008-2016 Alexander Beider and Stephen P. Morse
© 2013-2016 Olegs Capligins