我想知道是否有一种快速方法来查找2个文本字符串之间的定向交集,例如R文本挖掘 - 文本字段之间的交集
t1 <- "I have achieved my goals over the past 20 years and look forward for my next chalanges"
t2 <- " have achieved goals and look my chalanges some other words bla bla"
t1 isContainedIn t2将返回7,因为在t1中显示的7个单词也在t2中显示。 此外,t1和t2是数据框中的2列,所以我需要将该函数应用于整个数据框,并将结果列附加到我的原始数据框中。 这是“data.selected”我的数据框架的样子:
keywords title
1 Samsung UN48H6350 48" Samsung UN48H6350 48" Full 1080p Smart HDTV 120Hz with Wi-Fi +$50 Visa Gift Card
2 Samsung UN48H6350 48" Samsung UN48H6350 48" Full HD Smart LED TV -Bundle- (See Below for Contents)
3 Samsung UN48H6350 48" Samsung UN48H6350 48" Class Full HD Smart LED TV -BUNDLE- See below Details
4 Samsung UN48H6350 48" Samsung UN48H6350 48" Full HD Smart LED TV With BD-H5100 Blu-ray Disc Player
5 Samsung UN48H6350 48" Samsung UN48H6350 48" Smart 1080p Clear Motion Rate 240 LED HDTV
6 Samsung UN48H6350 48" Samsung UN48H6350 - 48-Inch Full HD 1080p Smart HDTV 120Hz with Wi-Fi
7 Samsung UN48H6350 48" Samsung 6350 Series UN48H6350 48" 1080p HD LED LCD Internet TV NEW
8 Samsung UN48H6350 48" Samsung Un48h6350af 75" 1080p Led-lcd Tv - 16:9 - Hdtv 1080p - (un75h6350afxza)
9 Samsung UN48H6350 48" Samsung UN48H6350 - 48" HD 1080p Smart HDTV 120Hz Bundle
10 Samsung UN48H6350 48" Samsung UN48H6350 - 48-Inch Full HD 1080p Smart HDTV 120Hz with Wi-Fi, (R#416)
你是对的 - 交集不正确的术语。我的意思是要找出t2中包含多少t1:t1中出现多少个项,出现在t2中(反之亦然 - 方向很重要) – user3628777
另外 - t1和t2是数据帧 - 我不确定此解决方案是否支持作为R当前返回字符(0)当我运行它在我的数据 – user3628777
@ user3628777 - 不,它不。从一开始,这些信息本来是很好的。我会做一个编辑,但我们需要知道:你究竟在比较什么?关键字和标题?还请在问题中显示您更新的数据框中所需的结果 –