不同蕴涵机制的耶拿效应
我正在尝试 sparql 和蕴涵的使用。
作为示例,我使用 http://www.w3。 org/TR/2010/WD-sparql11-entailment-20100126/#t112
我尝试将它们放入耶拿。
OntClass book1= model.createClass(NS+"book1");
OntClass book2=model.createClass(NS+"book2");
OntClass book3=model.createClass(NS+"book3");
OntClass publication=model.createClass(NS+"publication");
OntClass article=model.createClass(NS+"article");
OntClass mit=model.createClass(NS+"MIT");
ObjectProperty a = model.createObjectProperty(NS+"a");
ObjectProperty publishes = model.createObjectProperty(NS+"publishes");
book1.addProperty(a, publication);
book2.addProperty(a, article);
publication.addSubClass(article);
publishes.addRange(publication);
mit.addProperty(publishes, book3);
其中模型是 OntModel 类型。
我使用了类似于问题的查询
"PREFIX table: "I have correct namespace here"+
"SELECT *"+
"WHERE"+
"{"+
" ?x ?y table:publication ."+
"}";
模型是这样创建的。希望 OntModelSpec 没问题。
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RDFS_INF, null);
我从查询中得到的结果
x y
| http://www.example.com/ontologies/sample.owl#publishes | rdfs:range |
| http://www.example.com/ontologies/sample.owl#article | rdfs:subClassOf |
| http://www.example.com/ontologies/sample.owl#book1 | http://www.example.com/ontologies/sample.owl#a |
| http://www.example.com/ontologies/sample.owl#publication | rdfs:subClassOf |
| http://www.example.com/ontologies/sample.owl#book3 | rdf:type |
谁能给我一个例子,有或没有蕴含,所以不能尝试代码,可以得到正确的结果。
I am trying sparql and the use of entailment.
As a example i used http://www.w3.org/TR/2010/WD-sparql11-entailment-20100126/#t112
i try to put them in jena.
OntClass book1= model.createClass(NS+"book1");
OntClass book2=model.createClass(NS+"book2");
OntClass book3=model.createClass(NS+"book3");
OntClass publication=model.createClass(NS+"publication");
OntClass article=model.createClass(NS+"article");
OntClass mit=model.createClass(NS+"MIT");
ObjectProperty a = model.createObjectProperty(NS+"a");
ObjectProperty publishes = model.createObjectProperty(NS+"publishes");
book1.addProperty(a, publication);
book2.addProperty(a, article);
publication.addSubClass(article);
publishes.addRange(publication);
mit.addProperty(publishes, book3);
where model is type OntModel.
and i used the query similar to the problem
"PREFIX table: "I have correct namespace here"+
"SELECT *"+
"WHERE"+
"{"+
" ?x ?y table:publication ."+
"}";
The model was created like this. Hope OntModelSpec is ok.
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RDFS_INF, null);
i get as results from query
x y
| http://www.example.com/ontologies/sample.owl#publishes | rdfs:range |
| http://www.example.com/ontologies/sample.owl#article | rdfs:subClassOf |
| http://www.example.com/ontologies/sample.owl#book1 | http://www.example.com/ontologies/sample.owl#a |
| http://www.example.com/ontologies/sample.owl#publication | rdfs:subClassOf |
| http://www.example.com/ontologies/sample.owl#book3 | rdf:type |
Can anyone give me a example, with and without entailment, so a cant try code, can get the results right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的本体论看起来有点可疑。
book1
、book2
、book3
和mit
不是类,它们是个体。您应该使用model.createIndividual(NS + "bookX",publication)
作为书籍,并为“organization”或类似的类创建一个类,然后创建mit
作为该班级的个人。请注意,createIndividual
已经负责将类型分配给个体,因此您无需弄乱“a
”属性。您应该先解决这些问题,然后重试并更新您的问题。关于蕴含:查看查询结果的最后一行。您没有在任何地方说
book3
是一本书,但该声明仍然存在。这是因为它是由其他语句蕴含的,这就是 RDFS 推理引擎在您查询模型时使该语句可见的原因。该语句是必然的,因为publishes
的范围:正在发布的所有内容都必然是publication
类型。Your ontology looks a bit fishy.
book1
,book2
,book3
andmit
are not classes, they are individuals. You should usemodel.createIndividual(NS + "bookX", publication)
for the books, and create a class for “organization” or similar, and then createmit
as an individual of that class. Note thatcreateIndividual
already takes care of assigning the type to the individual, so you don't need to mess around with your “a
” property. You should fix these things first and then try again and update your question.About entailment: Look at the last line of your query result. You didn't say anywhere that
book3
is a book, but the statement is there anyways. That's because it was entailed by the other statements, and that's why the RDFS inference engine makes the statement visible when you query the model. The statement is entailed because of the range onpublishes
: Everything that's being published is entailed to be of typepublication
.