从DataFrame中的字符串列创建距离矩阵



我尝试在没有成功的情况下使用此代码:

library(fuzzywuzzyR)
library(proxy)
set.seed(42)
rm(list = ls())
options(scipen = 999)
init = FuzzMatcher$new()
data <- data.frame(string = c("aaaaa baaaaa", "baaaaa xxxhhx ", "caaaaa hhhr ejhhehe"))
data$string <- as.character(data$string)
f <- function(string_1, string_2) {
    init$Token_set_ratio(string1 = string_1, string2 = string_2, force_ascii = TRUE, full_process = TRUE)
}
proxy::dist(data$string, method = f)

目的是使用代理:: dist和fuzzywuzzyr软件包在每行之间生成距离。

错误:

错误:两个参数'string1'和'string2'应为类型 字符串 另外:警告消息: 在do.call("。外部",c(列表(cfun,x,y,pairwise,if(!is.function(method((get(method(else方法(,: NAS由CORCION引入

我在计算机上测试了它,并通过install.packages安装了fuzzywuzzyr软件包。这将软件包安装好了,但是当我运行init$Token_set_ratio(string1 = s1, string2 = s2, force_ascii = TRUE, full_process = TRUE) 时,这给了我attempt to apply non-function的错误,而CC_2的错误又在后来的调用中返回NAs introduced by coercion。我相信问题可能与https://github.com/mlampros/fuzzywuzzyR/issues/4相似,我什至无法在小插图中运行基本示例。我相信该软件包被损坏或不保留,因为我甚至无法在GitHub存储库中运行UTILS部分,而不会遇到相同的非功能错误。抱歉,这无法解决您的问题,但也许会有所帮助。

最新更新