不同蕴涵机制的耶拿效应

发布于 2024-09-04 12:58:58 字数 1995 浏览 7 评论 0原文

我正在尝试 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光清浅 2024-09-11 12:58:58

你的本体论看起来有点可疑。

book1book2book3mit 不是类,它们是个体。您应该使用 model.createIndividual(NS + "bookX",publication) 作为书籍,并为“organization”或类似的类创建一个类,然后创建 mit 作为该班级的个人。请注意,createIndividual 已经负责将类型分配给个体,因此您无需弄乱“a”属性。您应该先解决这些问题,然后重试并更新您的问题。

关于蕴含:查看查询结果的最后一行。您没有在任何地方说 book3 是一本书,但该声明仍然存在。这是因为它是由其他语句蕴含的,这就是 RDFS 推理引擎在您查询模型时使该语句可见的原因。该语句是必然的,因为 publishes 的范围:正在发布的所有内容都必然是 publication 类型。

Your ontology looks a bit fishy.

book1, book2, book3 and mit are not classes, they are individuals. You should use model.createIndividual(NS + "bookX", publication) for the books, and create a class for “organization” or similar, and then create mit as an individual of that class. Note that createIndividual 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 on publishes: Everything that's being published is entailed to be of type publication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文