public EnsembleSim call(KnownSim ks) throws DaoException {
List<LocalString> localStrings = Arrays.asList(
new LocalString(ks.language, ks.phrase1),
new LocalString(ks.language, ks.phrase2)
);
List<LocalId> ids = getDisambiguator().disambiguateTop(localStrings, null);
if (ids.isEmpty() || ids.get(0).getId() <= 0) {
return null;
}
int pageId = ids.get(0).getId();
EnsembleSim es = new EnsembleSim(ks);
for (SRMetric metric : metrics) {
double score = Double.NaN;
int rank = -1;
try {
SRResultList dsl = metric.mostSimilar(pageId, getMaxResults(numResults), validIds);
if (dsl != null && dsl.getIndexForId(ids.get(1).getId()) >= 0) {
score = dsl.getScore(dsl.getIndexForId(ids.get(1).getId()));
rank = dsl.getIndexForId(ids.get(1).getId());
}
} catch (Exception e) {
LOG.warn("Local sr metric " + metric.getName() + " failed for " + pageId, e);
} finally {
es.add(score, rank);
}
}
return es;
}
}, 100);