if (anchor.getSenses().isEmpty()) {
continue;
}
// what is the most likely sense for the given candidate
Sense bestSense = anchor.getSenses().first();
// add to the context all articles that map
// from ngrams with one possible meaning
// = non-ambiguous meanings
// and high probability of being links in Wikipedia
if (anchor.getSenses().size() == 1
&& anchor.getLinkProbability() > 0.5) {
context.add(bestSense);
continue;
}
// in case if not enough non-ambigious terms were collected
// additionally collect other mappings based on:
// a. likelihood of the sense
double senseProbability = bestSense.getProbability();
// b. keyphraseness
double linkProbability = anchor.getLinkProbability();
if (senseProbability >= 0.9 && linkProbability > 0.5) {
bestSense.setWeight(senseProbability);
bestCandidateSenses.add(bestSense, false);
}
} catch (SQLException e) {
System.err.println("Error computing senses for " + anchor);