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

ljacqu / wordeval / 14575565697

21 Apr 2025 02:51PM UTC coverage: 59.907% (+1.9%) from 58.038%
14575565697

push

github

ljacqu
Create service to unmunch Hunspell dictionaries (work in progress)

330 of 635 branches covered (51.97%)

70 of 72 new or added lines in 5 files covered. (97.22%)

904 of 1509 relevant lines covered (59.91%)

3.4 hits per line

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

95.0
/src/main/java/ch/jalu/wordeval/dictionary/hunspell/AffixFlagType.java
1
package ch.jalu.wordeval.dictionary.hunspell;
2

3
import java.util.ArrayList;
4
import java.util.Arrays;
5
import java.util.List;
6

7
public enum AffixFlagType {
3✔
8

9
  /** Affix rules have a single character as flag name. */
10
  SINGLE,
6✔
11

12
  /** 2-character flag names are used, e.g. foo/Y1Z3F? -> affixes Y1, Z3, F?. */
13
  LONG,
6✔
14

15
  /** Numbers are used as flag names and are separated by commas. */
16
  NUMBER;
6✔
17

18
  /**
19
   * Returns the affix flag type that corresponds to the flag name. Throws an exception
20
   * if the value is unknown.
21
   *
22
   * @param str the name of the flag as defined in an .aff file
23
   * @return the corresponding flag type
24
   */
25
  public static AffixFlagType fromAffixFileString(String str) {
26
    return switch (str) {
9✔
27
      case "long" -> LONG;
2✔
28
      case "num" -> NUMBER;
2✔
29
      default -> throw new IllegalArgumentException("Unknown affix flag type: " + str);
6✔
30
    };
31
  }
32

33
  /**
34
   * Takes a string of specified affixes (from a .dic file) and splits it into individual flags.
35
   *
36
   * @param affixList the string list to split
37
   * @return the affix flags from the list
38
   */
39
  public List<String> split(String affixList) {
40
    if (this == SINGLE) {
3✔
41
      return affixList.chars()
4✔
42
          .mapToObj(i -> String.valueOf((char) i))
5✔
43
          .toList();
1✔
44
    } else if (this == LONG) {
3✔
45
      List<String> affixes = new ArrayList<>(affixList.length() / 2);
8✔
46
      for (int i = 0; i < affixList.length(); i += 2) {
8✔
47
        affixes.add(affixList.substring(i, i + 2));
9✔
48
      }
49
      return affixes;
2✔
50
    } else if (this == NUMBER) {
3!
51
      return Arrays.asList(affixList.split(","));
5✔
52
    } else {
NEW
53
      throw new IllegalStateException("Unsupported affix type: " + this);
×
54
    }
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

© 2026 Coveralls, Inc