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

ljacqu / wordeval / 14562991048

20 Apr 2025 08:19PM UTC coverage: 55.116% (+1.7%) from 53.367%
14562991048

push

github

ljacqu
Merge remote-tracking branch 'origin/master' into dependencies

269 of 568 branches covered (47.36%)

212 of 313 new or added lines in 36 files covered. (67.73%)

6 existing lines in 5 files now uncovered.

738 of 1339 relevant lines covered (55.12%)

3.27 hits per line

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

31.58
/src/main/java/ch/jalu/wordeval/evaluators/impl/LongWords.java
1
package ch.jalu.wordeval.evaluators.impl;
2

3
import ch.jalu.wordeval.dictionary.Word;
4
import ch.jalu.wordeval.evaluators.WordEvaluator;
5
import ch.jalu.wordeval.evaluators.export.EvaluatorExportUtil;
6
import ch.jalu.wordeval.evaluators.result.WordWithScore;
7
import com.google.common.collect.ListMultimap;
8
import lombok.Getter;
9

10
import java.util.ArrayList;
11
import java.util.Comparator;
12
import java.util.HashSet;
13
import java.util.List;
14
import java.util.Set;
15

16
/**
17
 * Filters the words by length, with the intention to get the longest words of
18
 * the dictionary.
19
 */
20
public class LongWords implements WordEvaluator {
2✔
21

22
  /** Ignore any words whose length is less than the minimum length. */
23
  private static final int MIN_LENGTH = 6;
24

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

28
  @Override
29
  public void evaluate(Word word) {
30
    int length = word.getLowercase().length();
4✔
31
    if (length >= MIN_LENGTH) {
3✔
32
      results.add(new WordWithScore(word, length));
10✔
33
    }
34
  }
1✔
35

36
  @Override
37
  public ListMultimap<Object, Object> getTopResults(int topScores, int maxLimit) {
38
    List<WordWithScore> sortedResult = results.stream()
×
NEW
39
        .sorted(Comparator.comparing(WordWithScore::score).reversed())
×
40
        .toList();
×
41

42
    Set<Double> uniqueValues = new HashSet<>();
×
43
    ListMultimap<Object, Object> filteredResults = EvaluatorExportUtil.newListMultimap();
×
44
    for (WordWithScore wordWithScore : sortedResult) {
×
NEW
45
      if (uniqueValues.add(wordWithScore.score()) && uniqueValues.size() > topScores) {
×
46
        break;
×
47
      }
NEW
48
      filteredResults.put((int) wordWithScore.score(), wordWithScore.word().getRaw());
×
49
      if (filteredResults.size() >= maxLimit) {
×
50
        break;
×
51
      }
52
    }
×
53

54
    return filteredResults;
×
55
  }
56
}
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