Java Code Examples for org.dmg.pmml.Field#getDataType()

The following examples show how to use org.dmg.pmml.Field#getDataType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueParser.java    From jpmml-evaluator with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public VisitorAction visit(Value value){
	PMMLObject parent = getParent();

	Object simpleValue = value.getValue();
	if(simpleValue == null){
		throw new MissingAttributeException(value, PMMLAttributes.VALUE_VALUE);
	} // End if

	if(parent instanceof Field){
		Field<?> field = (Field<?>)parent;

		DataType dataType = field.getDataType();
		if(dataType != null){
			simpleValue = safeParseOrCast(dataType, simpleValue);

			value.setValue(simpleValue);
		}
	}

	return super.visit(value);
}
 
Example 2
Source File: AbstractParser.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
protected DataType resolveDataType(FieldName name){
	DataType dataType = this.dataTypes.get(name);

	if(dataType == null && !this.dataTypes.containsKey(name)){
		Collection<Field<?>> fields = getFields();

		for(Field<?> field : fields){

			if((name).equals(field.getName())){

				if((dataType == null) || (dataType).equals(field.getDataType())){
					dataType = field.getDataType();
				} else

				// Two or more conflicting data types
				{
					dataType = null;

					break;
				}
			}
		}

		this.dataTypes.put(name, dataType);
	}

	return dataType;
}
 
Example 3
Source File: AbstractParser.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
protected DataType resolveTargetDataType(FieldName name){
	DataType dataType = this.dataTypes.get(name);

	if(dataType == null && !this.dataTypes.containsKey(name)){
		Collection<Field<?>> fields = getFields();

		for(Field<?> field : fields){

			if((name).equals(field.getName())){

				if(dataType != null){
					throw new DuplicateFieldException(name);
				}

				dataType = field.getDataType();
			}
		}

		if(dataType == null){
			throw new MissingFieldException(name);
		}

		this.dataTypes.put(name, dataType);
	}

	return dataType;
}
 
Example 4
Source File: DocumentFeature.java    From jpmml-sparkml with GNU Affero General Public License v3.0 4 votes vote down vote up
public DocumentFeature(SparkMLEncoder encoder, Field<?> field, String wordSeparatorRE){
	super(encoder, field.getName(), field.getDataType());

	setWordSeparatorRE(wordSeparatorRE);
}
 
Example 5
Source File: BaseNFeature.java    From jpmml-sklearn with GNU Affero General Public License v3.0 4 votes vote down vote up
public BaseNFeature(PMMLEncoder encoder, Field<?> field, int base, SetMultimap<Integer, ?> values){
	this(encoder, field.getName(), field.getDataType(), base, values);
}
 
Example 6
Source File: FieldUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
static
public DataType getDataType(Field<?> field){
	return field.getDataType();
}
 
Example 7
Source File: ModelField.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
public DataType getDataType(){
	Field<?> field = getField();

	return field.getDataType();
}