简体   繁体   English

JENA API 是否支持 OWL 2?

[英]Does JENA API support OWL 2?

May I know if Apahe JENA supports OWL 2 syntax in Java?我可以知道 Apahe JENA 是否支持 Java 中的 OWL 2 语法? It does mentioned that in the documentation ( https://jena.apache.org/documentation/ontology/ ) it only provide limited cardinality restrictions.它确实提到在文档( https://jena.apache.org/documentation/ontology/ )中它只提供有限的基数限制。 I would like to confirm this from the experts.我想从专家那里确认这一点。

Apache Jena does not support OWL2, only OWL11 through org.apache.jena.ontology.OntModel interface.阿帕奇耶拿支持OWL2,只有通过OWL11 org.apache.jena.ontology.OntModel接口。 See also documentation .另请参阅文档

But you still can work with OWL2 in Jena using some external jena-based APIs and tools, eg ONT-API , that is OWL-API -api( v5 ) impl over Jena.但是您仍然可以使用一些基于 jena 的外部 API 和工具(例如ONT-API ,即OWL-API -api( v5 ) impl over Jena 在 Jena 中使用 OWL2。

In ONT-API there are two main OWL2 view of data, which encapsulate the same RDF Graph: com.github.owlcs.ontapi.jena.model.OntModel and com.github.owlcs.ontapi.Ontology ( in older versions (ONT-API: v1.xx ) these classes have names ru.avicomp.ontapi.jena.model.OntGraphModel and ru.avicomp.ontapi.OntologyModel respectively ).在 ONT-API 中有两个主要的 OWL2 数据视图,它们封装了相同的 RDF 图: com.github.owlcs.ontapi.jena.model.OntModelcom.github.owlcs.ontapi.Ontology在旧版本中(ONT- API:v1.xx)这些类有名字ru.avicomp.ontapi.jena.model.OntGraphModelru.avicomp.ontapi.OntologyModel分别)。

The com.github.owlcs.ontapi.jena.model.OntModel view is a full analogue of Jena org.apache.jena.ontology.OntModel , it is the facility to work with triples. com.github.owlcs.ontapi.jena.model.OntModel视图完全类似于 Jena org.apache.jena.ontology.OntModel ,它是处理三元组的工具。 And the com.github.owlcs.ontapi.Ontology view is an extended org.semanticweb.owlapi.model.OWLOntology , the facility to work with axiomatic data, that is backed by the com.github.owlcs.ontapi.jena.model.OntModel view and vice-versa. com.github.owlcs.ontapi.Ontology视图是一个扩展的org.semanticweb.owlapi.model.OWLOntology ,它是处理公理数据的工具,由com.github.owlcs.ontapi.jena.model.OntModel支持com.github.owlcs.ontapi.jena.model.OntModel视图,反之亦然。

For example, the following snippet:例如,以下代码段:

    String uri = "https://stackoverflow.com/questions/54049750";
    String ns = uri + "#";
    OntModel m = OntModelFactory.createModel()
            .setNsPrefixes(OntModelFactory.STANDARD).setNsPrefix("q", ns);
    m.setID(uri);
    OntClass c = m.createOntClass(ns + "c");
    OntObjectProperty p = m.createObjectProperty(ns + "p");
    OntIndividual i = c.createIndividual(ns + "i");
    m.createObjectComplementOf(m.createObjectUnionOf(c, m.getOWLThing(),
            m.createObjectSomeValuesFrom(p, m.createObjectOneOf(i))));
    m.write(System.out, "ttl");

will produce the following ontology:将产生以下本体:

@prefix q:     <https://stackoverflow.com/questions/54049750#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<https://stackoverflow.com/questions/54049750>
        a       owl:Ontology .

q:c     a       owl:Class .

q:p     a       owl:ObjectProperty .

q:i     a       owl:NamedIndividual , q:c .

[ a                 owl:Class ;
  owl:complementOf  [ a            owl:Class ;
                      owl:unionOf  ( q:c owl:Thing
                                     [ a                   owl:Restriction ;
                                       owl:onProperty      q:p ;
                                       owl:someValuesFrom  [ a          owl:Class ;
                                                             owl:oneOf  ( q:i )
                                                           ]
                                     ]
                                   )
                    ]
] .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM