我试图使用Jena框架来编辑用Protoge4.2构建的现有本体。也就是说,改变属性值或添加个人或类,然后进行推理。假设在本体论中我们有这样一个规则: hasAge(?p,?age)^swrlb:greaterThan(?age,18)->Adult(?p)。我希望能够改变耶拿一边的hasAge属性,看看是否有人是成年人。你能给我一些这方面的示例代码吗?任何帮助都是非常感谢的。
发布于 2014-04-10 14:00:09
假设:
下面的代码片段将为单个x-test://individual添加一个年龄,并断言漩涡引入的属性是满意的。
// create an empty ontology model using Pellet spec
final OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
// read the file
model.read( ont );
// Grab a resource and and property, and then set the property on that individual
final Resource Adult = ResourceFactory.createResource("x-domain://Adult");
final Property hasAge = ResourceFactory.createProperty("x-domain://hasAge");
final Resource res = model.createResource("x-test://individual");
res.addLiteral(hasAge, 19);
// Test that the swirl rule has executed
assert( res.hasProperty(RDF.type, Adult) );https://stackoverflow.com/questions/10576258
复制相似问题