首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jena框架中SWRL规则的Pellet推理

Jena框架中SWRL规则的Pellet推理
EN

Stack Overflow用户
提问于 2012-05-14 00:16:52
回答 1查看 1.3K关注 0票数 3

我试图使用Jena框架来编辑用Protoge4.2构建的现有本体。也就是说,改变属性值或添加个人或类,然后进行推理。假设在本体论中我们有这样一个规则: hasAge(?p,?age)^swrlb:greaterThan(?age,18)->Adult(?p)。我希望能够改变耶拿一边的hasAge属性,看看是否有人是成年人。你能给我一些这方面的示例代码吗?任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2014-04-10 14:00:09

假设:

  • 您知道如何通过阅读构建的本体(
  • )来填充您的模型,您已经在类路径
  • 上放置了Pellet,您将IRI下面的IRI替换为您的域
  • 中的断言--启用了

下面的代码片段将为单个x-test://individual添加一个年龄,并断言漩涡引入的属性是满意的。

代码语言:javascript
复制
// 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) );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10576258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档