aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/semantics/test/StemmingTestCase.java
blob: c5277bf6ef6f2c8bc6939d21b2e31f929608132d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;

import org.junit.jupiter.api.Test;

/**
 * Tests stemming.
 *
 * @author bratseth
 */
public class StemmingTestCase {

    @Test
    void testRewritingDueToStemmingInQuery() {
        var tester = new RuleBaseTester("stemming.sr");
        tester.assertSemantics("+(AND i:vehicle TRUE) -i:s", "i:cars -i:s");
    }

    @Test
    void testNoRewritingDueToStemmingInQueryWhenStemmingDisabled() {
        var tester = new RuleBaseTester("stemming-none.sr");
        tester.assertSemantics("+i:cars -i:s", "i:cars -i:s");
    }

    @Test
    void testRewritingDueToStemmingInRule() {
        var tester = new RuleBaseTester("stemming.sr");
        tester.assertSemantics("+(AND i:animal TRUE) -i:s", "i:horse -i:s");
    }

    @Test
    void testNoRewritingDueToStemmingInRuleWhenStemmingDisabled() {
        var tester = new RuleBaseTester("stemming-none.sr");
        tester.assertSemantics("+i:horse -i:s", "i:horse -i:s");
    }

    @Test
    void testRewritingDueToExactMatch() {
        var tester = new RuleBaseTester("stemming.sr");
        tester.assertSemantics("+(AND i:arts i:sciences TRUE) -i:s", "i:as -i:s");
    }

    @Test
    void testEnglishStemming() {
        var tester = new RuleBaseTester("stemming.sr");
        tester.assertSemantics("i:drive", "i:going");
    }

    @Test
    void testFrenchStemming() {
        var tester = new RuleBaseTester("stemming-french.sr");
        tester.assertSemantics("i:going", "i:going");
    }

}