我想知道是否有一種快速方法來查找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 - 不,它不。從一開始,這些信息本來是很好的。我會做一個編輯,但我們需要知道:你究竟在比較什麼?關鍵字和標題?還請在問題中顯示您更新的數據框中所需的結果 –