clues = {
let remaining = [];
for (let i = 0; i < nearest.length; i++)
if (!chosen.includes(i)) remaining = remaining.concat(nearest[i]);
const scored = new Map();
for (const { word, distance } of remaining) {
if (!scored.has(word))
scored.set(word, { distance, count: distance > 0 ? 1 : 0 });
else
scored.set(word, {
distance: scored.get(word).distance + distance,
count: scored.get(word).count + (distance > 0 ? 1 : 0)
});
}
return d3.sort(scored.entries(), (a, b) => b[1].distance - a[1].distance);
}