0

我想用本体和颗粒推理器进行分类。Pellet 有一个功能(即实现())来为个人找到最具体的。我已经尝试过,但它不起作用,任何人都可以提供一些帮助或给我一些例子。

<Class rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#HavingDrink">
    <equivalentClass>
        <Class>
            <intersectionOf rdf:parseType="Collection">
                <rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#PersonalActivity"/>
                <Restriction>
                    <onProperty rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#hasActor"/>
                    <allValuesFrom>
                        <Class>
                            <intersectionOf rdf:parseType="Collection">
                                <rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#Person"/>
                                <Restriction>
                                    <onProperty rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#hasCurrentSymbolicLocation"/>
                                    <someValuesFrom rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#Kitchen"/>
                                </Restriction>
                                <Restriction>
                                    <onProperty rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#usingArtifact"/>
                                    <someValuesFrom>
                                        <Class>
                                            <unionOf rdf:parseType="Collection">
                                                <rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#CupsCupboard"/>
                                                <rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#Fridge"/>
                                            </unionOf>
                                        </Class>
                                    </someValuesFrom>
                                </Restriction>
                            </intersectionOf>
                        </Class>
                    </allValuesFrom>
                </Restriction>
            </intersectionOf>
        </Class>
    </equivalentClass>
    <rdfs:subClassOf rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#PersonalActivity"/>
</Class>

例如,HavingDrink 是活动类之一。现在我创建一个个人及其 ObjectProperty:

    String file = "file:///home/uqjwen/workspace/Owlapi/snapshot.owl#";
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ont = manager.loadOntology(IRI.create(file));
    OWLDataFactory fac = manager.getOWLDataFactory();

    PrefixManager pm = new DefaultPrefixManager(IRI.create("http://webmind.dico.unimi.it/CARE/locont.owl").toString());


    //////////create hasActor property///////////////////////////////////////
    OWLNamedIndividual currentActivity = fac.getOWLNamedIndividual("#alice_activity", pm);
    OWLNamedIndividual alice = fac.getOWLNamedIndividual("#alice", pm);
    OWLObjectProperty hasActor = fac.getOWLObjectProperty("#hasActor", pm);
    OWLObjectPropertyAssertionAxiom propertyAssertion = fac
            .getOWLObjectPropertyAssertionAxiom(hasActor,currentActivity,alice);
    manager.addAxiom(ont, propertyAssertion);

    ////////////create hasCurrentSymbolicLocation ////////
    OWLNamedIndividual kitchen = fac.getOWLNamedIndividual("#Kitchen", pm);

    OWLObjectProperty hasLocation = fac
            .getOWLObjectProperty("#hasCurrentSymbolicLocation", pm);
    OWLObjectPropertyAssertionAxiom locationAssertion = fac
            .getOWLObjectPropertyAssertionAxiom(hasLocation,alice,kitchen);
    manager.addAxiom(ont, locationAssertion);

    /////////////create using actifact  //////////////
    OWLNamedIndividual cc = fac.getOWLNamedIndividual("#cups_cupboard", pm);
    OWLObjectProperty usingArtifact = fac
            .getOWLObjectProperty("#usingArtifact", pm);
    OWLObjectPropertyAssertionAxiom artifactAssertion =fac
            .getOWLObjectPropertyAssertionAxiom(usingArtifact, alice, cc);
    manager.addAxiom(ont, artifactAssertion);

    OWLNamedIndividual fridge = fac.getOWLNamedIndividual("#fridge", pm);
    artifactAssertion =fac
            .getOWLObjectPropertyAssertionAxiom(usingArtifact, alice, fridge);
    manager.addAxiom(ont, artifactAssertion);


    //////////////reason 
    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );
    System.out.println(reasoner.isConsistent());
    reasoner.getKB().classify();
    reasoner.getKB().realize();
    NodeSet<OWLClass> types = reasoner.getTypes(currentActivity, true);

它应该返回 HaveDrink 类,但它没有。

4

2 回答 2

0

感谢 Joshua 和 Ignazio,我终于找到了问题所在。当我自己用 protege 定义本体时,它运行良好。所以我可以得出结论,这里本体的定义可能有问题:webmind.di.unimi.it/care/snapshot.owl。

于 2014-08-21T22:14:42.840 回答
0

首先要检查的是本体是否包含您希望它包含的类和个体——您可以通过将本体保存到代码中的 System.out 来做到这一点,这样您就可以确定加载了什么:

manager.saveOntology(ont, new SystemOutDocumentTarget());

然后确保前缀管理器解析的 IRI 与本体中的 IRI 匹配:

OWLNamedIndividual currentActivity = fac.getOWLNamedIndividual("#alice_activity", pm);
System.put.println("expected individual "+currentActivity.getIRI());

一旦这些可能的错误源被排除,您需要验证您期望的类型实际上可以从本体中推断出来——我们无法看到本体的其余部分,并且那里可能存在可能会改变预期结果的重要信息.

编辑:从本体来看,HavingDrink(在功能语法中)的定义是:

EquivalentClasses(:HavingDrink ObjectIntersectionOf( ObjectAllValuesFrom(:hasActor ObjectIntersectionOf(:Person ObjectSomeValuesFrom(:hasCurrentSymbolicLocation :Kitchen) ObjectSomeValuesFrom(:usingArtifact ObjectUnionOf(:Fridge :CupsCupboard))) ) :PersonalActivity))

为了使某物成为HavingDrink活动,它必须具有usingArtifact类型Fridgeor的值CupsCupboard,我在您的本体中看不到断言。这是一个相当复杂的定义,所以我会开始检查是否alice_activity是交叉路口各个部分的实例,并确保每个部分都满足。据我所知,中期不满意。

于 2014-08-18T21:46:47.873 回答