Search in sources :

Example 11 with DefineFunction

use of org.dmg.pmml.DefineFunction in project drools by kiegroup.

the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDefineFunction.

static void commonVerifyKiePMMLDefineFunction(KiePMMLDefineFunction toVerify, DefineFunction source) {
    assertNotNull(toVerify);
    assertEquals(source.getName(), toVerify.getName());
    DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
    assertEquals(expectedDataType, toVerify.getDataType());
    OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
    assertEquals(expectedOpType, toVerify.getOpType());
    commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
    List<ParameterField> sourcesParameterFields = source.getParameterFields();
    List<KiePMMLParameterField> toVerifyList = toVerify.getParameterFields();
    assertEquals(sourcesParameterFields.size(), toVerifyList.size());
    sourcesParameterFields.forEach(paramSource -> {
        Optional<KiePMMLParameterField> parameterToVerify = toVerifyList.stream().filter(param -> param.getName().equals(paramSource.getName().getValue())).findFirst();
        assertTrue(parameterToVerify.isPresent());
        commonVerifyKiePMMLParameterField(parameterToVerify.get(), paramSource);
    });
}
Also used : Interval(org.dmg.pmml.Interval) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) FieldColumnPair(org.dmg.pmml.FieldColumnPair) KiePMMLMiningField(org.kie.pmml.commons.model.KiePMMLMiningField) NormDiscrete(org.dmg.pmml.NormDiscrete) KiePMMLInterval(org.kie.pmml.commons.model.expressions.KiePMMLInterval) KiePMMLTruePredicate(org.kie.pmml.commons.model.predicates.KiePMMLTruePredicate) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) Row(org.dmg.pmml.Row) KiePMMLOutputField(org.kie.pmml.commons.model.KiePMMLOutputField) KiePMMLInlineTable(org.kie.pmml.commons.model.expressions.KiePMMLInlineTable) KiePMMLLinearNorm(org.kie.pmml.commons.model.expressions.KiePMMLLinearNorm) KiePMMLNormContinuous(org.kie.pmml.commons.model.expressions.KiePMMLNormContinuous) DiscretizeBin(org.dmg.pmml.DiscretizeBin) KiePMMLRow(org.kie.pmml.commons.model.expressions.KiePMMLRow) Assert.fail(org.junit.Assert.fail) TextIndexNormalization(org.dmg.pmml.TextIndexNormalization) SimpleSetPredicate(org.dmg.pmml.SimpleSetPredicate) True(org.dmg.pmml.True) KiePMMLDiscretizeBin(org.kie.pmml.commons.model.expressions.KiePMMLDiscretizeBin) CompoundPredicate(org.dmg.pmml.CompoundPredicate) KiePMMLFieldColumnPair(org.kie.pmml.commons.model.expressions.KiePMMLFieldColumnPair) KiePMMLTargetValue(org.kie.pmml.commons.model.KiePMMLTargetValue) KiePMMLSimpleSetPredicate(org.kie.pmml.commons.model.predicates.KiePMMLSimpleSetPredicate) NormContinuous(org.dmg.pmml.NormContinuous) KiePMMLDiscretize(org.kie.pmml.commons.model.expressions.KiePMMLDiscretize) DataField(org.dmg.pmml.DataField) KiePMMLTextIndexNormalization(org.kie.pmml.commons.model.expressions.KiePMMLTextIndexNormalization) List(java.util.List) KiePMMLApply(org.kie.pmml.commons.model.expressions.KiePMMLApply) Optional(java.util.Optional) ParameterField(org.dmg.pmml.ParameterField) KiePMMLDerivedField(org.kie.pmml.commons.transformations.KiePMMLDerivedField) IntStream(java.util.stream.IntStream) KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Predicate(org.dmg.pmml.Predicate) DefineFunction(org.dmg.pmml.DefineFunction) InlineTable(org.dmg.pmml.InlineTable) OutputField(org.dmg.pmml.OutputField) KiePMMLMapValues(org.kie.pmml.commons.model.expressions.KiePMMLMapValues) KiePMMLNormDiscrete(org.kie.pmml.commons.model.expressions.KiePMMLNormDiscrete) DerivedField(org.dmg.pmml.DerivedField) CAST_INTEGER(org.kie.pmml.api.enums.CAST_INTEGER) Discretize(org.dmg.pmml.Discretize) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) MiningField(org.dmg.pmml.MiningField) KiePMMLExpression(org.kie.pmml.commons.model.expressions.KiePMMLExpression) TargetValue(org.dmg.pmml.TargetValue) KiePMMLDefineFunction(org.kie.pmml.commons.transformations.KiePMMLDefineFunction) Expression(org.dmg.pmml.Expression) False(org.dmg.pmml.False) KiePMMLSimplePredicate(org.kie.pmml.commons.model.predicates.KiePMMLSimplePredicate) Assert.assertNotNull(org.junit.Assert.assertNotNull) TextIndex(org.dmg.pmml.TextIndex) FieldRef(org.dmg.pmml.FieldRef) KiePMMLCompoundPredicate(org.kie.pmml.commons.model.predicates.KiePMMLCompoundPredicate) Assert.assertTrue(org.junit.Assert.assertTrue) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) Target(org.dmg.pmml.Target) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) KiePMMLPredicate(org.kie.pmml.commons.model.predicates.KiePMMLPredicate) Array(org.dmg.pmml.Array) SimplePredicate(org.dmg.pmml.SimplePredicate) KiePMMLTarget(org.kie.pmml.commons.model.KiePMMLTarget) KiePMMLTextIndex(org.kie.pmml.commons.model.expressions.KiePMMLTextIndex) LinearNorm(org.dmg.pmml.LinearNorm) MapValues(org.dmg.pmml.MapValues) Apply(org.dmg.pmml.Apply) EXPRESSION_NOT_MANAGED(org.kie.pmml.commons.Constants.EXPRESSION_NOT_MANAGED) Constant(org.dmg.pmml.Constant) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) KiePMMLFalsePredicate(org.kie.pmml.commons.model.predicates.KiePMMLFalsePredicate) Assert.assertEquals(org.junit.Assert.assertEquals) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) ParameterField(org.dmg.pmml.ParameterField)

Example 12 with DefineFunction

use of org.dmg.pmml.DefineFunction in project drools by kiegroup.

the class KiePMMLTransformationDictionaryFactory method addDefineFunctions.

static NodeList<Expression> addDefineFunctions(final BlockStmt body, final List<DefineFunction> defineFunctions) {
    NodeList<Expression> arguments = new NodeList<>();
    for (DefineFunction defineFunction : defineFunctions) {
        arguments.add(new NameExpr(defineFunction.getName()));
        BlockStmt toAdd = getDefineFunctionVariableDeclaration(defineFunction);
        toAdd.getStatements().forEach(body::addStatement);
    }
    return getArraysAsListInvocation(arguments);
}
Also used : Expression(com.github.javaparser.ast.expr.Expression) NodeList(com.github.javaparser.ast.NodeList) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) NameExpr(com.github.javaparser.ast.expr.NameExpr) DefineFunction(org.dmg.pmml.DefineFunction)

Aggregations

DefineFunction (org.dmg.pmml.DefineFunction)12 Constant (org.dmg.pmml.Constant)5 FieldRef (org.dmg.pmml.FieldRef)5 ParameterField (org.dmg.pmml.ParameterField)5 Apply (org.dmg.pmml.Apply)4 TextIndex (org.dmg.pmml.TextIndex)4 KiePMMLDefineFunction (org.kie.pmml.commons.transformations.KiePMMLDefineFunction)4 Test (org.junit.Test)3 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 DerivedField (org.dmg.pmml.DerivedField)2 InlineTable (org.dmg.pmml.InlineTable)2 PMML (org.dmg.pmml.PMML)2 TextIndexNormalization (org.dmg.pmml.TextIndexNormalization)2 KiePMMLApply (org.kie.pmml.commons.model.expressions.KiePMMLApply)2 KiePMMLConstant (org.kie.pmml.commons.model.expressions.KiePMMLConstant)2 KiePMMLFieldRef (org.kie.pmml.commons.model.expressions.KiePMMLFieldRef)2 KiePMMLTextIndex (org.kie.pmml.commons.model.expressions.KiePMMLTextIndex)2