我正在開發一個文件系統,每次創建一個新文件系統時,它都必須檢測並丟棄包含大約500,000條記錄的數據庫中的重複項。現在,我使用搜索引擎來檢索20個最相似的文檔,並將它們與我們嘗試創建的新文檔進行比較。問題是我必須檢查新文檔是否類似(使用similar_text很容易),或者即使它包含在其他文本中,所有這些操作都考慮到文本可能已被用戶部分更改(這裏是問題)。我該怎麼做?如何檢查文本是否包含在另一個文件中?
例如:
<?php
$new = "the wild lion";
$candidates = array(
'the dangerous lion lives in Africa',//$new is contained into this one, but has changed 'wild' to 'dangerous', it has to be detected as duplicate
'rhinoceros are native to Africa and three to southern Asia.'
);
foreach ($candidates as $candidate) {
if($candidate is similar or $new is contained in it) {
//Duplicated!!
}
}
當然,在我的系統文件都超過3個字:)
我的問題是沒有找到類似的文件(我已經在使用索引來查找它們),這是檢查文本包含到另一個。這些算法只工作一個文本比較到另一個,但沒有找到什麼文字部分是最相似的其他文字。 –