普贤教程 › 包参考
phonetic 包
语音编码
| 项 | 值 |
|---|---|
| 包名 | phonetic |
| 版本 | 0.1.0 |
| 入口 | phonetic.px |
| 分类 | 文本与中文处理 |
| 文件数 / 行数 | 1 / 312 |
安装与引入
bash
pxpkg init # 首次 pxpkg add phonetic@0.1.0 pxpkg install
px
import phonetic所属分类教程:文本与中文处理
公开接口
| 函数 | 参数 |
|---|---|
ph_soundex | s |
ph_metaphone | s |
ph_nysiis | s |
ph_match | a, b |
ph_distance | a, b |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/phonetic —— 语音编码 ------------------------------------------------------------ 纯函数库,双模式一致。 对齐 PHP soundex / metaphone、Python jellyfish、Go xstrings: ph_soundex(s) → Soundex 编码(4 字符,如 "Robert" → "R163") ph_metaphone(s) → Metaphone 编码(简化版,如 "Smith" → "SM0") ph_nysiis(s) → NYSIIS 编码(New York State Identification) ph_match(a, b) → 两字符串语音是否相似(soundex 相同) ph_distance(a, b) → 语音编辑距离(soundex 差异字符数) ============================================================