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

ljacqu / wordeval / 14558242496

20 Apr 2025 09:39AM UTC coverage: 53.745%. First build
14558242496

push

github

ljacqu
Change WordEvalMain to SpringBootApp, convert dict & lang data to constants

286 of 596 branches covered (47.99%)

124 of 134 new or added lines in 4 files covered. (92.54%)

739 of 1375 relevant lines covered (53.75%)

3.04 hits per line

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

95.74
/src/main/java/ch/jalu/wordeval/appdata/DictionaryData.java
1
package ch.jalu.wordeval.appdata;
2

3
import ch.jalu.wordeval.dictionary.Dictionary;
4
import ch.jalu.wordeval.dictionary.sanitizer.FrSanitizer;
5
import ch.jalu.wordeval.dictionary.sanitizer.HuSanitizer;
6
import ch.jalu.wordeval.dictionary.sanitizer.ItSanitizer;
7
import ch.jalu.wordeval.language.Language;
8

9
import java.util.stream.Stream;
10

11
/**
12
 * Stores all {@link Dictionary} objects.
13
 */
14
final class DictionaryData {
15

16
  private static final String DICT_PATH = "dict/";
17

18
  public static final Dictionary AF = newDictionary("af").delimiters('/').skipSequences(".", "µ", "Ð", "ø").build();
30✔
19
  public static final Dictionary BG = newDictionary("bg").delimiters('/').build();
11✔
20
  public static final Dictionary DA = newDictionary("da").delimiters('/').build();
11✔
21
  public static final Dictionary DE_DE = newDictionary("de-de").delimiters('/', '#').skipSequences("°").build();
22✔
22
  public static final Dictionary EN_US = newDictionary("en-us").delimiters('/').build();
11✔
23
  public static final Dictionary EN_TEST = newDictionary("en-test").delimiters('/').build();
11✔
24
  // TODO #62: Some Basque entries have _ but most parts seem to be present alone
25
  public static final Dictionary ES = newDictionary("es").delimiters('/').build();
11✔
26
  public static final Dictionary EU = newDictionary("eu").delimiters('/').skipSequences(".", "+", "_").build();
26✔
27
  public static final Dictionary FR = newDictionary("fr").sanitizerCreator(FrSanitizer::new)
14✔
28
      .delimiters('/', '\t')
75✔
29
      .skipSequences(".", "&", "µ", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉", "ᵈ", "ᵉ", "ᵍ", "ˡ", "ᵐ", "ʳ", "ˢ")
1✔
30
      .build();
2✔
31
  public static final Dictionary HU = newDictionary("hu").sanitizerCreator(HuSanitizer::new)
14✔
32
      .delimiters('/', '\t')
31✔
33
      .skipSequences(".", "+", "±", "ø", "ʻ", "’", "­")
1✔
34
      .build();
2✔
35
  public static final Dictionary IT = newDictionary("it").sanitizerCreator(ItSanitizer::new)
10✔
36
      .delimiters('/')
1✔
37
      .build();
2✔
38
  public static final Dictionary NB = newDictionary("nb").delimiters('/').build();
11✔
39
  // TODO: The nl dictionary uses the digraph symbol 'ij' instead of 'i'+'j'
40
  public static final Dictionary NL = newDictionary("nl").delimiters('/').build();
11✔
41
  public static final Dictionary NN = newDictionary("nn").delimiters('/').build();
11✔
42
  public static final Dictionary PL = newDictionary("pl").delimiters('/').build();
11✔
43
  public static final Dictionary PT_BR = newDictionary("pt-br").delimiters('/').build();
11✔
44
  public static final Dictionary PT_PT = newDictionary("pt-pt").delimiters('/', '[').build();
15✔
45
  public static final Dictionary RU = newDictionary("ru").delimiters('/').skipSequences(".").build();
18✔
46
  public static final Dictionary SR_CYRL = newDictionary("sr-cyrl").build();
4✔
47
  public static final Dictionary SR_LATN = newDictionary("sr-latn").delimiters('/').build();
11✔
48
  public static final Dictionary TR = newDictionary("tr").delimiters(' ').build();
12✔
49

50
  private DictionaryData() {
51
  }
52

53
  public static Dictionary getOrThrow(String code) {
54
    Dictionary dictionary = getOrNull(code);
3✔
55
    if (dictionary == null) {
2!
NEW
56
      throw new IllegalStateException("Unknown dictionary code: " + code);
×
57
    }
58
    return dictionary;
2✔
59
  }
60

61
  public static Dictionary getOrNull(String code) {
62
    return streamThroughAll()
4✔
63
        .filter(dict -> code.equals(dict.getIdentifier()))
6✔
64
        .findFirst().orElse(null);
4✔
65
  }
66

67
  public static Stream<Dictionary> streamThroughAll() {
68
    return Stream.of(AF, BG, DA, DE_DE, EN_US, EN_TEST, ES, EU, FR, HU, IT,
88✔
69
        NB, NL, NN, PL, PT_BR, PT_PT, RU, SR_CYRL, SR_LATN, TR);
70
  }
71

72
  private static Dictionary.Builder newDictionary(String identifier) {
73
    return Dictionary.builder()
3✔
74
        .identifier(identifier)
3✔
75
        .file(DICT_PATH + identifier + ".dic")
2✔
76
        .language(getLanguage(identifier));
2✔
77
  }
78

79
  private static Language getLanguage(String identifier) {
80
    Language language = LanguageData.getOrNull(identifier);
3✔
81
    if (language == null) {
2✔
82
      if (identifier.indexOf('-') != -1) {
5!
83
        return getLanguage(identifier.substring(0, identifier.indexOf('-')));
8✔
84
      }
NEW
85
      throw new IllegalStateException("No language stored for code '" + identifier + "'");
×
86
    }
87
    return LanguageData.getOrThrow(identifier);
3✔
88
  }
89
}
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