@Override
public List<ResolvedOrganization> select(List<OrganizationOccurrence> allPossibilities) {
ArrayList<ResolvedOrganization> bestCandidates = new ArrayList<ResolvedOrganization>();
for(OrganizationOccurrence occurrence: allPossibilities){
if (bestCandidates.size() == 0){
bestCandidates.add(new ResolvedOrganization(occurrence));
continue;
}
boolean added = false;
for(ResolvedOrganization alreadyAdded: bestCandidates){
String newDude= occurrence.text.toLowerCase(Locale.US);
String oldDude = alreadyAdded.getName().toLowerCase(Locale.US);
if (newDude.equals(oldDude)){
logger.debug(alreadyAdded.getName() + " is a duplicate of " + occurrence.text);
alreadyAdded.addOccurrence(occurrence);
added = true;
break;
}
}
if (!added){
bestCandidates.add(new ResolvedOrganization(occurrence));
}
}
return bestCandidates;
}