diff options
Diffstat (limited to 'config-model/src/main/javacc/SDParser.jj')
-rw-r--r-- | config-model/src/main/javacc/SDParser.jj | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index fe522494baf..07171dea803 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -29,6 +29,7 @@ import com.yahoo.documentmodel.*; import com.yahoo.compress.Compressor; import com.yahoo.compress.CompressionType; import com.yahoo.searchdefinition.Application; +import com.yahoo.searchdefinition.DistributableResource; import com.yahoo.searchdefinition.document.*; import com.yahoo.searchdefinition.document.annotation.SDAnnotationType; import com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType; @@ -357,6 +358,7 @@ TOKEN : | < MULTITHREADEDINDEXING: "multi-threaded-indexing" > | < MATCHFEATURES_SL: "match-features" (" ")* ":" (~["}","\n"])* ("\n")? > | < MATCHFEATURES_ML: "match-features" (<SEARCHLIB_SKIP>)? "{" (~["}"])* "}" > +| < MATCHFEATURES_ML_INHERITS: "match-features inherits " (<IDENTIFIER>) (<SEARCHLIB_SKIP>)? "{" (~["}"])* "}" > | < SUMMARYFEATURES_SL: "summary-features" (" ")* ":" (~["}","\n"])* ("\n")? > | < SUMMARYFEATURES_ML: "summary-features" (<SEARCHLIB_SKIP>)? "{" (~["}"])* "}" > | < SUMMARYFEATURES_ML_INHERITS: "summary-features inherits " (<IDENTIFIER>) (<SEARCHLIB_SKIP>)? "{" (~["}"])* "}" > @@ -1945,8 +1947,8 @@ Object onnxModelItem(OnnxModel onnxModel) : } { ( - (<FILE> <COLON> path = filePath() { } (<NL>)*) { onnxModel.setFileName(path); } | - (<URI> <COLON> path = uriPath() { } (<NL>)*) { onnxModel.setUri(path); } | + (path = fileItem()) { onnxModel.setFileName(path); } | + (path = uriItem()) { onnxModel.setUri(path); } | (<ONNX_INPUT_SL>) { String name = token.image.substring(5, token.image.lastIndexOf(":")).trim(); if (name.startsWith("\"")) { name = name.substring(1, name.length() - 1); } @@ -1973,56 +1975,42 @@ Object onnxModelItem(OnnxModel onnxModel) : void rankingConstant(Schema schema) : { String name; - RankingConstant constant; + String path = null; + DistributableResource.PathType pathType = DistributableResource.PathType.FILE; + TensorType type = null; } { - ( <CONSTANT> name = identifier() - { - constant = new RankingConstant(name); - } - lbrace() (rankingConstantItem(constant) (<NL>)*)+ <RBRACE> ) + ( <CONSTANT> name = identifier() lbrace() + (path = fileItem() { pathType = DistributableResource.PathType.FILE; } + | path = uriItem() { pathType = DistributableResource.PathType.URI; } + | type = tensorTypeWithPrefix(rankingConstantErrorMessage(name)) (<NL>)* + )+ + <RBRACE> + ) { if (documentsOnly) return; - schema.rankingConstants().add(constant); + schema.rankingConstants().add(new RankingConstant(name, type, path, pathType)); } } -/** - * This rule consumes a constant block. - * - * @param constant The constant to modify. - * @return Null. - */ -Object rankingConstantItem(RankingConstant constant) : +String fileItem() : { - String path = null; - TensorType type = null; + String path; } { - ( (<FILE> <COLON> path = filePath() { } (<NL>)*) { constant.setFileName(path); } - | (<URI> <COLON> path = uriPath() { } (<NL>)*) { constant.setUri(path); } - | type = tensorTypeWithPrefix(rankingConstantErrorMessage(constant.getName())) (<NL>)* { constant.setType(type); } - ) - { - return null; - } + (<FILE> <COLON> ( <FILE_PATH> | <STRING> | <IDENTIFIER>) { path = token.image; } { } (<NL>)*) { return path; } } - -String rankingConstantErrorMessage(String name) : {} +String uriItem() : { - { return "For ranking constant ' " + name + "'"; } + String path; } - -String filePath() : { } { - ( <FILE_PATH> | <STRING> | <IDENTIFIER>) - { return token.image; } + (<URI> <COLON> ( <URI_PATH> ) { path = token.image; } (<NL>)*) { return path; } } -String uriPath() : { } +String rankingConstantErrorMessage(String name) : {} { - ( <URI_PATH> ) - { return token.image; } + { return "For ranking constant ' " + name + "'"; } } /** @@ -2335,7 +2323,14 @@ Object matchFeatures(RankProfile profile) : { ( <MATCHFEATURES_SL> { features = token.image.substring(token.image.indexOf(":") + 1).trim(); } | <MATCHFEATURES_ML> { features = token.image.substring(token.image.indexOf("{") + 1, - token.image.lastIndexOf("}")).trim(); } ) + token.image.lastIndexOf("}")).trim(); } | + <MATCHFEATURES_ML_INHERITS> { + int inheritsIndex = token.image.indexOf("inherits "); + String rest = token.image.substring(inheritsIndex + "inherits ".length()); + profile.setInheritedMatchFeatures(rest.substring(0, rest.indexOf(" ")).trim()); + features = token.image.substring(token.image.indexOf("{") + 1, token.image.lastIndexOf("}")).trim(); + } + ) { profile.addMatchFeatures(getFeatureList(features)); return null; |