@Test public void testRankerReturnsBestMatchingCandidateDueToHigherRankingWords() { Candidate worst = new DefaultCandidate( "not bad", "not bad", ImmutableMap.of( "firstname", "James", "surname", "Major", "abstract", "Prime Minister of no where")); Candidate best = new DefaultCandidate( "best", "best", ImmutableMap.of( "firstname", "John", "surname", "Major", "abstract", "Prime Minister after Thatcher")); Optional<Candidate> topCandidate = ranker.getTopCandidate(entityInformation, ImmutableSet.of(worst, best)); assertTrue(topCandidate.isPresent()); assertEquals(best, topCandidate.get()); }
@Override public Optional<Candidate> getTopCandidate( EntityInformation<T> entityInformation, Collection<Candidate> candidates) { SortedSet<? extends Candidate> ranked = rankedCandidates(candidates, entityInformation); if (ranked.isEmpty()) { return Optional.empty(); } else { return Optional.ofNullable(ranked.last()); } }
BagOfWordsCandidateRanker implements CandidateRanker<T> { @Override public Optional<Candidate> getTopCandidate( EntityInformation<T> entityInformation, Collection<Candidate> candidates) { SortedSet<? extends Candidate> ranked = rankedCandidates(candidates, entityInformation); if (ranked.isEmpty()) { return Optional.empty(); } else { return Optional.ofNullable(ranked.last()); } } }
BagOfWordsCandidateRanker implements CandidateRanker<T> { @Override public Optional<Candidate> getTopCandidate( EntityInformation<T> entityInformation, Collection<Candidate> candidates) { SortedSet<? extends Candidate> ranked = rankedCandidates(candidates, entityInformation); if (ranked.isEmpty()) { return Optional.empty(); } else { return Optional.ofNullable(ranked.last()); } }  }
BagOfWordsCandidateRanker implements CandidateRanker<T> { @Override public Optional<Candidate> getTopCandidate( EntityInformation<T> entityInformation, Collection<Candidate> candidates) { SortedSet<? extends Candidate> ranked = rankedCandidates(candidates, entityInformation); if (ranked.isEmpty()) { return Optional.empty(); } else { return Optional.ofNullable(ranked.last()); } }  @Override void initialize(Collection<String> stopwords); @Override Optional<Candidate> getTopCandidate(
      EntityInformation<T> entityInformation, Collection<Candidate> candidates); }
BagOfWordsCandidateRanker implements CandidateRanker<T> { @Override public Optional<Candidate> getTopCandidate( EntityInformation<T> entityInformation, Collection<Candidate> candidates) { SortedSet<? extends Candidate> ranked = rankedCandidates(candidates, entityInformation); if (ranked.isEmpty()) { return Optional.empty(); } else { return Optional.ofNullable(ranked.last()); } }  @Override void initialize(Collection<String> stopwords); @Override Optional<Candidate> getTopCandidate(
      EntityInformation<T> entityInformation, Collection<Candidate> candidates);  }