Search in sources :

Example 11 with ReferenceNode

use of com.yahoo.searchlib.rankingexpression.rule.ReferenceNode in project vespa by vespa-engine.

the class AbstractArrayContext method extractVariables.

private void extractVariables(ExpressionNode node, Set<String> variables) {
    if (node instanceof ReferenceNode) {
        ReferenceNode fNode = (ReferenceNode) node;
        if (fNode.getArguments().expressions().size() > 0)
            throw new UnsupportedOperationException("Array lookup is not supported with features having arguments)");
        variables.add(fNode.toString());
    } else if (node instanceof CompositeNode) {
        CompositeNode cNode = (CompositeNode) node;
        for (ExpressionNode child : cNode.children()) extractVariables(child, variables);
    }
}
Also used : CompositeNode(com.yahoo.searchlib.rankingexpression.rule.CompositeNode) ReferenceNode(com.yahoo.searchlib.rankingexpression.rule.ReferenceNode) ExpressionNode(com.yahoo.searchlib.rankingexpression.rule.ExpressionNode)

Example 12 with ReferenceNode

use of com.yahoo.searchlib.rankingexpression.rule.ReferenceNode in project vespa by vespa-engine.

the class FeatureList method parse.

/**
 * Parses the content of a reader object as a list of feature nodes.
 *
 * @param reader A reader object that contains an feature list.
 * @return A list of those features named in the string.
 * @throws ParseException if the string could not be parsed.
 */
private static List<ReferenceNode> parse(Reader reader) throws ParseException {
    List<ReferenceNode> lst;
    try {
        lst = new RankingExpressionParser(reader).featureList();
    } catch (TokenMgrError e) {
        ParseException t = new ParseException();
        throw (ParseException) t.initCause(e);
    }
    List<ReferenceNode> ret = new ArrayList<ReferenceNode>(lst.size());
    for (Object obj : lst) {
        if (!(obj instanceof ReferenceNode)) {
            throw new IllegalStateException("Feature list contains a " + obj.getClass().getName() + ".");
        }
        ret.add((ReferenceNode) obj);
    }
    return ret;
}
Also used : ReferenceNode(com.yahoo.searchlib.rankingexpression.rule.ReferenceNode) ArrayList(java.util.ArrayList) RankingExpressionParser(com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParser) TokenMgrError(com.yahoo.searchlib.rankingexpression.parser.TokenMgrError) ParseException(com.yahoo.searchlib.rankingexpression.parser.ParseException)

Aggregations

ReferenceNode (com.yahoo.searchlib.rankingexpression.rule.ReferenceNode)12 ExpressionNode (com.yahoo.searchlib.rankingexpression.rule.ExpressionNode)6 NameNode (com.yahoo.searchlib.rankingexpression.rule.NameNode)4 TensorFunctionNode (com.yahoo.searchlib.rankingexpression.rule.TensorFunctionNode)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Arguments (com.yahoo.searchlib.rankingexpression.rule.Arguments)2 ArithmeticNode (com.yahoo.searchlib.rankingexpression.rule.ArithmeticNode)2 CompositeNode (com.yahoo.searchlib.rankingexpression.rule.CompositeNode)2 TensorType (com.yahoo.tensor.TensorType)2 Reduce (com.yahoo.tensor.functions.Reduce)2 RankProfile (com.yahoo.searchdefinition.RankProfile)1 DoubleValue (com.yahoo.searchlib.rankingexpression.evaluation.DoubleValue)1 TensorValue (com.yahoo.searchlib.rankingexpression.evaluation.TensorValue)1 Value (com.yahoo.searchlib.rankingexpression.evaluation.Value)1 OrderedTensorType (com.yahoo.searchlib.rankingexpression.integration.tensorflow.importer.OrderedTensorType)1 ParseException (com.yahoo.searchlib.rankingexpression.parser.ParseException)1 RankingExpressionParser (com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParser)1 TokenMgrError (com.yahoo.searchlib.rankingexpression.parser.TokenMgrError)1 ArithmeticOperator (com.yahoo.searchlib.rankingexpression.rule.ArithmeticOperator)1