aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/semantics/test/EllipsisTestCase.java
blob: 1c570220f52b82dc976b3f4f74d4205166b5a108 (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
// 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.Test;

/**
 * tersts the ellipsis rule base
 *
 * @author bratseth
 */
public class EllipsisTestCase extends RuleBaseAbstractTestCase {

    public EllipsisTestCase() {
        super("ellipsis.sr");
    }

    @Test
    public void testUnreferencedEllipsis() {
        assertSemantics("AND why is stench unpleasant about:stench","why is stench unpleasant");
        assertSemantics("AND why is the sky blue about:\"the sky\"","why is the sky blue");
        assertSemantics("AND why is aardwark almost always most relevant in dictionaries about:aardwark",
                        "why is aardwark almost always most relevant in dictionaries");
    }

    @Test
    public void testReferencedEllipsis() {
        assertSemantics("album:parade","parade album");
        assertSemantics("album:\"a sun came\"","a sun came album");
        assertSemantics("album:parade","parade cd");
        assertSemantics("album:\"a sun came\"","a sun came cd");
    }

    @Test
    public void testEllipsisInNamedCondition() {
        assertSemantics("AND name:\"a sun came\" product:video","buy a sun came");
        assertSemantics("AND name:stalker product:video","buy stalker video");
        assertSemantics("AND name:\"the usual suspects\" product:video","buy the usual suspects video");
    }

    @Test
    public void testMultipleEllipsis() {
        assertSemantics("AND from:paris to:texas","from paris to texas");
        assertSemantics("AND from:\"sao paulo\" to:\"real madrid\"","from sao paulo to real madrid");
        assertSemantics("AND from:\"from from\" to:oslo","from from from to oslo");
        assertSemantics("AND from:\"from from to\" to:koko","from from from to to koko"); // Matching is greedy left-right
    }

}