From 5973587421282738babb1be7fe1cd45acd21ddfc Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 4 Apr 2022 10:02:52 +0200 Subject: Allow inputs declarations in rank profiles --- config-model/src/main/javacc/SDParser.jj | 48 +++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'config-model/src/main/javacc/SDParser.jj') diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index c4542c36779..724239fc9b7 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -46,6 +46,7 @@ import com.yahoo.searchdefinition.fieldoperation.*; import com.yahoo.searchlib.rankingexpression.FeatureList; import com.yahoo.searchlib.rankingexpression.evaluation.Value; import com.yahoo.searchlib.rankingexpression.evaluation.TensorValue; +import com.yahoo.searchlib.rankingexpression.Reference; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -137,9 +138,9 @@ public class SDParser { /** * Parses the given token image as a ranking expression feature list. * - * @param image The token image to parse. - * @return The consumed feature list. - * @throws ParseException Thrown if the image could not be parsed. + * @param image the token image to parse + * @return the consumed feature list + * @throws ParseException thrown if the image could not be parsed. */ private FeatureList getFeatureList(String image) throws ParseException { try { @@ -205,6 +206,7 @@ TOKEN : | < WEIGHT: "weight" > | < TYPE: "type" > | < INDEX: "index" > +| < INPUTS: "inputs"> | < MTOKEN: "token" > | < TEXT: "text" > | < WORD: "word" > @@ -218,6 +220,7 @@ TOKEN : | < ONNXMODEL: "onnx-model"> | < MODEL: "model" > | < MUTATE: "mutate" > +| < QUERY: "query" > | < RANKPROFILE: "rank-profile" > | < RANKDEGRADATIONFREQ: "rank-degradation-frequency" > | < RANKDEGRADATION: "rank-degradation" > @@ -1975,6 +1978,7 @@ void rankProfileItem(RankProfile profile) : { } | rankProperties(profile) | secondPhase(profile) | rankDegradation(profile) + | inputs(profile) | constants(profile) | matchFeatures(profile) | summaryFeatures(profile) @@ -2187,11 +2191,28 @@ void secondPhaseItem(RankProfile profile) : ) } -/** - * This rule consumes a summary-features block of a rank profile. - * - * @param profile The rank profile to modify. - */ +/** Consumes an inputs block of a rank profile. */ +void inputs(RankProfile profile) : +{ + Reference reference; + TensorType type; +} +{ + ()* + ( reference = queryFeature() type = tensorType("Type of " + reference) { profile.addInput(reference, type); } ()*) * + +} + +Reference queryFeature() : +{ + String argument; +} +{ + "(" argument = identifier() ")" + { return Reference.simple("query", argument); } +} + +/** Consumes a summary-features block of a rank profile. */ void summaryFeatures(RankProfile profile) : { String features; @@ -2476,9 +2497,7 @@ void rankDegradation(RankProfile profile) : ) } -/** - * Consumes a set of constants available in ranking expressions in the enclosing profile. - */ +/** Consumes a set of constants available in ranking expressions in the enclosing profile. */ void constants(RankProfile profile) : { String name; @@ -2633,6 +2652,8 @@ String identifier() : { } | | | + | + | | | | @@ -2671,6 +2692,8 @@ String identifier() : { } | | | + | + | | | | @@ -2699,6 +2722,7 @@ String identifier() : { } | | | + | | | | @@ -2746,8 +2770,6 @@ String identifier() : { } | | | - | - | ) { return token.image; } } -- cgit v1.2.3