aboutsummaryrefslogtreecommitdiffstats
path: root/model-evaluation/src/test/java/ai/vespa/models/evaluation/RankProfileImportingTest.java
blob: 3fdbb370a5c2717ff703b3da57dcdd67b4eeb08c (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.models.evaluation;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

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

    @Test
    public void testImportingRankExpressions() {
        ModelTester tester = new ModelTester("src/test/resources/config/rankexpression/");

        assertEquals(18, tester.models().size());

        Model macros = tester.models().get("macros");
        assertEquals("macros", macros.name());
        assertEquals(4, macros.functions().size());
        tester.assertFunction("fourtimessum", "4 * (var1 + var2)", macros);
        tester.assertFunction("firstphase", "match + fieldMatch(title) + rankingExpression(myfeature)", macros);
        tester.assertFunction("secondphase", "rankingExpression(fourtimessum@5cf279212355b980.67f1e87166cfef86)", macros);
        tester.assertFunction("myfeature",
                              "70 * fieldMatch(title).completeness * pow(0 - fieldMatch(title).earliness,2) + " +
                              "30 * pow(0 - fieldMatch(description).earliness,2)",
                              macros);
        assertEquals(4, macros.referencedFunctions().size());
        tester.assertBoundFunction("rankingExpression(fourtimessum@5cf279212355b980.67f1e87166cfef86)",
                                   "4 * (match + rankBoost)", macros);
    }

}