【发布时间】:2019-08-23 10:49:59
【问题描述】:
我正在尝试使用 OWL API 从 Jena 模型加载本体,但大多数公理都显示为注释。
Turtle 中的本体如下图所示。我使用 Jena 模型来存储它。 注意:下面的答案中提到的本体不正确
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://example.com/minimalDecoupling>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "minimal decoupling" .
<http://example.com/frequency>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "frequency" .
<http://example.com/voltage>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "Voltage" .
<http://example.com/powerConsumed>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "power consumed" .
<http://example.com/installation>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "installation" .
<http://example.com/Device>
a "http://www.w3.org/2002/07/owl#Class" ;
rdfs:label "device" .
<http://example.com/dimension>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "dimension" .
<http://example.com/>
a "http://www.w3.org/2002/07/owl#Ontology" .
假设上述本体存储在Jena模型ontologyGraph中,我使用下面的代码将Jena模型加载为OWL本体。
OWLOntology ontology = ontologyManager.
loadOntologyFromOntologyDocument
(new ByteArrayInputStream(Ontology.toTurtle(ontologyGraph).getBytes()));
toTurtle 方法如下所示:
public static String toTurtle(Model ontologyGraph){
StringWriter out = new StringWriter();
ontologyGraph.write(out,"TTL");
return out.toString();
}
然而,正如我们在下面的输出中看到的,来自本体的公理出现在注解公理:
Ontology(OntologyID(Anonymous-2)) [公理:15 逻辑公理:0] 首先 20 个公理:{AnnotationAssertion(rdfs:label http://example.com/powerConsumed“功耗”) AnnotationAssertion(rdfs:label http://example.com/minimalDecoupling "最小解耦") AnnotationAssertion(rdf:type http://example.com/ "http://www.w3.org/2002/07/owl#Ontology") AnnotationAssertion(rdfs:label http://example.com/dimension “维度”)AnnotationAssertion(rdf:type http://example.com/dimension "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdf:type http://example.com/voltage "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdf:type http://example.com/Device "http://www.w3.org/2002/07/owl#Class") AnnotationAssertion(rdfs:label http://example.com/installation“安装”) AnnotationAssertion(rdfs:label http://example.com/voltage "电压") AnnotationAssertion(rdf:type http://example.com/minimalDecoupling "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdf:type http://example.com/frequency "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdfs:label http://example.com/Device "device") AnnotationAssertion(rdf:type http://example.com/powerConsumed "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdfs:label http://example.com/frequency “频率”)注释断言(rdf:类型 http://example.com/installation "http://www.w3.org/2002/07/owl#DatatypeProperty") }
我的问题是:
- 为什么所有公理都显示为注释?
- 是否可以使用 OWL API 直接将 Jena 模型加载为 OWL 本体而无需通过 Turtle?
【问题讨论】:
标签: jena owl-api turtle-rdf