• 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

53.85
/src/main/java/ch/jalu/wordeval/dictionary/hunspell/HunspellDictionaryService.java
1
package ch.jalu.wordeval.dictionary.hunspell;
2

3
import ch.jalu.wordeval.DataUtils;
4
import ch.jalu.wordeval.dictionary.HunspellDictionary;
5
import ch.jalu.wordeval.dictionary.hunspell.lineprocessor.HunspellLineProcessor;
6
import ch.jalu.wordeval.dictionary.hunspell.parser.AffixesParser;
7
import ch.jalu.wordeval.dictionary.hunspell.parser.ParsedAffixes;
8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.stereotype.Service;
10

11
import java.util.stream.Stream;
12

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

19
  @Autowired
20
  private AffixesParser affixesParser;
21

22
  @Autowired
23
  private ParserToModelConverter parserToModelConverter;
24

25
  @Autowired
26
  private HunspellUnmuncherService unmuncherService;
27

28
  @Autowired
29
  private DataUtils dataUtils;
30

31
  HunspellDictionaryService() {
2✔
32
  }
1✔
33

34
  /**
35
   * Returns a stream with all words defined by the given dictionary.
36
   *
37
   * @param lines the lines of the dictionary to read from
38
   * @param dictionary the dictionary the lines belong to
39
   * @return all parsed and unmunched words
40
   */
41
  public Stream<String> loadAllWords(Stream<String> lines, HunspellDictionary dictionary) {
42
    HunspellLineProcessor lineProcessor = dictionary.getLineProcessor();
×
NEW
43
    HunspellAffixes affixDefinition = loadAndParseAffixes(dictionary);
×
NEW
44
    return loadAllWords(lines, lineProcessor, affixDefinition);
×
45
  }
46

47
  /**
48
   * Returns a stream with all words processed by the given lines.
49
   *
50
   * @param lines the lines of the dictionary to read from
51
   * @param lineProcessor line processor for splitting/handling lines
52
   * @param affixDefinition definition of the Hunspell dictionary's affixes
53
   * @return all parsed and unmunched words
54
   */
55
  public Stream<String> loadAllWords(Stream<String> lines, HunspellLineProcessor lineProcessor,
56
                                     HunspellAffixes affixDefinition) {
57
    return lines
4✔
58
        .map(lineProcessor::split)
5✔
59
        .filter(baseWord -> !baseWord.isEmpty())
11✔
60
        .flatMap(baseWord -> unmuncherService.unmunch(baseWord, affixDefinition))
9✔
61
        .map(lineProcessor::transform);
4✔
62
  }
63

64
  /**
65
   * Loads all affix rules defined by the given dictionary.
66
   *
67
   * @param dictionary the dictionary to process
68
   * @return the dictionary's affix rules
69
   */
70
  public HunspellAffixes loadAndParseAffixes(HunspellDictionary dictionary) {
71
    ParsedAffixes parsedAffixes;
72
    try (Stream<String> affixLines = dataUtils.lines(dictionary.getAffixFile())) {
×
73
      parsedAffixes = affixesParser.parseAffFile(affixLines);
×
74
    }
75
    return parserToModelConverter.convert(parsedAffixes);
×
76
  }
77
}
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