aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/semantics/test/SynonymTestCase.java
blob: 65001cfcd44cca02245d6c55c82a8fdff0021a31 (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
// 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;

/**
 * @author bratseth
 */
public class SynonymTestCase {

    @Test
    void testReplacingBySynonyms() {
        var tester = new RuleBaseTester("synonyms.sr");
        tester.assertSemantics("EQUIV index1:foo index1:baz index1:bar", "index1:foo");
        tester.assertSemantics("EQUIV index1:foo index1:baz index1:bar", "index1:bar");
        tester.assertSemantics("EQUIV index1:foo index1:baz index1:bar", "index1:baz");
        tester.assertSemantics("EQUIV index1:word index1:\"a phrase\"", "index1:word");
        tester.assertSemantics("EQUIV index1:word index1:\"a phrase\"", "index1:a index1:phrase");
        tester.assertSemantics("index1:other", "index1:other");
    }

    @Test
    void testAddingSynonyms() {
        var tester = new RuleBaseTester("synonyms.sr");
        tester.assertSemantics("EQUIV index2:foo index2:baz index2:bar", "index2:foo");
        tester.assertSemantics("EQUIV index2:bar index2:foo index2:baz", "index2:bar");
        tester.assertSemantics("EQUIV index2:baz index2:foo index2:bar", "index2:baz");
        tester.assertSemantics("EQUIV index2:word index2:\"a phrase\"", "index2:word");
        tester.assertSemantics("EQUIV index2:\"a phrase\" index2:word", "index2:a index2:phrase");
        tester.assertSemantics("index2:other", "index2:other");
    }

}