當前位置: 首頁>>代碼示例>>Java>>正文


Java CompoundPredicate類代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:25,代碼來源:TreeModelEvaluator.java

示例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));
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:26,代碼來源:PredicateUtilTest.java

示例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());
        }
    }
}
 
開發者ID:brwe,項目名稱:es-token-plugin,代碼行數:15,代碼來源:TreeModelFactory.java

示例4: visit

import org.dmg.pmml.CompoundPredicate; //導入依賴的package包/類
@Override
public VisitorAction visit(CompoundPredicate compoundPredicate){

	if(compoundPredicate.hasPredicates()){
		filterAll(compoundPredicate.getPredicates());
	}

	return super.visit(compoundPredicate);
}
 
開發者ID:jpmml,項目名稱:jpmml-model,代碼行數:10,代碼來源:PredicateFilterer.java

示例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);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:30,代碼來源:PredicateUtil.java

示例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;
	}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:13,代碼來源:PredicateTransformer.java

示例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());
}
 
開發者ID:jpmml,項目名稱:jpmml-model,代碼行數:17,代碼來源:StringInternerTest.java

示例8: createCompoundPredicate

import org.dmg.pmml.CompoundPredicate; //導入依賴的package包/類
static
private CompoundPredicate createCompoundPredicate(CompoundPredicate.BooleanOperator booleanOperator, Predicate... predicates){
	return new CompoundPredicate(booleanOperator)
		.addPredicates(predicates);
}
 
開發者ID:jpmml,項目名稱:jpmml-model,代碼行數:6,代碼來源:GolfingTreeModelExample.java

示例9: evaluateCompoundPredicate

import org.dmg.pmml.CompoundPredicate; //導入依賴的package包/類
static
public Boolean evaluateCompoundPredicate(CompoundPredicate compoundPredicate, EvaluationContext context){
	CompoundPredicateResult result = evaluateCompoundPredicateInternal(compoundPredicate, context);

	return result.getResult();
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:7,代碼來源:PredicateUtil.java

示例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);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:62,代碼來源:PredicateUtil.java

示例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));
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:18,代碼來源:PredicateUtilTest.java


注:本文中的org.dmg.pmml.CompoundPredicate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。