【问题标题】:Fuzzy merging in RR中的模糊合并
【发布时间】:2017-11-18 13:52:51
【问题描述】:

如果两个对象在语义上不同,如何连接它们?

1.Tire 195 / 75R16C Cordiant Business CA 107 / 105R all-season
2.195/75 R16C lid CORDIANT Business CA

但这是同一个产品,因为匹配它的文章195/75 R16С

还有一个例子

1.185/75 R16C lid Forward Professional 156 ASHK tubeless
2.The tire `185/75 R16С` С-156

185/75 R16C

关于这个话题的新问题 R:Error in compare.linkage : Data sets have different format

【问题讨论】:

  • 我想我可以提供帮助,但在上面的示例中,我不清楚一个对象从哪里开始,另一个对象从哪里开始。
  • @BradCannell。我编辑了帖子并指出了对象的数量
  • @missuse,是的,但我无法提供组合,它有很多组合 '(1.)6,50-16 y-387-1 (2.)9.00-20 ВЛ-45等等有很多对象的
  • 你能提供任何解决方案吗,因为我的数据集不是英文的

标签: r fuzzy-search


【解决方案1】:

所以这里有一个使用RecordLinkage package 的解决方案。我认为这可以满足您的要求。

示例数据:

library(tidyverse)
library(RecordLinkage)

df_01 <- tibble(
  product = c("Tire 195 / 75R16C Cordiant Business CA 107 / 105R all-season",
              "Something else")
)
df_02 <- tibble(
  product = c("195/75 R16C lid CORDIANT Business CA", 
              "Different Product")
)

下一部分的细节最好留给 RecordLinkage 文档:

rpairs_jar <- compare.linkage(df_01, df_02,
                              strcmp = c("product"),
                              strcmpfun = jarowinkler)

rpairs_epiwt <- epiWeights(rpairs_jar)

getPairs(rpairs_epiwt, max.weight = Inf, min.weight = -Inf)

   id                                                      product    Weight
1   1 Tire 195 / 75R16C Cordiant Business CA 107 / 105R all-season          
2   1                         195/75 R16C lid CORDIANT Business CA 0.6135377
3                                                                           
4   2                                               Something else          
5   2                                            Different Product 0.4827264
6                                                                           
7   1 Tire 195 / 75R16C Cordiant Business CA 107 / 105R all-season          
8   2                                            Different Product 0.4586156
9                                                                           
10  2                                               Something else          
11  1                         195/75 R16C lid CORDIANT Business CA 0.4320106

因此,这导致两行匹配的概率。如您所见,您要匹配的行返回最高权重。

【讨论】:

  • 布拉德,很好。
  • @D.Joe 我很高兴这对你有用。您介意点击复选标记接受答案吗?
  • 完成了)最后一个请求,我要加入两个表,这些权重是否可以创建一个列,表明它的权重很好匹配。例如加入后我们必须有字段 id, х1,x2,x3.. ,weight, match (0- bad much, 1 middle match, 3 good match
  • 我不确定我是否理解正确。如果要加入具有共同 id 的表,为什么需要模糊匹配?
  • 这不是普通的id)) 语义不同,但是文章是普通的,我必须加入才能获得价格列。一个表的 id 包含对象和文章,第二个表的 id 具有相同的文章,但不同的语义和价格列))
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多