Java Code Examples for org.dmg.pmml.Extension#getContent()

The following examples show how to use org.dmg.pmml.Extension#getContent() . 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: NaiveBayesModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private List<BayesInput> parseBayesInputs(NaiveBayesModel naiveBayesModel){
	BayesInputs bayesInputs = naiveBayesModel.getBayesInputs();

	if(!bayesInputs.hasExtensions()){
		return bayesInputs.getBayesInputs();
	}

	List<BayesInput> result = new ArrayList<>(bayesInputs.getBayesInputs());

	// The support for continuous fields using the TargetValueStats element was officially introduced in PMML schema version 4.2.
	// However, it is possible to encounter this feature in older PMML schema version documents (most notably, produced by R's "pmml" package),
	// where the offending BayesInput element is surrounded by an Extension element:
	// <BayesInputs>
	//   <BayesInput>
	//     <PairCounts/>
	//   </BayesInput>
	//   <Extension>
	//     <BayesInput>
	//       <TargetValueStats/>
	//     </BayesInput>
	//   </Extension>
	// </BayesInputs>
	List<Extension> extensions = bayesInputs.getExtensions();
	for(Extension extension : extensions){
		List<?> objects = extension.getContent();

		for(Object object : objects){

			if(object instanceof BayesInput){
				BayesInput bayesInput = (BayesInput)object;

				result.add(bayesInput);
			}
		}
	}

	return result;
}
 
Example 2
Source File: MixedContentTest.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
static
private List<?> getDeepContent(Object object){
	Extension extension = (Extension)object;

	return extension.getContent();
}
 
Example 3
Source File: ExtensionUtil.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
static
public List<?> getContent(HasExtensions<?> hasExtensions){
	List<Extension> extensions = hasExtensions.getExtensions();

	assertEquals(1, extensions.size());

	Extension extension = extensions.get(0);

	return extension.getContent();
}