fuzzystrmatch
确定字符串之间的相似性和距离
fuzzystrmatch · 确定字符串之间的相似性和距离
概览
| ID | 扩展 | 软件包 | 版本 | 类别 | 许可证 | 编程语言 |
|---|---|---|---|---|---|---|
| 2380 | fuzzystrmatch | fuzzystrmatch | 1.2 | FTS | PostgreSQL | C |
| 属性 | 可执行文件 | 动态库 | 需要预加载 | 需要建扩展 | 可迁移 | 可信 |
|---|---|---|---|---|---|---|
| --s-dtr | 否 | 是 | 否 | 是 | 是 | 是 |
| 关联 | |
|---|---|
| 被依赖 | postgis_tiger_geocoder |
| 相关扩展 | pg_trgm pg_similarity smlar pgpcre re2 pg_bigm biscuit unaccent citext |
软件包
| PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|
| 1.2 | 1.2 | 1.2 | 1.2 | 1.2 |
此 contrib 扩展随 PostgreSQL 一起发行。
安装
在数据库中创建扩展。
用法
fuzzystrmatch 模块提供了判断字符串之间相似度和距离的函数。
Soundex
将字符串转换为 Soundex 编码(适用于匹配发音相似的名称):
difference 函数返回 0-4,其中 4 表示最相似。
Daitch-Mokotoff Soundex
返回 Daitch-Mokotoff soundex 编码集合(对非英语名称效果更好):
支持 GIN 索引:
Levenshtein 距离
计算两个字符串之间的编辑距离(插入、删除、替换):
Metaphone
返回字符串的 metaphone 编码:
Double Metaphone
返回主要和备选编码(处理更多名称变体):