隐士推理得到一个班级的所有个体

时间:2016-08-10 16:58:51

标签: rdf owl owl-api pellet

我正在使用来自Maven的HermiT»1.3.8.1和来自maven的OWL API 5.0.2。我试着差不多2天才得到推论。我检查了所有的例子,对我来说没有用。有这么多版本的reasoners和APIS真是令人沮丧。 `

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        File file = new File(PATH_MODEL_ALL_OWL);
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file);

        OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
        OWLReasonerConfiguration config = new SimpleConfiguration();
        OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, config);
        reasoner.precompute();
    private void printIndividualsByclass(OWLOntology ontology, OWLReasoner reasoner, String owlClass) {
    for (OWLClass c : ontology.getClassesInSignature()) {
        if (c.getIRI().getShortForm().equals(owlClass)) {
            NodeSet<OWLNamedIndividual> instances = reasoner.getInstances(c, false);
            System.out.println("Class : " + c.getIRI().getShortForm());
            for (OWLNamedIndividual i : instances.getFlattened()) {
                System.out.println(i.getIRI().getShortForm());
            }
        }
    }

我有3个等级相关的类:A,B,C。 A包含4个人和C 2.如果我要求这个方法返回B的所有实例,它应该返回6个实例,这些实例在这些类中的任何等价关系。我做了一个实验并制作了B的子类B和A等价的B.使用推理逻辑得到了A和C的所有实例。但不公平地说,等同与隐士不起作用。非常感谢帮助!

编辑:我看到我没有使用Hermit推理器而没有调用Reasoner reasoner = new Reasoner。我找不到一个例子,它给出了一个特定类的所有个体,也是推理(equivalentTo,Subclass)。请提供您使用隐士版本或任何其他推理者的owl api版本。带有depandancies的pom文件也非常棒。只是一个有pom的工作示例。我真的很沮丧,没有一个例子对我有用。

我的pom文件:

`<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>Exporter</groupId>
        <artifactId>Exporter</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <build>
            <sourceDirectory>src</sourceDirectory>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>net.sourceforge.owlapi</groupId>
                <artifactId>owlapi-distribution</artifactId>
                <version>5.0.2</version>
            </dependency>
            <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>org.semanticweb.hermit</artifactId>
        <version>1.3.8.500</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.github.ansell.pellet/pellet-owlapiv3 -->

            <dependency>
                <groupId>net.sourceforge.owlapi</groupId>
                <artifactId>owlapi-apibinding</artifactId>
                <version>5.0.2</version>
            </dependency>
            <dependency>
                <groupId>net.sourceforge.owlapi</groupId>
                <artifactId>owlapi-api</artifactId>
                <version>5.0.2</version>
            </dependency>
        </dependencies>
    </project>`

1 个答案:

答案 0 :(得分:1)

HermiT 1.3.8.1与owlapi 5不兼容。在maven版本1.3.8.500上有兼容版本。它是主要的HermiT代码库的一个分支,它更新1.3.8.x以使用owlapi 5(我同时维护owlapi 5和这个分支)。

相关问题