具有短前缀的OWL API公理

时间:2017-02-27 17:19:21

标签: java owl owl-api

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 )

本体论当然可以定义更多的前缀(不仅仅是“葡萄酒”)

2 个答案:

答案 0 :(得分:0)

您需要使用前缀,例如以下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关键字,您可以使用带前缀的单词替换与其相关的网址。

答案 1 :(得分:0)

您所看到的是toString()值;这是出于调试目的,而不是用于进一步处理。

根据您希望实现的目标,您可能最好选择支持前缀的语言(例如,曼彻斯特OWL语法或功能语法),设置您希望使用的前缀并呈现公理:

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