private List<ParseResult> removeRepeats(List<ParseResult> all) { System.out.println("----------------------- all.size equals to --------------" + all.size()); List<ParseResult> bestList = new LinkedList<ParseResult>(); for (int i = 0; i < all.size(); i++) { ParseResult e_i = all.get(i); boolean best = true; for (int j = i + 1; j < all.size(); j++) { ParseResult e_j = all.get(j); if (e_i.getExp().equals(e_j.getExp()) && e_i.getScore() <= e_j.getScore()) { best = false; break; } } if (best) bestList.add(e_i); } return bestList; }
public boolean hasExp(Exp sem) { for (ParseResult p : allParses) { if (p.getExp().equals(sem)) { return true; } } return false; }
private List<ParseResult> findBestParses(List<ParseResult> all, Exp e) { List<ParseResult> best = new LinkedList<ParseResult>(); double bestScore = -Double.MAX_VALUE; for (ParseResult p : all) { if (p.getExp().inferType() != null) { if ((e == null || p.getExp().equals(e))) { if (p.getScore() == bestScore) best.add(p); if (p.getScore() > bestScore) { bestScore = p.getScore(); best.clear(); best.add(p); } } } } return best; }