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

ljacqu / wordeval / 14626813804

23 Apr 2025 07:48PM UTC coverage: 60.853% (+0.7%) from 60.152%
14626813804

push

github

ljacqu
Flatten affix rules in model, consider crossproduct, check strip when applying rule

357 of 672 branches covered (53.13%)

38 of 40 new or added lines in 4 files covered. (95.0%)

956 of 1571 relevant lines covered (60.85%)

3.41 hits per line

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

94.74
/src/main/java/ch/jalu/wordeval/dictionary/hunspell/AffixRule.java
1
package ch.jalu.wordeval.dictionary.hunspell;
2

3
import ch.jalu.wordeval.dictionary.hunspell.condition.AffixCondition;
4
import lombok.Getter;
5
import lombok.RequiredArgsConstructor;
6
import org.apache.commons.lang3.StringUtils;
7

8
import java.util.List;
9

10
@Getter
11
@RequiredArgsConstructor
12
public abstract class AffixRule {
13

14
  protected final String strip;
15
  protected final String affix;
16
  private final List<String> continuationClasses;
17
  private final AffixCondition condition;
18
  private final boolean crossProduct;
19

20
  public abstract String applyRule(String word);
21

22
  public abstract AffixType getType();
23

24
  public boolean matches(String word) {
25
    return condition.matches(word);
5✔
26
  }
27

28
  public static class SuffixRule extends AffixRule {
29

30
    public SuffixRule(String strip, String suffix, List<String> continuationClasses,
31
                      AffixCondition condition, boolean crossProduct) {
32
      super(strip, suffix, continuationClasses, condition, crossProduct);
7✔
33
    }
1✔
34

35
    @Override
36
    public String applyRule(String word) {
37
      if (strip.isEmpty()) {
4✔
38
        return word + affix;
5✔
39
      }
40

41
      String strippedWord = StringUtils.removeEnd(word, strip);
5✔
42
      if (strippedWord.equals(word)) {
4✔
43
        return null;
2✔
44
      }
45
      return strippedWord + affix;
5✔
46
    }
47

48
    @Override
49
    public AffixType getType() {
50
      return AffixType.SFX;
2✔
51
    }
52
  }
53

54
  public static class PrefixRule extends AffixRule {
55

56
    public PrefixRule(String strip, String prefix, List<String> continuationClasses,
57
                      AffixCondition condition, boolean crossProduct) {
58
      super(strip, prefix, continuationClasses, condition, crossProduct);
7✔
59
    }
1✔
60

61
    @Override
62
    public String applyRule(String word) {
63
      if (strip.isEmpty()) {
4✔
64
        return affix + word;
5✔
65
      }
66

67
      String strippedWord = StringUtils.removeStart(word, strip);
5✔
68
      if (strippedWord.equals(word)) {
4!
NEW
69
        return null;
×
70
      }
71
      return affix + strippedWord;
5✔
72
    }
73

74
    @Override
75
    public AffixType getType() {
76
      return AffixType.PFX;
2✔
77
    }
78
  }
79
}
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