【问题标题】:Is there an R function for computing fast Levenshtein distance with threshold (maxDist)是否有用于计算具有阈值(maxDist)的快速 Levenshtein 距离的 R 函数
【发布时间】:2021-10-25 08:57:21
【问题描述】:

我正在寻找一个 R 函数,如果 Levenshtein 距离小于阈值,它会返回两个字符串的 Levenshtein 距离,并且通过不计算大于阈值的 Levenshtein 距离来节省时间。阈值是给定的,应该在 2 到 10 之间。起初,我认为使用阈值可以节省很多计算时间,但我对此不再那么确定了。 我尝试使用 stringdist 包中的 amatchmaxDist 参数,但与不使用阈值相比,它似乎没有加速算法。

【问题讨论】:

  • 提供一个最小可重现的例子。

标签: r string levenshtein-distance


【解决方案1】:

有一个名为RecordLinkage 的包,其中包括levenshteinSimlevenshteinDist 函数。

此软件包已过期,但可以与old versions 的源文件一起安装。

这里是RecordLinkagepackage manifest;的levenshteinSim功能说明

Details
String metrics compute a similarity value in the range [0, 1] for two strings, with 1 denoting the
highest (usually equality) and 0 denoting the lowest degree of similarity. In the context of Record
Linkage, string similarities can improve the discernibility between matches and non-matches.
jarowinkler is an implementation of the algorithm by Jaro and Winkler (see references). For the
meaning of W_1, W_2, W_3 and r see the referenced article. For most applications, the default values
are reasonable.
levenshteinDist returns the Levenshtein distance, which cannot be directly used as a valid string
comparator. levenshteinSim is a similarity function based on the Levenshtein distance, calculated
by 1 −
d(str1,str2)
max(A,B)) , where d is the Levenshtein distance function and A and B are the lenghts of the
strings.
Arguments str1 and str2 are expected to be of type "character".

您可以通过这种方式使用 .tar.gz 从源文件安装软件包;

How do I install an R package from source?

【讨论】:

    猜你喜欢
    • 2023-04-10
    • 1970-01-01
    • 2014-04-20
    • 2013-04-23
    • 2011-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多