我需要使用开源软件 mahout 开展一个项目。一个示例程序如下。
import org.apache.mahout.cf.taste.common.Refreshable;
import org.apache.mahout.cf.taste.impl.common.FastIDSet;
import org.apache.mahout.cf.taste.similarity.ItemSimilarity;
public class GenderItemSimilarity implements ItemSimilarity {
private final FastIDSet men;
private final FastIDSet women;
public GenderItemSimilarity(FastIDSet men, FastIDSet women) {
this.men = men;
this.women = women;
}
public double itemSimilarity(long profileID1, long profileID2) {
Boolean profile1IsMan = isMan(profileID1);
if (profile1IsMan == null) {
return 0.0;
}
Boolean profile2IsMan = isMan(profileID2);
if (profile2IsMan == null) {
return 0.0;
}
return profile1IsMan == profile2IsMan ? 1.0 : -1.0;
}
public double[] itemSimilarities(long itemID1, long[] itemID2s) {
double[] result = new double[itemID2s.length];
for (int i = 0; i < itemID2s.length; i++) {
result[i] = itemSimilarity(itemID1, itemID2s[i]);
}
return result;
}
private Boolean isMan(long profileID) {
if (men.contains(profileID)) {
return Boolean.TRUE;
}
if (women.contains(profileID)) {
return Boolean.FALSE;
}
return null;
}
public void refresh(Collection<Refreshable> alreadyRefreshed) {
// do nothing
}
}
eclipse 编译器给出错误信息,例如
GenderItemSimilarity 类型必须实现继承的抽象方法 ItemSimilarity.allSimilarItemIDs(long)
在我看来,这个错误消息表明存在一个类 ItemSimilarity,它有一个 allSimilarItemIDs(long) 的方法。但是,目前的程序没有这种方法。我的分析正确吗?添加这种方法会解决问题吗?