diff options
6 files changed, 93 insertions, 4 deletions
diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionReference.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionReference.java index 34e34a3341d..666c3a103b5 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionReference.java +++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/FunctionReference.java @@ -25,13 +25,13 @@ import java.util.regex.Pattern; class FunctionReference { private static final Pattern referencePattern = - Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.]+)(@[a-f0-9]+[.a-f0-9]*)?\\)(\\.rankingScript)?"); + Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.$]+)(@[a-f0-9]+[.a-f0-9]*)?\\)(\\.rankingScript)?"); private static final Pattern externalReferencePattern = - Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.]+)(@[a-f0-9]+[.a-f0-9]*)?\\)(\\.expressionName)?"); + Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.$]+)(@[a-f0-9]+[.a-f0-9]*)?\\)(\\.expressionName)?"); private static final Pattern argumentTypePattern = - Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.]+)(@[a-f0-9]+[.a-f0-9]*)?\\)\\.([a-zA-Z0-9_]+)\\.type"); + Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.$]+)(@[a-f0-9]+[.a-f0-9]*)?\\)\\.([a-zA-Z0-9_]+)\\.type"); private static final Pattern returnTypePattern = - Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.]+)(@[a-f0-9]+[.a-f0-9]*)?\\)\\.type"); + Pattern.compile("rankingExpression\\(([a-zA-Z0-9_.$]+)(@[a-f0-9]+[.a-f0-9]*)?\\)\\.type"); /** The name of the function referenced */ private final String name; diff --git a/model-evaluation/src/test/java/ai/vespa/models/evaluation/RankProfileImportingTest.java b/model-evaluation/src/test/java/ai/vespa/models/evaluation/RankProfileImportingTest.java index c5084166c1f..65eb55ae46d 100644 --- a/model-evaluation/src/test/java/ai/vespa/models/evaluation/RankProfileImportingTest.java +++ b/model-evaluation/src/test/java/ai/vespa/models/evaluation/RankProfileImportingTest.java @@ -54,4 +54,10 @@ public class RankProfileImportingTest { ModelTester tester = new ModelTester("src/test/resources/config/expressions-as-arguments/"); assertEquals(3, tester.models().size()); } + + @Test + public void testImportingWithMacros() { + ModelTester tester = new ModelTester("src/test/resources/config/ranking-macros/"); + assertEquals(5, tester.models().size()); + } } diff --git a/model-evaluation/src/test/resources/config/ranking-macros/onnx-models.cfg b/model-evaluation/src/test/resources/config/ranking-macros/onnx-models.cfg new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/model-evaluation/src/test/resources/config/ranking-macros/onnx-models.cfg diff --git a/model-evaluation/src/test/resources/config/ranking-macros/rank-profiles.cfg b/model-evaluation/src/test/resources/config/ranking-macros/rank-profiles.cfg new file mode 100644 index 00000000000..2f1657aebf3 --- /dev/null +++ b/model-evaluation/src/test/resources/config/ranking-macros/rank-profiles.cfg @@ -0,0 +1,83 @@ +rankprofile[0].name "default" +rankprofile[1].name "unranked" +rankprofile[1].fef.property[0].name "vespa.rank.firstphase" +rankprofile[1].fef.property[0].value "value(0)" +rankprofile[1].fef.property[1].name "vespa.hitcollector.heapsize" +rankprofile[1].fef.property[1].value "0" +rankprofile[1].fef.property[2].name "vespa.hitcollector.arraysize" +rankprofile[1].fef.property[2].value "0" +rankprofile[1].fef.property[3].name "vespa.dump.ignoredefaultfeatures" +rankprofile[1].fef.property[3].value "true" +rankprofile[2].name "standalone" +rankprofile[2].fef.property[0].name "rankingExpression(myfeature).rankingScript" +rankprofile[2].fef.property[0].value "7 * attribute(num)" +rankprofile[2].fef.property[1].name "rankingExpression(fourtimessum@2b1138e8965e7ff5.67f1e87166cfef86).rankingScript" +rankprofile[2].fef.property[1].value "4 * (match + match)" +rankprofile[2].fef.property[2].name "rankingExpression(macro_with_dollar$).rankingScript" +rankprofile[2].fef.property[2].value "69" +rankprofile[2].fef.property[3].name "rankingExpression(anotherfeature).rankingScript" +rankprofile[2].fef.property[3].value "10 * rankingExpression(myfeature)" +rankprofile[2].fef.property[4].name "rankingExpression(yetanotherfeature).rankingScript" +rankprofile[2].fef.property[4].value "100 * rankingExpression(myfeature)" +rankprofile[2].fef.property[5].name "rankingExpression(fourtimessum).rankingScript" +rankprofile[2].fef.property[5].value "4 * (var1 + var2)" +rankprofile[2].fef.property[6].name "vespa.rank.firstphase" +rankprofile[2].fef.property[6].value "rankingExpression(firstphase)" +rankprofile[2].fef.property[7].name "rankingExpression(firstphase).rankingScript" +rankprofile[2].fef.property[7].value "match + fieldMatch(title) + rankingExpression(myfeature)" +rankprofile[2].fef.property[8].name "vespa.rank.secondphase" +rankprofile[2].fef.property[8].value "rankingExpression(secondphase)" +rankprofile[2].fef.property[9].name "rankingExpression(secondphase).rankingScript" +rankprofile[2].fef.property[9].value "rankingExpression(fourtimessum@2b1138e8965e7ff5.67f1e87166cfef86) + 0 * rankingExpression(macro_with_dollar$)" +rankprofile[2].fef.property[10].name "vespa.summary.feature" +rankprofile[2].fef.property[10].value "firstPhase" +rankprofile[2].fef.property[11].name "vespa.summary.feature" +rankprofile[2].fef.property[11].value "rankingExpression(myfeature)" +rankprofile[2].fef.property[12].name "vespa.summary.feature" +rankprofile[2].fef.property[12].value "rankingExpression(anotherfeature)" +rankprofile[2].fef.property[13].name "vespa.summary.feature" +rankprofile[2].fef.property[13].value "rankingExpression(yetanotherfeature)" +rankprofile[2].fef.property[14].name "vespa.summary.feature" +rankprofile[2].fef.property[14].value "rankingExpression(macro_with_dollar$)" +rankprofile[2].fef.property[15].name "vespa.feature.rename" +rankprofile[2].fef.property[15].value "rankingExpression(anotherfeature)" +rankprofile[2].fef.property[16].name "vespa.feature.rename" +rankprofile[2].fef.property[16].value "anotherfeature" +rankprofile[2].fef.property[17].name "vespa.feature.rename" +rankprofile[2].fef.property[17].value "rankingExpression(yetanotherfeature)" +rankprofile[2].fef.property[18].name "vespa.feature.rename" +rankprofile[2].fef.property[18].value "yetanotherfeature" +rankprofile[2].fef.property[19].name "vespa.feature.rename" +rankprofile[2].fef.property[19].value "rankingExpression(macro_with_dollar$)" +rankprofile[2].fef.property[20].name "vespa.feature.rename" +rankprofile[2].fef.property[20].value "macro_with_dollar$" +rankprofile[3].name "constantsAndMacro" +rankprofile[3].fef.property[0].name "rankingExpression(c).rankingScript" +rankprofile[3].fef.property[0].value "attribute(num)" +rankprofile[3].fef.property[1].name "vespa.rank.firstphase" +rankprofile[3].fef.property[1].value "rankingExpression(firstphase)" +rankprofile[3].fef.property[2].name "rankingExpression(firstphase).rankingScript" +rankprofile[3].fef.property[2].value "attribute(num) * 2.0 + 3.0" +rankprofile[3].fef.property[3].name "vespa.summary.feature" +rankprofile[3].fef.property[3].value "firstPhase" +rankprofile[4].name "doc" +rankprofile[4].fef.property[0].name "rankingExpression(myfeature).rankingScript" +rankprofile[4].fef.property[0].value "fieldMatch(title) + freshness(timestamp)" +rankprofile[4].fef.property[1].name "rankingExpression(otherfeature@6b0a229a66fcaa04).rankingScript" +rankprofile[4].fef.property[1].value "nativeRank(title,body)" +rankprofile[4].fef.property[2].name "rankingExpression(otherfeature).rankingScript" +rankprofile[4].fef.property[2].value "nativeRank(foo,body)" +rankprofile[4].fef.property[3].name "vespa.rank.firstphase" +rankprofile[4].fef.property[3].value "rankingExpression(firstphase)" +rankprofile[4].fef.property[4].name "rankingExpression(firstphase).rankingScript" +rankprofile[4].fef.property[4].value "rankingExpression(myfeature) * 10" +rankprofile[4].fef.property[5].name "vespa.rank.secondphase" +rankprofile[4].fef.property[5].value "rankingExpression(secondphase)" +rankprofile[4].fef.property[6].name "rankingExpression(secondphase).rankingScript" +rankprofile[4].fef.property[6].value "rankingExpression(otherfeature@6b0a229a66fcaa04) * rankingExpression(myfeature)" +rankprofile[4].fef.property[7].name "vespa.summary.feature" +rankprofile[4].fef.property[7].value "rankingExpression(myfeature)" +rankprofile[4].fef.property[8].name "vespa.feature.rename" +rankprofile[4].fef.property[8].value "rankingExpression(myfeature)" +rankprofile[4].fef.property[9].name "vespa.feature.rename" +rankprofile[4].fef.property[9].value "myfeature"
\ No newline at end of file diff --git a/model-evaluation/src/test/resources/config/ranking-macros/ranking-constants.cfg b/model-evaluation/src/test/resources/config/ranking-macros/ranking-constants.cfg new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/model-evaluation/src/test/resources/config/ranking-macros/ranking-constants.cfg diff --git a/model-evaluation/src/test/resources/config/ranking-macros/ranking-expressions.cfg b/model-evaluation/src/test/resources/config/ranking-macros/ranking-expressions.cfg new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/model-evaluation/src/test/resources/config/ranking-macros/ranking-expressions.cfg |