简体   繁体   English

使用OWL-API和Hermit打印Pizza本体的超类

[英]Printing Superclasses of Pizza ontology using OWL-API and Hermit

I try to print the Superclasses of standard Pizza ontology downloaded from here . 我尝试打印从此处下载的标准Pizza本体的超类。 I am using OWL API 3.4.3 and Hermit 1.3.8.1 (reasoner). 我正在使用OWL API 3.4.3和Hermit 1.3.8.1(原因)。

The following code snippet is used to print the required Superclasses of class "Food" . 以下代码段用于打印所需的“食品”类的超类

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
IRI ontologyIRI =IRI.create("file:/D:/pizza.owl.xml");      
//IRI ontologyIRI =IRI.create("http://www.co-ode.org/ontologies/pizza/pizza.owl");

OWLOntology ontology = manager.loadOntology(ontologyIRI);
OWLReasoner reasoner = new Reasoner.ReasonerFactory().createReasoner(ontology);
OWLDataFactory df = manager.getOWLDataFactory();    
    try{
            reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS);
            //following Lines are to see super classes of Container
            OWLClass clsA = df.getOWLClass(IRI.create(ontologyIRI + "#Food"));
            Set<OWLClassExpression> superClasses = clsA.getSuperClasses(ontology);
            System.out.println("in TRY 1");
            //System.out.println("Hello World\n"+superClasses.iterator().toString());
            for (OWLClassExpression g : superClasses) {
                 System.out.println("The superclasses are:"+g);   
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }

I do not get any compilation error. 我没有得到任何编译错误。 The result is in TRY 1 . 结果为TRY 1 The content inside for loop has not been printed . for循环内的内容尚未打印

In protege 5.0, I have seen two Superclasses of Food class ; 在protege 5.0中,我看到了Food类的两个超类 namely DomainConcept and owl:Thing . DomainConceptowl:Thing Why these two names has not been printed by the program? 为什么程序没有打印这两个名字?

Where am I doing wrong? 我在哪里做错了?

Thanks for any kind of help. 感谢您的任何帮助。

Your ontology IRI is a local file name. 您的本体IRI是本地文件名。 When you use it to obtain a class IRI, you're getting a different IRI from the one actually used in the ontology. 当您使用它获得类IRI时,您将获得与本体中实际使用的IRI不同的IRI。 Check what IRI the class actually has and that should fix your issue. 检查班级实际拥有的IRI,这应该可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM