目录
1: 如何计算两字段中字符串的相似程度?
有时候我们需要对比两个字段相似程度,Oracle提供一个函数用于使用。
涉及函数(11gR2)
UTL_MATCH 的4个子程序来进行处理(subprogram)
Subprogram | Description |
---|---|
EDIT_DISTANCE | Calculates the number of changes required to transform string-1 into string-2 计算字符串string-1 转成string-2需要做几次改变 |
EDIT_DISTANCE_SIMILARITY | Calculates the number of changes required to transform string-1 into string-2, returning a value between 0 (no match) and 100 (perfect match) 计算字符串string-1 转成string-2需要做改变的次数,剩下的值,0代表没有一个字符匹配,100代表完全匹配 |
JARO_WINKLER | Calculates the measure of agreement between string-1 and string-2 计算字符串1和字符串2之间的一致程度 |
JARO_WINKLER_SIMILARITY | Calculates the measure of agreement between string-1 and string-2, returning a value between 0 (no match) and 100 (perfect match)计算字符串1和字符串2之间的一致程度,返回0(不匹配)和100(完全匹配)之间的值 |
UTL_MATCH函数简介
The UTL_MATCH package facilitates matching two records. This is typically used to match names, such as two First Names or two Last Names.
译文:UTL_MATCH包有助于匹配两个记录。 这通常用于匹配名称,例如两个名或两个姓。
Edit Distance 概念
“Edit Distance”也称为“ Levenshtein距离”(以俄罗斯科学家Vladimir Levenshtein的名字命名,他于1965年设计了该算法),它是两个字符串s1和s2之间相似度的量度。 距离是将s1转换为s2所需的插入,删除或替换的数量。
UTL_MATCH.EDIT_DISTANCE((string-1, string-2)
UTL_MATCH.EDIT_DISTANCE_SIMILARITY(string-1, string-2)
Jaro-Winkler 概念
“ Jaro-Winkler算法”是另一种计算两个字符串之间的编辑距离的方法。 在美国人口普查局开发的此方法是一种字符串比较器量度,可提供两个字符串之间的部分一致值。 字符串比较器考虑了字符串的长度,部分考虑了字母数字字符串中常见的人为错误。