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

ljacqu / wordeval / 14890732001

07 May 2025 06:33PM UTC coverage: 60.614% (-0.8%) from 61.437%
14890732001

push

github

ljacqu
Fix line processor tests not to depend on the dictionary files

392 of 702 branches covered (55.84%)

0 of 2 new or added lines in 1 file covered. (0.0%)

26 existing lines in 5 files now uncovered.

968 of 1597 relevant lines covered (60.61%)

3.41 hits per line

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

97.37
/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.HunspellDictionary;
5
import ch.jalu.wordeval.dictionary.hunspell.lineprocessor.FrLineProcessor;
6
import ch.jalu.wordeval.dictionary.hunspell.lineprocessor.HuLineProcessor;
7
import ch.jalu.wordeval.dictionary.hunspell.lineprocessor.ItLineProcessor;
8
import ch.jalu.wordeval.language.Language;
9

10
import java.util.stream.Stream;
11

12
/**
13
 * Stores all {@link Dictionary} objects.
14
 *
15
 * @see AppData
16
 */
17
final class DictionaryData {
18

19
  private static final String DICT_PATH = "dict/";
20

21
  public static final Dictionary AF = hunspellDictionary("af").lineProcessor(".", "µ", "Ð", "ø").build();
23✔
22
  public static final Dictionary BG = hunspellDictionary("bg").build();
4✔
23
  public static final Dictionary DA = hunspellDictionary("da").build();
4✔
24
  public static final Dictionary DE_DE = hunspellDictionary("de-de").lineProcessor("#", "°").build();
15✔
25
  public static final Dictionary EN_US = hunspellDictionary("en-us").build();
4✔
26
  public static final Dictionary EN_TEST = hunspellDictionary("en-test").build();
4✔
27
  // TODO #62: Some Basque entries have _ but most parts seem to be present alone
28
  public static final Dictionary ES = hunspellDictionary("es").build();
4✔
29
  public static final Dictionary EU = hunspellDictionary("eu").lineProcessor(".", "+", "_").build();
19✔
30
  public static final Dictionary FR = hunspellDictionary("fr").lineProcessor(new FrLineProcessor()).build();
8✔
31
  public static final Dictionary HU = hunspellDictionary("hu").lineProcessor(new HuLineProcessor()).build();
8✔
32
  public static final Dictionary IT = hunspellDictionary("it").lineProcessor(new ItLineProcessor()).build();
8✔
33
  public static final Dictionary NB = hunspellDictionary("nb").build();
4✔
34
  // TODO: The nl dictionary uses the digraph symbol 'ij' instead of 'i'+'j'
35
  public static final Dictionary NL = hunspellDictionary("nl").build();
4✔
36
  public static final Dictionary NN = hunspellDictionary("nn").build();
4✔
37
  public static final Dictionary PL = hunspellDictionary("pl").build();
4✔
38
  public static final Dictionary PT_BR = hunspellDictionary("pt-br").build();
4✔
39
  public static final Dictionary PT_PT = hunspellDictionary("pt-pt").build();
4✔
40
  public static final Dictionary RU = hunspellDictionary("ru").lineProcessor(".").build();
11✔
41
  public static final Dictionary SR_CYRL = hunspellDictionary("sr-cyrl").build();
4✔
42
  public static final Dictionary SR_LATN = hunspellDictionary("sr-latn").build();
4✔
43
  public static final Dictionary TR = hunspellDictionary("tr").build();
5✔
44

45
  private DictionaryData() {
46
  }
47

48
  public static Dictionary getOrThrow(String code) {
49
    Dictionary dictionary = getOrNull(code);
3✔
50
    if (dictionary == null) {
2✔
51
      throw new IllegalStateException("Unknown dictionary code: " + code);
6✔
52
    }
53
    return dictionary;
2✔
54
  }
55

56
  public static Dictionary getOrNull(String code) {
57
    return streamThroughAll()
4✔
58
        .filter(dict -> code.equals(dict.getIdentifier()))
6✔
59
        .findFirst().orElse(null);
4✔
60
  }
61

62
  public static Stream<Dictionary> streamThroughAll() {
63
    return Stream.of(AF, BG, DA, DE_DE, EN_US, EN_TEST, ES, EU, FR, HU, IT,
88✔
64
        NB, NL, NN, PL, PT_BR, PT_PT, RU, SR_CYRL, SR_LATN, TR);
65
  }
66

67
  private static HunspellDictionary.Builder hunspellDictionary(String identifier) {
68
    return HunspellDictionary.newHunspellDictionary(identifier)
5✔
69
        .file(DICT_PATH + identifier + ".dic")
2✔
70
        .language(getLanguage(identifier));
2✔
71
  }
72

73
  private static Language getLanguage(String identifier) {
74
    Language language = LanguageData.getOrNull(identifier);
3✔
75
    if (language == null) {
2✔
76
      if (identifier.indexOf('-') != -1) {
5!
77
        return getLanguage(identifier.substring(0, identifier.indexOf('-')));
8✔
78
      }
UNCOV
79
      throw new IllegalStateException("No language stored for code '" + identifier + "'");
×
80
    }
81
    return LanguageData.getOrThrow(identifier);
3✔
82
  }
83
}
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

© 2026 Coveralls, Inc