本文整理汇总了Java中org.dmg.pmml.CompoundPredicate类的典型用法代码示例。如果您正苦于以下问题:Java CompoundPredicate类的具体用法?Java CompoundPredicate怎么用?Java CompoundPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompoundPredicate类属于org.dmg.pmml包,在下文中一共展示了CompoundPredicate类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateNode
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
private Boolean evaluateNode(Trail trail, Node node, EvaluationContext context){
EmbeddedModel embeddedModel = node.getEmbeddedModel();
if(embeddedModel != null){
throw new UnsupportedElementException(embeddedModel);
}
Predicate predicate = PredicateUtil.ensurePredicate(node);
// A compound predicate whose boolean operator is "surrogate" represents a special case
if(predicate instanceof CompoundPredicate){
CompoundPredicate compoundPredicate = (CompoundPredicate)predicate;
PredicateUtil.CompoundPredicateResult result = PredicateUtil.evaluateCompoundPredicateInternal(compoundPredicate, context);
if(result.isAlternative()){
trail.addMissingLevel();
}
return result.getResult();
} else
{
return PredicateUtil.evaluate(predicate, context);
}
}
示例2: evaluateSurrogateCompoundPredicate
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
@Test
public void evaluateSurrogateCompoundPredicate(){
FieldName temperature = FieldName.create("temperature");
FieldName humidity = FieldName.create("humidity");
CompoundPredicate temperaturePredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.AND)
.addPredicates(
new SimplePredicate(temperature, SimplePredicate.Operator.LESS_THAN).setValue("90"),
new SimplePredicate(temperature, SimplePredicate.Operator.GREATER_THAN).setValue("50")
);
SimplePredicate humidityPredicate = new SimplePredicate(humidity, SimplePredicate.Operator.GREATER_OR_EQUAL).setValue("80");
CompoundPredicate compoundPredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.SURROGATE)
.addPredicates(temperaturePredicate, humidityPredicate);
assertEquals(Boolean.TRUE, evaluate(compoundPredicate, temperature, 70, humidity, null));
assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, 40, humidity, null));
assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, 100, humidity, null));
assertEquals(Boolean.TRUE, evaluate(compoundPredicate, temperature, null, humidity, 90));
assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, null, humidity, 70));
assertEquals(null, evaluate(compoundPredicate, temperature, null, humidity, null));
}
示例3: getFieldNamesFromPredicate
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
protected static void getFieldNamesFromPredicate(Set<String> fieldNames, Predicate predicate) {
if (predicate instanceof CompoundPredicate) {
List<Predicate> predicates = ((CompoundPredicate) predicate).getPredicates();
for (Predicate predicate1 : predicates) {
getFieldNamesFromPredicate(fieldNames, predicate1);
}
} else {
if (predicate instanceof SimplePredicate) {
fieldNames.add(((SimplePredicate) predicate).getField().getValue());
} else if (predicate instanceof SimpleSetPredicate) {
fieldNames.add(((SimpleSetPredicate) predicate).getField().getValue());
}
}
}
示例4: visit
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
@Override
public VisitorAction visit(CompoundPredicate compoundPredicate){
if(compoundPredicate.hasPredicates()){
filterAll(compoundPredicate.getPredicates());
}
return super.visit(compoundPredicate);
}
示例5: evaluatePredicate
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
static
Boolean evaluatePredicate(Predicate predicate, EvaluationContext context){
if(predicate instanceof SimplePredicate){
return evaluateSimplePredicate((SimplePredicate)predicate, context);
} else
if(predicate instanceof SimpleSetPredicate){
return evaluateSimpleSetPredicate((SimpleSetPredicate)predicate, context);
} else
if(predicate instanceof CompoundPredicate){
return evaluateCompoundPredicate((CompoundPredicate)predicate, context);
} else
if(predicate instanceof True){
return evaluateTrue((True)predicate);
} else
if(predicate instanceof False){
return evaluateFalse((False)predicate);
} // End if
if(predicate instanceof JavaPredicate){
return evaluateJavaPredicate((JavaPredicate)predicate, context);
}
throw new UnsupportedElementException(predicate);
}
示例6: transform
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
public Predicate transform(Predicate predicate){
if(predicate instanceof SimpleSetPredicate){
return transform((SimpleSetPredicate)predicate);
} else
if(predicate instanceof CompoundPredicate){
return transform((CompoundPredicate)predicate);
}
return predicate;
}
示例7: intern
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
@Test
public void intern(){
SimplePredicate left = new CustomSimplePredicate(FieldName.create("x"), SimplePredicate.Operator.LESS_THAN, new String("0"));
SimplePredicate right = new CustomSimplePredicate(FieldName.create("y"), SimplePredicate.Operator.LESS_THAN, new String("0"));
assertNotSame(left.getValue(), right.getValue());
CompoundPredicate compoundPredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.OR)
.addPredicates(left, right);
StringInterner interner = new StringInterner();
interner.applyTo(compoundPredicate);
assertSame(left.getValue(), right.getValue());
}
示例8: createCompoundPredicate
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
static
private CompoundPredicate createCompoundPredicate(CompoundPredicate.BooleanOperator booleanOperator, Predicate... predicates){
return new CompoundPredicate(booleanOperator)
.addPredicates(predicates);
}
示例9: evaluateCompoundPredicate
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
static
public Boolean evaluateCompoundPredicate(CompoundPredicate compoundPredicate, EvaluationContext context){
CompoundPredicateResult result = evaluateCompoundPredicateInternal(compoundPredicate, context);
return result.getResult();
}
示例10: evaluateCompoundPredicateInternal
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
static
public CompoundPredicateResult evaluateCompoundPredicateInternal(CompoundPredicate compoundPredicate, EvaluationContext context){
CompoundPredicate.BooleanOperator booleanOperator = compoundPredicate.getBooleanOperator();
if(booleanOperator == null){
throw new MissingAttributeException(compoundPredicate, PMMLAttributes.COMPOUNDPREDICATE_BOOLEANOPERATOR);
} // End if
if(!compoundPredicate.hasPredicates()){
throw new MissingElementException(MissingElementException.formatMessage(XPathUtil.formatElement(compoundPredicate.getClass()) + "/<Predicate>"), compoundPredicate);
}
List<Predicate> predicates = compoundPredicate.getPredicates();
if(predicates.size() < 2){
throw new InvalidElementListException(predicates);
}
Predicate predicate = predicates.get(0);
Boolean result = evaluate(predicate, context);
switch(booleanOperator){
case AND:
case OR:
case XOR:
break;
case SURROGATE:
if(result != null){
return new CompoundPredicateResult(result, false);
}
break;
default:
throw new UnsupportedAttributeException(compoundPredicate, booleanOperator);
}
for(int i = 1, max = predicates.size(); i < max; i++){
predicate = predicates.get(i);
Boolean value = evaluate(predicate, context);
switch(booleanOperator){
case AND:
result = PredicateUtil.binaryAnd(result, value);
break;
case OR:
result = PredicateUtil.binaryOr(result, value);
break;
case XOR:
result = PredicateUtil.binaryXor(result, value);
break;
case SURROGATE:
if(value != null){
return new CompoundPredicateResult(value, true);
}
break;
default:
throw new UnsupportedAttributeException(compoundPredicate, booleanOperator);
}
}
return new CompoundPredicateResult(result, false);
}
示例11: evaluateBooleanCompoundPredicate
import org.dmg.pmml.CompoundPredicate; //导入依赖的package包/类
@Test
public void evaluateBooleanCompoundPredicate(){
CompoundPredicate compoundPredicate = new CompoundPredicate()
.addPredicates(new True(), new False());
compoundPredicate.setBooleanOperator(CompoundPredicate.BooleanOperator.AND);
assertEquals(Boolean.FALSE, evaluate(compoundPredicate));
compoundPredicate.setBooleanOperator(CompoundPredicate.BooleanOperator.OR);
assertEquals(Boolean.TRUE, evaluate(compoundPredicate));
compoundPredicate.setBooleanOperator(CompoundPredicate.BooleanOperator.XOR);
assertEquals(Boolean.TRUE, evaluate(compoundPredicate));
}