Search in sources :

Example 1 with DefaultIntensionalUniSet

use of com.sri.ai.expresso.core.DefaultIntensionalUniSet in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultIntensionalUniSetFromLabelAndSubTrees.

private static Expression makeDefaultIntensionalUniSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
        subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
    }
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    if (subTreeExpressions.size() == 1) {
        subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
    }
    Expression scopingExpression = subTreeExpressions.get(0);
    IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet((scopingExpression == null || scopingExpression.numberOfArguments() == 0) ? Util.list() : new ArrayList<Expression>(Expressions.ensureListFromKleeneList(scopingExpression.get(0))));
    Expression conditioningSyntaxTree = subTreeExpressions.get(2);
    Expression condition = conditioningSyntaxTree == null ? Expressions.TRUE : conditioningSyntaxTree.get(0);
    Expression result = new DefaultIntensionalUniSet(indexExpressions, subTreeExpressions.get(1), condition);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) DefaultIntensionalUniSet(com.sri.ai.expresso.core.DefaultIntensionalUniSet) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) ArrayList(java.util.ArrayList) Collection(java.util.Collection) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)1 IndexExpressionsSet (com.sri.ai.expresso.api.IndexExpressionsSet)1 LambdaExpression (com.sri.ai.expresso.api.LambdaExpression)1 DefaultIntensionalUniSet (com.sri.ai.expresso.core.DefaultIntensionalUniSet)1 DefaultLambdaExpression (com.sri.ai.expresso.core.DefaultLambdaExpression)1 ExtensionalIndexExpressionsSet (com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet)1 IndexExpressions (com.sri.ai.grinder.library.indexexpression.IndexExpressions)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1