public SimpleSegmentPredicate(SimplePredicate predicate) { this.baseFieldName = predicate.getField(); this.operator = predicate.getOperator(); this.value = predicate.getValue(); this.stringLiteralValue = checkValueForStringLiteral(this.value); if (this.operator == null) { throw new IllegalStateException("PMML - SimplePredicate: Missing operator"); } }
public static String extractFieldNameFromCharacteristic(Characteristic c) { String field = ""; Attribute scoreAttribute = c.getAttributes().get(0); if (scoreAttribute.getSimplePredicate() != null) { field = scoreAttribute.getSimplePredicate().getField(); } else if (scoreAttribute.getSimpleSetPredicate() != null) { field = scoreAttribute.getSimpleSetPredicate().getField(); } else if (scoreAttribute.getCompoundPredicate() != null) { Object predicate = scoreAttribute.getCompoundPredicate().getSimplePredicatesAndCompoundPredicatesAndSimpleSetPredicates().get(0); if (predicate instanceof SimplePredicate){ field = ((SimplePredicate)predicate).getField(); } else if (predicate instanceof SimpleSetPredicate){ field = ((SimpleSetPredicate)predicate).getField(); } } return field; }