【问题标题】:OWL API axioms with short prefixes带有短前缀的 OWL API 公理
【发布时间】:2017-02-27 17:19:20
【问题描述】:

Java 中的 OWL API 通过以下方式提供了一组公理:

domainOntology.getAxioms()

默认情况下,所有公理都有长前缀,例如:

ObjectPropertyAssertion(<http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn> <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TexasRegion> <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#USRegion>) 

如何将公理转换为带有短前缀的公理,例如:

ObjectPropertyAssertion( wine:locatedIn wine:TexasRegion wine:USRegion )

本体当然可以定义更多的前缀(不仅仅是例如“wine”)

【问题讨论】:

    标签: java owl owl-api


    【解决方案1】:

    您看到的是toString() 值;这是为了调试目的,而不是为了进一步处理。

    根据您想要实现的具体目标,您最好选择一种支持前缀的语言(例如 Manchester OWL 语法或函数式语法),设置您希望使用的前缀并呈现公理:

    FunctionalSyntaxDocumentFormat format=new FunctionalSyntaxDocumentFormat();
    format.setPrefix("ont", "http://test.com/ontology");
    ontology.saveOntology(format, System.out);
    

    【讨论】:

    • 我认为我的答案在您的回复中。您能否告诉我如何以短前缀形式显示本体中的任何公理,例如ObjectPropertyRange(食物:hasFood 食物:EdibleThing)。我不想修改本体原始前缀(format.setPrefix)
    • 我展示的代码并没有修改本体的原始格式。调用 save 只是在标准输出上显示本体。如果您希望单独显示公理,您可以创建一个仅包含一个公理的新本体,或者查看 ToStringRenderer 以修改默认 toString()
    • 我更新了 OWL Api 来检查它。在 ontology.saveOntology 中的代码中的“本体”是什么类型?不过,我认为这段代码不会缩短原始前缀
    • OWLOntology - 使用 OWLOntologyManager 创建,然后使用 OWLManager 创建。
    • 我无法使 FunctionalSyntaxDocumentFormat(和您的代码)工作。我正在使用 OWLFunctionalSyntaxOntologyFormat。
    【解决方案2】:

    您需要使用前缀,例如以下 SPARQL 查询:

    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    select * where {
    SERVICE <http://it.dbpedia.org/sparql/> {
        SELECT * where {
           ?value rdfs:label "Personaggi dei fumetti"@it .
           ?title <http://purl.org/dc/terms/subject> ?value . 
           OPTIONAL {?title <http://dbpedia.org/ontology/firstAppearance> ?start_date .   
       }
           OPTIONAL {?title <http://dbpedia.org/ontology/author> ?author . }
           OPTIONAL {?title <http://it.dbpedia.org/property/paese> ?country .} 
           OPTIONAL {?title <http://it.dbpedia.org/property/sesso> ?gender .}  
           OPTIONAL {?title <http://it.dbpedia.org/property/dataInizio> ?date .}
       }
    }
    }
    

    在设置查询时使用 PREFIX 关键字可以让您使用前缀词替换它所涉及的 URL。

    【讨论】:

    • 当然,我知道这一点。我要求通过 OWL API 从 Java 代码获取短前缀。
    • @Annabelle 好吧,不知道 Java API,我觉得这对你有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 2021-04-05
    • 1970-01-01
    • 1970-01-01
    • 2017-05-04
    相关资源
    最近更新 更多