• 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

45.45
/src/main/java/ch/jalu/wordeval/dictionary/DictionaryService.java
1
package ch.jalu.wordeval.dictionary;
2

3
import ch.jalu.wordeval.DataUtils;
4
import ch.jalu.wordeval.dictionary.sanitizer.Sanitizer;
5
import ch.jalu.wordeval.language.Language;
6
import org.apache.commons.lang3.StringUtils;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.stereotype.Service;
9

10
import java.util.ArrayList;
11
import java.util.List;
12

13
/**
14
 * Service for processing dictionaries.
15
 */
16
@Service
17
public class DictionaryService {
18

19
  @Autowired
20
  private DataUtils dataUtils;
21

22
  DictionaryService() {
2✔
23
  }
1✔
24

25
  /**
26
   * Reads all words from the dictionary's file and sanitizes them.
27
   *
28
   * @param dictionary the dictionary to load
29
   * @return all words of the dictionary
30
   */
31
  public List<Word> readAllWords(Dictionary dictionary) {
NEW
32
    return processAllWords(dictionary, dataUtils.readAllLines(dictionary.getFile()));
×
33
  }
34

35
  public List<Word> processAllWords(Dictionary dictionary, List<String> lines) {
36
    final Sanitizer sanitizer = dictionary.buildSanitizer();
3✔
37
    final Language language = dictionary.getLanguage();
3✔
38
    final WordFactory wordFactory = new WordFactory(language);
5✔
39

40
    return lines.stream()
5✔
41
        .map(sanitizer::isolateWord)
5✔
42
        .filter(StringUtils::isNotEmpty)
3✔
43
        .map(wordFactory::createWordObject)
4✔
44
        .toList();
1✔
45
  }
46

47
  public WordEntries processWordsForDebug(Dictionary dictionary) {
48
    final Sanitizer sanitizer = dictionary.buildSanitizer();
×
49
    List<String> skippedLines = new ArrayList<>();
×
50
    List<String> includedLines = new ArrayList<>();
×
51

NEW
52
    dataUtils.readAllLines(dictionary.getFile()).forEach(line -> {
×
53
      String isolatedWord = sanitizer.isolateWord(line);
×
54
      if (StringUtils.isEmpty(isolatedWord)) {
×
55
        skippedLines.add(line);
×
56
      } else {
57
        includedLines.add(isolatedWord + " -> " + line);
×
58
      }
59
    });
×
60

61
    return new WordEntries(skippedLines, includedLines);
×
62
  }
63

64
  public record WordEntries(List<String> skippedLines, List<String> includedLines) {
×
65
  }
66
}
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