• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ValidityReport类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.hp.hpl.jena.reasoner.ValidityReport的典型用法代码示例。如果您正苦于以下问题:Java ValidityReport类的具体用法?Java ValidityReport怎么用?Java ValidityReport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ValidityReport类属于com.hp.hpl.jena.reasoner包,在下文中一共展示了ValidityReport类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCorrectOntology

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的package包/类
@Test
public void testCorrectOntology() throws Exception {
    Anno4j anno4j = new Anno4j();

    // Get a model builder with correct ontology:
    OntologyModelBuilder modelBuilder = new OWLJavaFileGenerator(anno4j);
    VehicleOntologyLoader.addVehicleOntology(modelBuilder);

    // Build the model:
    modelBuilder.build();

    // The model should be valid:
    ValidityReport report = modelBuilder.validate();
    assertTrue(report.isValid());

    // Check if model was persisted to Anno4j:
    List<RDFSClazz> cars = anno4j.createQueryService()
                                .addPrefix("ex", "http://example.de/ont#")
                                .addCriteria(".[is-a rdfs:Class AND is-a ex:Vehicle]",
                                                "http://example.de/ont#Car")
                                .execute(RDFSClazz.class);
    assertEquals(1, cars.size());
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:24,代码来源:ModelBuilderValidationTest.java


示例2: validate

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例3: main

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例4: testIsConsistent

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例5: testInvalidOntology

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的package包/类
@Test
public void testInvalidOntology() throws Exception {
    Anno4j anno4j = new Anno4j();

    // Get a model builder with correct ontology:
    OntologyModelBuilder modelBuilder = new OWLJavaFileGenerator(anno4j);
    VehicleOntologyLoader.addVehicleOntology(modelBuilder);

    // Set range of ex:seat_num to something not numeric (violates range constraint):
    modelBuilder.addRDF(IOUtils.toInputStream("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
            "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
            "         xmlns:ns0=\"http://example.de/ont#\">\n" +
            "  <rdf:Description rdf:about=\"http://example.de/ont#VWGolf\">\n" +
            "    <rdf:type rdf:resource=\"http://example.de/ont#Car\"/>\n" +
            "    <ns0:seat_num>Some non-numeric string</ns0:seat_num>\n" +
            "  </rdf:Description>\n" +
            "</rdf:RDF>"), "http://example.de/ont#");

    // Build the model:
    boolean exceptionThrown = false;
    try {
        modelBuilder.build();
    } catch (OntologyModelBuilder.RDFSModelBuildingException e) {
        exceptionThrown = true;
    }
    assertTrue(exceptionThrown);

    // The model should be valid:
    ValidityReport report = modelBuilder.validate();
    assertFalse(report.isValid());

    // Check that the model was not persisted to Anno4j:
    List<RDFSClazz> cars = anno4j.createQueryService()
            .addPrefix("ex", "http://example.de/ont#")
            .addCriteria(".[is-a rdfs:Class AND is-a ex:Vehicle]",
                    "http://example.de/ont#Car")
            .execute(RDFSClazz.class);
    assertEquals(0, cars.size());
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:40,代码来源:ModelBuilderValidationTest.java


示例6: run

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的package包/类
@Override
public void run() {
	final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	for (final URL u : ontologyURLs)
		try {
			final String uri = u.toExternalForm();
			out.println("Loading " + uri);
			if (uri.endsWith(".ttl")){
				out.println("recognized turtle");
				model.read(uri, "http://example.org", "TURTLE");
			} else
				model.read(u.toExternalForm());
			out.println("Loaded " + uri);
		} catch (Exception e) {
			model.close();
			handler.error(new OntologyDownloadError(u, e));
			return;
		}
	out.println("Consistency check started");
	final ValidityReport report = model.validate();
	if (report.isValid()){
		out.println("Consistency check succesful complete");
		handler.complete(new JenaQueryEngine(model));
	}
	else {
		out.println("Consistency check complete with errors");
		model.close();
		handler.error(new InconsistenOntologyException());
	}
}
 
开发者ID:opendatahacklab,项目名称:semanticoctopus,代码行数:31,代码来源:JenaPelletSeqDownloadTask.java


示例7: checkOntologyModelInconsistencies

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例8: doTestDatatypeRangeValidation

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的package包/类
private void doTestDatatypeRangeValidation(RDFDatatype over12Type, OntModelSpec spec) {	
		OntModel ont = ModelFactory.createOntologyModel(spec);
		String NS = "http://jena.hpl.hp.com/example#";
	    Resource over12 = ont.createResource( over12Type.getURI() );
	    DatatypeProperty hasValue = ont.createDatatypeProperty(NS + "hasValue");
	    hasValue.addRange( over12 );
	    
	    ont.createResource(NS + "a").addProperty(hasValue, "15", over12Type);
	    ont.createResource(NS + "b").addProperty(hasValue, "16", over12Type);
	    ont.createResource(NS + "c").addProperty(hasValue, "10", over12Type);
	    
	    ValidityReport validity = ont.validate();
	    assertTrue (! validity.isValid()); 
	    Iterator<Report> ritr = validity.getReports();
	    while (ritr.hasNext()) {
	    	System.out.println("For spec '" + spec + "': " + ritr.next().toString());
	    }
	    ont.write(System.out);
	    
	    // Check culprit reporting
	    ValidityReport.Report report = (validity.getReports().next());
	    Triple culprit = (Triple)report.getExtension();
	    assertEquals(culprit.getSubject().getURI(), NS + "c");
	    assertEquals(culprit.getPredicate(), hasValue.asNode());
	    
//	    ont.createTypedLiteral("15", over12Type).getValue();
//	    ont.createTypedLiteral("16", over12Type).getValue();
//	    ont.createTypedLiteral("12", over12Type).getValue();
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:30,代码来源:TestUserDefinedDatatype.java


示例9: run

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例10: closure

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例11: assessDataset

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的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


示例12: validate

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的package包/类
/**
 * Returns a validity report for the model build during the last call of {@link #build()}.
 *
 * @return The validity report for the model. Use {@link ValidityReport#isValid()} to
 * check if the model built is valid.
 * @throws IllegalStateException Thrown if the model was not previously built.
 */
@Override
public ValidityReport validate() {
    return model.validate();
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:12,代码来源:OWLJavaFileGenerator.java


示例13: validate

import com.hp.hpl.jena.reasoner.ValidityReport; //导入依赖的package包/类
/**
 * Returns a validity report for the model build during the last call of {@link #build()}.
 *
 * @return The validity report for the model. Use {@link ValidityReport#isValid()} to
 * check if the model built is valid.
 * @throws IllegalStateException Thrown if the model was not previously built.
 */
ValidityReport validate();
 
开发者ID:anno4j,项目名称:anno4j,代码行数:9,代码来源:OntologyModelBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalResourceStatus类代码示例发布时间:2022-05-22
下一篇:
Java ConfigRetriever类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap