当前位置: 首页>>代码示例>>Java>>正文


Java InfModel.validate方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.rdf.model.InfModel.validate方法的典型用法代码示例。如果您正苦于以下问题:Java InfModel.validate方法的具体用法?Java InfModel.validate怎么用?Java InfModel.validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.rdf.model.InfModel的用法示例。


在下文中一共展示了InfModel.validate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
/**
 * Validates the collected sample.
 * 
 * @param resource the Job resource representation (i.e. the sample owner).
 * @param exchange the current exchange.
 */
public void validate(final JobResource resource, final Exchange exchange) {
	log.info(MessageCatalog._00055_VALIDATING, resource.getID());

	resource.markAsValidated();

	collectSample(resource.getID(), exchange.getIn().getBody(String.class));
	
	final InfModel infmodel = ModelFactory.createInfModel(reasoner, samples.remove(resource.getID()));
       final ValidityReport validity = infmodel.validate();
       if (!validity.isClean()) {
       	log.info(MessageCatalog._00057_VALIDATION_KO, resource.getID());
       	for (final Iterator<ValidityReport.Report> iterator = validity.getReports(); iterator.hasNext(); ) {
       		final ValidityReport.Report report = iterator.next();
       		validationMessageRepository.save(new ValidationMessage(resource.getID(), report.getType(), report.getDescription()));
        	log.info(MessageCatalog._00058_VALIDATION_MSG, resource.getID(), report.getDescription(), report.getType());
       	}
        resource.setRunning(false);
        exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE); 
       } else {
        log.info(MessageCatalog._00056_VALIDATION_OK, resource.getID());
       }		
}
 
开发者ID:ALIADA,项目名称:aliada-tool,代码行数:29,代码来源:Validator.java

示例2: main

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void main( String[] args )
{

	Model schema = FileManager.get().loadModel("file:data/input/turtle/ex1-schema.ttl");
	Model data = FileManager.get().loadModel("file:data/input/turtle/ex1-data.ttl");
	InfModel infmodel = ModelFactory.createRDFSModel(schema, data);
	        
	
	ValidityReport validity = infmodel.validate();
	if (validity.isValid()) {
	    System.out.println("\nOK");
	} else {
	    System.out.println("\nConflicts");
	    for (Iterator i = validity.getReports(); i.hasNext(); ) {
	        ValidityReport.Report report = (ValidityReport.Report)i.next();
	        System.out.println(" - " + report);
	    }
	}
	
	System.out.println( "done" );
	
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:23,代码来源:ReadRDF_And_Validate.java

示例3: testIsConsistent

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
/**
 * Test if the new Inference Model is consistent.
 *
 */
@Test
public void testIsConsistent() throws Exception {
    boolean res = false;
    InfModel inf = ModelFactory.createInfModel(this.myReasoner, this.instances);
    if (!inf.isEmpty()) {
        ValidityReport validity = inf.validate();
        if (validity.isValid()) {
            // Our inference has been validated and we can say that is consistent based on new rules.
            res = true;
        }
    }
    assertTrue(res);
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:18,代码来源:RuleEngineTest.java

示例4: checkOntologyModelInconsistencies

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
/**
 * 
 * Check reasoning inference (no spin rules infereces, only OWL inferences
 * and restrictions)
 * 
 * @param model
 */
public void checkOntologyModelInconsistencies(OntModel model) {
	Reasoner reasoner = model.getReasoner();
	InfModel infmodel = ModelFactory.createInfModel(reasoner, model);

	ValidityReport report = infmodel.validate();
	if (!report.isValid()) {
		this.getLogger().severe("Incosistent ontology -> isValid: " + report.isValid());
	} else {
		this.getLogger().severe("No incosistent ontology -> isValid: " + report.isValid());
	}
}
 
开发者ID:gsi-upm,项目名称:shanks-wsn-module,代码行数:19,代码来源:ZigBeeCoordiantorNodeSoftware.java

示例5: run

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
/**
 * Add OWL rules and compute the forward chain.
 * 
 * @param base
 * @param datasetPaths
 */
public static void run(String base) {

	Reasoner reasoner = PelletReasonerFactory.theInstance().create();
	OntModel ontModel = ModelFactory
			.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);

	String path = System.getProperty("user.dir");
	RDFDataMgr.read(infModel, "file://" + path + "/" + base + "/model.nt");

	logger.info("Model size = " + ontModel.size());

	ValidityReport report = infModel.validate();
	printIterator(report.getReports(), "Validation Results");

	logger.info("Inferred model size = " + infModel.size());

	infModel.enterCriticalSection(Lock.READ);

	try {
		RDFDataMgr.write(new FileOutputStream(new File(base
				+ "/model-fwc.nt")), infModel, Lang.NT);
		logger.info("Model generated.");
	} catch (FileNotFoundException e) {
		logger.fatal(e.getMessage());
		throw new RuntimeException("Necessary file model-fwc.nt was not generated.");
	} finally {
		infModel.leaveCriticalSection();
	}

	new File(base + "/model.nt").delete();

}
 
开发者ID:mommi84,项目名称:Mandolin,代码行数:40,代码来源:PelletReasoner.java

示例6: closure

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void closure(String input, String output) {
	
	Reasoner reasoner = PelletReasonerFactory.theInstance().create();
	OntModel ontModel = ModelFactory
			.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);

	String path = System.getProperty("user.dir");
	RDFDataMgr.read(infModel, "file://" + path + "/" + input);

	logger.info("Model = "+input+", size = " + ontModel.size());

	ValidityReport report = infModel.validate();
	printIterator(report.getReports(), "Validation Results");

	logger.info("Inferred model size = " + infModel.size());

	infModel.enterCriticalSection(Lock.READ);

	try {
		RDFDataMgr.write(new FileOutputStream(new File(output)), 
				infModel, Lang.NT);
		logger.info("Model generated at "+output);
	} catch (FileNotFoundException e) {
		logger.fatal(e.getMessage());
		throw new RuntimeException("Necessary file "+output+" was not generated.");
	} finally {
		infModel.leaveCriticalSection();
	}
	
}
 
开发者ID:mommi84,项目名称:Mandolin,代码行数:32,代码来源:PelletReasoner.java

示例7: assessDataset

import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
@Override
	public void assessDataset(SparqlifyDataset dataset)
			throws NotImplementedException, SQLException {

		Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
		logger.debug("building inf model");
		InfModel infModel = ModelFactory.createInfModel(reasoner, dataset);
		infModel.prepare();
		logger.debug("built inf model");
		
		logger.debug("generating valReport");
		ValidityReport valReport = infModel.validate();
		Iterator<Report> reportIt = valReport.getReports();
		
		while (reportIt.hasNext()) {
			Report report = reportIt.next();
			List<Triple> badTriples = getErroneousTriples(report);
			List<Pair<Triple, Set<ViewQuad<ViewDefinition>>>> pinpointRes =
					new ArrayList<Pair<Triple, Set<ViewQuad<ViewDefinition>>>>();
			
			for (Triple triple : badTriples) {
				if (tripleExists(triple, dataset)) {
				
					Set<ViewQuad<ViewDefinition>> candidates =
							pinpointer.getViewCandidates(triple);
					
					Pair<Triple, Set<ViewQuad<ViewDefinition>>> tmp =
							new Pair<Triple, Set<ViewQuad<ViewDefinition>>>(triple, candidates);
				
					pinpointRes.add(tmp);
				}
				
//				// <just for Amrapali's QA>
//				float val;
//				if (report.isError()) val = 0;
//				else val = (float) 0.5;
//				Set<ViewQuad<ViewDefinition>> viewQuads = new HashSet<ViewQuad<ViewDefinition>>();
//				writeTripleMeasureToSink(val, triple, viewQuads);
//				// </just for Amrapali's QA>
			}
			float val;
			if (report.isError()) val = 0;
			else val = (float) 0.5;
			
			writeTriplesMeasureToSink(report.getType(), val, pinpointRes);
		}
	}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:48,代码来源:BasicOntologyConformance.java


注:本文中的com.hp.hpl.jena.rdf.model.InfModel.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。