我需要使用sparklyr在R中计算两个字符串之间的距离。是否有一种使用stringdist或其他包的方法?我想使用余弦距离。此距离被作为stringdist函数的一种方法使用。
提前致谢。
提前致谢。
levenshtein
函数:df <- copy_to(sc, data.frame(a=c("This is it", "Foo"), b=c("This is", "foobar)))
# df %>% mutate(dist = levenshtein(a, b))
# # Source: lazy query [?? x 3]
# # Database: spark_connection
# a b dist
# <chr> <chr> <int>
# 1 This is it This is 3
# 2 Foo foobar 4
sparklyr
中使用非内置的字符串距离度量方法?比如 Jaro-Winkler,该方法可在此包中获得:https://github.com/MrPowers/spark-stringmetric。 - jfeigenbaum