- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否有内置方法来量化 agrep
的结果?功能?例如。在
agrep("test", c("tesr", "teqr", "toar"), max = 2, v=T)
[1] "tesr" "teqr"
tesr
距离
test
仅 1 个字符排列, 而
teqr
是 2,并且
toar
是 3,因此未找到。显然,
tesr
具有比
teqr
更高的“概率” .如何以排列数或百分比检索它?
agrep
获取我的列表,然后
adist
得到N个排列。
adist
速度较慢,运行时间是我数据集中的一个重要因素
最佳答案
使用 adist()
的另一种选择:
s <- c("tesr", "teqr", "toar")
s[adist("test", s) < 3]
stringdist
library(stringdist)
s[stringdist("test", s, method = "lv") < 3]
#[1] "tesr" "teqr"
x <- rep(s, 10e5)
library(microbenchmark)
mbm <- microbenchmark(
levenshteinDist = x[which(levenshteinDist("test", x) < 3)],
adist = x[adist("test", x) < 3],
stringdist = x[stringdist("test", x, method = "lv") < 3],
times = 10
)
Unit: milliseconds
expr min lq mean median uq max neval cld
levenshteinDist 840.7897 1255.1183 1406.8887 1398.4502 1510.5398 1960.4730 10 b
adist 2760.7677 2905.5958 2993.9021 2986.1997 3038.7692 3472.7767 10 c
stringdist 145.8252 155.3228 210.4206 174.5924 294.8686 355.1552 10 a
关于R: agrep 结果量词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33348437/
是否有内置方法来量化 agrep 的结果?功能?例如。在 agrep("test", c("tesr", "teqr", "toar"), max = 2, v=T) [1] "tesr" "teqr
尽管我将 max.distance 限制为零,为什么 agrep 会找到匹配项? adist 确实正确地告诉我,我需要两次插入... > agrep("ab", "abcd", max = list(
我在 R 中使用“agrep”函数,它返回匹配向量。我想要一个类似于 agrep 的函数,它只返回最佳匹配,或者如果存在平局则返回最佳匹配。目前,我正在对结果向量的每个元素使用“cba”包中的“sdi
我有一个模式向量,需要对它们使用 agrep。问题是 agrep 似乎一次只采用一种模式。 patt 1 and only the first element will be used lapply
我的目标是确定是否给定 text有一个 target字符串,但我想允许拼写错误/小派生并提取“导致”匹配的子字符串(将其用于进一步的文本分析)。 示例: target <- "target strin
在?agrep(带有模糊匹配的grep)中,它提到我可以设置参数fixed=FALSE来解释我的模式作为正则表达式。 但是,我无法让它工作! agrep('(asdf|fdsa)', 'asdf',
我正在尝试做的是使用 agrep 获取文件中最匹配的词和它的错误数。现在我只能使用这个脚本来获取单词: array=(bla1 bla2 bla3) for eachWord in "${array[
我是一个 R 新手,一直在尝试使用 agrep 进行一些实验。 R 中的函数。我有一个庞大的客户数据库(150 万行),我确信其中有很多重复项。尽管使用 table() 来获取重复确切名称的频率,但并
我需要一些帮助来理解这些函数的参数。我从帮助中拿了例子。 ## To see the transformation counts for the Levenshtein distance: drop(
我正在尝试从 data.frame 转换至 data.table ,并且需要一些关于我正在尝试在单个列上执行的逻辑索引的建议。这是我有的一张表: places <- data.table(name=c
使用 R,我尝试匹配按年份和城市构建的数据集中的人名。由于一些拼写错误,无法精确匹配,因此我尝试使用 agrep() 来模糊匹配名称。 数据集的示例 block 的结构如下: df <- data.f
我有一个字符串: string <- "I do not like green eggs and ham!" 和一个图案 pattern <- "(egs|ham)" 我想知道多少次pattern匹配
我的Java程序需要启动agrep.exe,其参数包含大矩阵中所有元素对的参数,并获取两个字符串的匹配错误数。我写了一段代码,但是运行速度很慢。我可以加快这部分代码的速度吗?或者,也许你可以建议我一些
我正在尝试使用 agrep 找出两个字符串名称之间模糊字符串匹配的最佳精度。 但是,由于字符串数量巨大,我需要选择一个精度“max.distance”以将其应用于我尝试匹配的所有字符串。不可能为我尝试
编辑:这个错误是在 32 位版本的 R 中发现的,已在 R 版本 2.9.2 中得到修复。 这是@leoniedu 今天发给我的推特,我没有他的答案,所以我想我会把它贴在这里。 我已经阅读了 agre
我是一名优秀的程序员,十分优秀!