我正在研究一些代码来比较接近重复的代码。我有点被比较代码卡住了。到目前为止,这是我的艰难尝试。
//shingles are already hashed integers and I'm working on the evaluation to true via the float similar parameter.
public static boolean compareShingles(float similar, CompareObject comp1, CompareObject comp2) {
int intersections = 0;
if(comp1.getShingle().size()>=comp2.getShingle().size()){
for(int i = 0; i < comp1.getShingle().size(); i++){
if(comp1.getShingle().get(i).equals(comp2.getShingle().get(i))){
intersections++;
}
}
}
else{
for(int i = 0; i < comp2.getShingle().size(); i++){
if(comp2.getShingle().get(i).equals(comp1.getShingle().get(i))){
intersections++;
}
}
}
return true; //not functional still working on when to return true
}如果我应该在一个数组中比较这些瓦1-1,或者我应该把一个瓦与一个循环中的所有瓦进行比较,我就有点拘束了。
例如,如果我把每一块石板和每一块石板进行比较,那么这些文件将是相同的.
{blah blah blah, Once upon a, time blah blah}
{Once upon a, time blah blah, blah blah blah}如果我在同一个文档上做了一个位置比较,那么位置1将是“诸如此类的废话”而不是“曾经的”,那就会返回错误。
我认为循环将是更密集的过程,但这可能是正确的选择。有什么想法?
发布于 2018-08-14 12:32:51
命令无关紧要..。
你基本上制作了板条集,并将它们与Jaccard的相似性进行比较。它有助于有一个散列自动丢弃重复瓦。只需计算每个文档之间的匹配,并计算出需要匹配多少个文档才能认为它们是相似的。
similarity.html
https://stackoverflow.com/questions/51564089
复制相似问题