dautkom / bmdm
比尔德-莫尔斯加上代奇-莫科托夫音节
Requires
- php: >=5.4.0
- ext-mbstring: *
Requires (Dev)
- monolog/monolog: *
- phpunit/phpunit: 5.5.*
This package is not auto-updated.
Last update: 2024-09-14 19:47:35 UTC
README
这是由Alexander Beider和Stephen P. Morse开发的算法的分支,用于姓名和单词的音位匹配。与soundex()和methaphone()相比,该算法生成的误报数量更少。此外,还可以在不进行转写的情况下使用此算法处理某些非拉丁字母表。
致谢
作者:Alexander Beider,巴黎 和 Stephen P. Morse,旧金山
网站:http://stevemorse.org/phoneticinfo.htm(源代码下载,信息及联系方式)
信息
目前支持16种语言:捷克语、荷兰语、英语、法语、德语、希腊语(希腊拉丁语)、希伯来语、匈牙利语、意大利语、拉脱维亚语、波兰语、葡萄牙语、罗马尼亚语、俄语(拉丁和西里尔)、西班牙语、土耳其语。此外,BMPM(Beider-Morse Phonetic Matching)及其衍生品BMDM可以根据阿什肯纳兹和塞法迪规则解析希伯来语姓名。
差异
此分支的目标是去除已废弃的全球函数、全局变量,并以面向对象的方式表示算法。还实现了一些修改和修复,以实现统一。现在,超出了过程代码的极限,可以在不费劲的情况下将算法包含在框架和第三方应用程序中。添加了拉脱维亚语言的实验性支持。
需求
PHP 5.4+;mbstring 扩展
性能
强烈建议使用PHP 7.0及以上版本,因为从5.x版本以来,性能有了显著提升,特别是在数组处理方面,这对BMDM至关重要。此外,还内置了缓存支持 - 确保运行目录./runtime可写,并让BMDM预编译并缓存其运行规则。以下是有和无缓存的性能图表。此外,缓存降低了I/O负载。测试结果可在这里找到。
用法
包含BMDM.php或最好使用composer安装: composer require dautkom/bmdm
<?php // You want to run ./composer install before require "../vendor/autoload.php"; $bmdm = new \dautkom\bmdm\BMDM(); // Process string with a Beider-Morse algorithm and retrieve BM phonetic keys $p = $bmdm->set('Hello world')->soundex() // Try to guess string's language $l = $bmdm->set('Grzegorz')->guess() // Retrieve all supported languages $g = $bmdm->getLanguages() // Process string with a Beider-Morse algorithm and retrieve phonetic keys $b = $bmdm->set('ברצלונה')->bm->soundex() // Try to guess string's language and retrieve only language names $l = $bmdm->set('Grzegorz')->bm->getLanguageNames() // Retrieve Daitch-Mokotoff soundex values // Only latin symbols are supported $d = $bmdm->set('Grzegorz')->dm->soundex()
阿什肯纳兹和塞法迪支持
<?php require "../vendor/autoload.php"; // Using 'ash' upon init will load Ashkenazi phonetic rules // Use 'sep' instead of 'ash' to init Sephardic rules $bmdm = new \dautkom\bmdm\BMDM('ash');
字符串中包含多种语言
<?php require "../vendor/autoload.php"; $bmdm = new \dautkom\bmdm\BMDM(); $p = $bmdm->set('This is Спарта!')->soundex()
不同语言的匹配
<?php require "../vendor/autoload.php"; $bmdm = new \dautkom\bmdm\BMDM(); // Words in different languages with the same pronunciation // in most cases give intersections in results. print_r($bmdm->set('Zelinska')->soundex()); print_r($bmdm->set('Зелинска')->soundex()); // ## Latin string // Array // ( // [input] => zelinska // [numeric] => Array // ( // [0] => Array // ( // [0] => 486450 // ) // // ) // // [phonetic] => Array // ( // [0] => Array // ( // [0] => zYlnzki // [1] => zilnzki // ) // // ) // // ) // // ## Cyrillic string // Array // ( // [input] => зелинска // [numeric] => Array // ( // [0] => Array // ( // [0] => 486450 // ) // // ) // // [phonetic] => Array // ( // [0] => Array // ( // [0] => zYlnzka // [1] => zYlnzko // [2] => zilnzka // [3] => zilnzko // ) // // ) // // )
修改
如果您要修改规则,请禁用开发过程中的缓存,并在之后清理./runtime目录。否则,将加载过期的缓存数据。
许可证
项目在GNU GPL v3许可证下分发,希望它将是有用的,但没有任何保证;甚至没有关于其商售性或适用于特定目的的暗示保证。有关详细信息,请参阅GNU通用公共许可证。
版权(c)2008-2016 Alexander Beider和Stephen P. Morse
版权(c)2013-2016 Olegs Capligins