【问题标题】:How to load axioms inferred from protege and filter them by using OWL api如何加载从 protege 推断的公理并使用 OWL api 过滤它们
【发布时间】:2019-08-16 06:32:50
【问题描述】:

我正在使用一个名为 DLMiner 的 protege 插件来推理假设。我想要的是选择这些包含某些类或关系的假设。

例如,有两个假设:

Client SubClassOf isOwnerof some Account

Loan SubClassof isLoanOf some owl:Thing

并且我想要包含 Client 的假设,所以应该选择第一个。 此外,每个假设都有一些指标(假设、提升、精度、支持),我希望这些指标也可以选择。

以下是包含两个假设的样本:

<?xml version="1.0"?>
<rdf:RDF xmlns="http://owl.cs.man.ac.uk/dlminer_6020e73c-5d3e-434a-9172-924d14f4e948#"
     xml:base="http://owl.cs.man.ac.uk/dlminer_6020e73c-5d3e-434a-9172-924d14f4e948"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:www="http://www.dlminer.io#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://owl.cs.man.ac.uk/dlminer_6020e73c-5d3e-434a-9172-924d14f4e948"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.dlminer.io#assumption -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#assumption"/>



    <!-- http://www.dlminer.io#lift -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#lift"/>



    <!-- http://www.dlminer.io#precision -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#precision"/>



    <!-- http://www.dlminer.io#support -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#support"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Object Properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.owl-ontologies.com/unnamed.owl#hasLoan -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasLoan"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.owl-ontologies.com/unnamed.owl#Account -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Account">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Account"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.7477272727272726</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2200.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#Running -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Running"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // General axioms
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <owl:Axiom>
        <owl:annotatedSource>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoan"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Running"/>
                <rdfs:subClassOf>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>
                        <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
                    </owl:Restriction>
                </rdfs:subClassOf>
            </owl:Restriction>
        </owl:annotatedSource>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.7477272727272726</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">201.0</www:support>
    </owl:Axiom>
</rdf:RDF>



<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->

所以,如果焦点词是“帐户”,我想要的打印内容是:

Account SubClassOf hasStatementIssuanceFrequency some StatementIssuanceFrequencyValue 支持:2200,假设:0,精度:1。

我尝试使用 Jena 来实现我的目标,但我可以通过分析三元组之间的关系来挑选出我需要的假设。但是,我无法将指标与假设相匹配,因为我发现阅读顺序是随机的。我不确定这是否是某种耶拿阅读规则。

所以,我想知道我是否可以通过使用 OWL api 来实现我的目标,如果你能给我一个完整的例子,我将不胜感激。谢谢

另一个示例:

<?xml version="1.0"?>
<rdf:RDF xmlns="http://owl.cs.man.ac.uk/dlminer_2ff7f586-ee56-400a-89a9-936c6d890678#"
     xml:base="http://owl.cs.man.ac.uk/dlminer_2ff7f586-ee56-400a-89a9-936c6d890678"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:www="http://www.dlminer.io#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://owl.cs.man.ac.uk/dlminer_2ff7f586-ee56-400a-89a9-936c6d890678"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.dlminer.io#assumption -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#assumption"/>



    <!-- http://www.dlminer.io#lift -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#lift"/>



    <!-- http://www.dlminer.io#precision -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#precision"/>



    <!-- http://www.dlminer.io#support -->

    <owl:AnnotationProperty rdf:about="http://www.dlminer.io#support"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Object Properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.owl-ontologies.com/unnamed.owl#IsLoanOf -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#isOwnerOf -->

    <owl:ObjectProperty rdf:about="http://www.owl-ontologies.com/unnamed.owl#isOwnerOf"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.owl-ontologies.com/unnamed.owl#Account -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Account">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Account"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasStatementIssuanceFrequency"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.7477272727272726</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2200.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#Classic -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Classic">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Classic"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">19.67780429594272</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">302.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#Client -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Client">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isOwnerOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Client"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isOwnerOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">15.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.7223476297968396</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.9932279909706546</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2200.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#CreditCard -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#CreditCard">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Client"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#CreditCard"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Client"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">19.67780429594272</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">419.0</www:support>
    </owl:Axiom>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#CreditCard"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#isCreditCardOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">19.67780429594272</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">419.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#Loan -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Loan">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Loan"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">28.139931740614337</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">293.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#LoanStatusValue -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#LoanStatusValue"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#OKRunningLoan -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#OKRunningLoan">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#LoanStatusValue"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#OKRunningLoan"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">28.139931740614337</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">182.0</www:support>
    </owl:Axiom>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#OKRunningLoan"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#LoanStatusValue"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">28.139931740614337</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">182.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#OKStatus -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#OKStatus"/>



    <!-- http://www.owl-ontologies.com/unnamed.owl#Running -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Running">
        <rdfs:subClassOf rdf:resource="http://www.owl-ontologies.com/unnamed.owl#OKRunningLoan"/>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#OKStatus"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Running"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget rdf:resource="http://www.owl-ontologies.com/unnamed.owl#OKRunningLoan"/>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">19.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">41.01990049751244</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.9054726368159204</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">182.0</www:support>
    </owl:Axiom>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Running"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#IsLoanOf"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">28.139931740614337</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">201.0</www:support>
    </owl:Axiom>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Running"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>
                <owl:someValuesFrom rdf:resource="http://www.owl-ontologies.com/unnamed.owl#OKStatus"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">19.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">28.494740040256733</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.9054726368159204</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">182.0</www:support>
    </owl:Axiom>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Running"/>
        <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
        <owl:annotatedTarget>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasLoanStatusValue"/>
                <owl:someValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
            </owl:Restriction>
        </owl:annotatedTarget>
        <www:assumption rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</www:assumption>
        <www:lift rdf:datatype="http://www.w3.org/2001/XMLSchema#double">28.139931740614337</www:lift>
        <www:precision rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</www:precision>
        <www:support rdf:datatype="http://www.w3.org/2001/XMLSchema#double">201.0</www:support>
    </owl:Axiom>



    <!-- http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue -->

    <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#StatementIssuanceFrequencyValue"/>
</rdf:RDF>



<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->


【问题讨论】:

  • @ssz 谢谢你的回答。我已经删除了之前提供的本体的一些内容,可能导致 RDF/XML 不正确,我将其替换为完整版本。
  • 哈哈。虽然我已经实现了我的部分目标——找到一个公理并使用jena打印,但作为一个初学者,我的代码看起来很复杂,我认为必须有另一种方法。因此,如果您能以自己的方式为我提供方法,我将不胜感激。再次感谢。

标签: jena owl-api


【解决方案1】:

使用来自 owlapi-parsers 的 OWL-API(v5.1.11) 和 ManchesterOWLSyntaxOWLObjectRendererImpl,以下方法对我有用:

        OWLOntologyManager m = OntManagers.createOWL();
        OWLOntology o = m.loadOntologyFromOntologyDocument(data);
        OWLClass c = m.getOWLDataFactory().getOWLClass("http://www.owl-ontologies.com/unnamed.owl#Account");
        OWLAxiom a = o.axioms(c)
                .filter(x -> AxiomType.SUBCLASS_OF.equals(x.getAxiomType()))
                .sorted() // to have the same order every time
                .findFirst()
                .orElseThrow(AssertionError::new);
        OWLObjectRenderer r = new ManchesterOWLSyntaxOWLObjectRendererImpl();
        String res = r.render(a) + " " + a.annotations()
                .map(x -> x.getProperty().getIRI().getShortForm() + ": " +
                        x.getValue().asLiteral().orElseThrow(AssertionError::new).parseDouble())
                .collect(Collectors.joining(", "));
        System.out.println(res);

输出:

Account SubClassOf hasStatementIssuanceFrequency some StatementIssuanceFrequencyValue assumption: 0.0, lift: 3.7477272727272726, precision: 1.0, support: 2200.0

请注意,ManchesterOWLSyntaxOWLObjectRendererImpl 不是公共接口的一部分,因此可能会被更改,因此最好编写自己的 OWLObjectRenderer 或其他方式以使 String 表示所需的公理。

【讨论】:

  • 太棒了!它也适用于我。现在我有另一个问题:因为不仅有一个包含焦点术语的假设,所以输出可能不是一个单一的。因此,如何对这些假设进行排序?我只是将假设放入一个字符串中,然后根据它们的长度对它们进行排序。那么,是否存在对这些假设进行排序的方法?像逻辑强度还是其他?我在问题描述中放了另一个假设更多的样本,焦点词可以设置为“跑步”
  • 这个问题是关于 Java 的,而不是 Jena 或 OWL-API 或 OWL。使用流 API。 OWLObjectComparable,因此您可以使用自然顺序对流进行排序。或提供您自己的Comparator。 RDF 本身不保证顺序,因此假设如果有多个&lt;c&gt; rdfs:subClassOf _:bx 语句,则未定义将拾取什么是正确的。由于您将信息保留为注释断言,因此在自定义比较器的情况下,您需要对注释进行排序。并按它们过滤。注意:注解不是保存信息的常用方法——通常使用数据属性断言。
  • 在响应中显示的代码中,公理列表已经排序(通过 OWLObject compareTo())并选择了第一个元素。如果您需要对所有结果执行相同的操作,只需使用流中的所有元素,而不是停在findFirst()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多