【发布时间】:2018-04-08 06:33:21
【问题描述】:
我有一个包含文章标题和相关 url 链接的数据框。
我的问题是对应标题的那一行不需要url链接,例如:
title | urls
Who will be the next president? | https://website/5-ways-to-make-a-cocktail.com
5 ways to make a cocktail | https://website/who-will-be-the-next-president.com
2 millions raised by this startup | https://website/how-did-you-find-your-house.com
How did you find your house | https://website/2-millions-raised-by-this-startup.com
How did you find your house | https://washingtonpost/article/latest-movies-in-theater.com
Latest movies in Theater | www.newspaper/mynews/what-to-cook-in-summer.com
What to cook in summer | https://website/2-millions-raised-by-this-startup.com
我的猜测是我需要考虑如此模糊的匹配逻辑,但我不确定如何。对于重复项,我将只使用unique 函数。
我开始使用 RecordLinkage 包中的 levenshteinSim 函数,该函数为每一行提供相似度分数,但显然由于行不匹配,各处的相似度分数都很低。
我还从stringdist 包中听说了stringdistmatrix 函数,但不知道如何在这里使用它。
【问题讨论】:
-
这种“website/[string].com”结构是否始终存在,或者这只是您的示例?如果是这样,您可以使用简单的正则表达式将其删除并进行完全匹配。
-
嗨,是的,我知道正则表达式,但不,它变化很大,因为有很多不同的网站:/
-
您可能应该让您的示例更具代表性,因为就目前而言,为您提供的示例提供解决方案非常容易。
-
@DavidArenburg 完全同意
-
感谢反馈,我已编辑
标签: r fuzzy-logic stringdist record-linkage