• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ljacqu / wordeval / 14540577447

18 Apr 2025 07:23PM UTC coverage: 51.439% (-6.2%) from 57.611%
14540577447

push

github

ljacqu
Remove EvaluationResult type param from all Evaluator interfaces

239 of 546 branches covered (43.77%)

16 of 17 new or added lines in 16 files covered. (94.12%)

193 existing lines in 17 files now uncovered.

679 of 1320 relevant lines covered (51.44%)

3.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.83
/src/main/java/ch/jalu/wordeval/evaluators/impl/FullPalindromes.java
1
package ch.jalu.wordeval.evaluators.impl;
2

3
import ch.jalu.wordeval.dictionary.Word;
4
import ch.jalu.wordeval.evaluators.PostEvaluator;
5
import ch.jalu.wordeval.evaluators.processing.AllWordsEvaluatorProvider;
6
import ch.jalu.wordeval.evaluators.result.WordWithKey;
7
import ch.jalu.wordeval.evaluators.result.WordWithScore;
8
import com.google.common.collect.ArrayListMultimap;
9
import com.google.common.collect.ListMultimap;
10
import lombok.Getter;
11

12
import java.util.ArrayList;
13
import java.util.Comparator;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Set;
17

18
/**
19
 * Evaluator that finds proper palindromes based on the results of the
20
 * {@link Palindromes} evaluator, which also matches parts of a word (e.g.
21
 * "ette" in "better").
22
 */
23
public class FullPalindromes implements PostEvaluator {
2✔
24

25
  @Getter
6✔
26
  private final List<WordWithScore> results = new ArrayList<>();
27

28
  @Override
29
  public void evaluate(AllWordsEvaluatorProvider allWordsEvaluatorProvider) {
30
    List<WordWithKey> palindromeResults =
2✔
31
        allWordsEvaluatorProvider.getEvaluator(Palindromes.class).getResults();
4✔
32

33
    for (WordWithKey entry : palindromeResults) {
10✔
34
      Word word = entry.getWord();
3✔
35
      int wordLength = word.getWithoutAccentsWordCharsOnly().length();
4✔
36
      if (wordLength == entry.getKey().length()) {
5✔
37
        results.add(new WordWithScore(word, wordLength));
10✔
38
      }
39
    }
1✔
40
  }
1✔
41

42
  @Override
43
  public ListMultimap<Object, Object> getTopResults(int topScores, int maxLimit) {
UNCOV
44
    List<WordWithScore> sortedResult = results.stream()
×
45
        .sorted(Comparator.comparing(WordWithScore::getScore).reversed())
×
46
        .toList();
×
47

UNCOV
48
    Set<Double> uniqueValues = new HashSet<>();
×
49
    ListMultimap<Object, Object> filteredResults = ArrayListMultimap.create();
×
50
    for (WordWithScore wordWithScore : sortedResult) {
×
51
      if (uniqueValues.add(wordWithScore.getScore()) && uniqueValues.size() > topScores) {
×
52
        break;
×
53
      }
UNCOV
54
      filteredResults.put((int) wordWithScore.getScore(), wordWithScore.getWord().getRaw());
×
55
      if (filteredResults.size() >= maxLimit) {
×
56
        break;
×
57
      }
UNCOV
58
    }
×
59

UNCOV
60
    return filteredResults;
×
61
  }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc