OWLAPI
目录基础知识开源库JENA简介OWLAPI简介工具protege简介基础知识知识图谱基础之RDF, RDFS与OWL通俗易懂开源库JENA简介A free and open source java framework for building Semantic Web and Linked Data applications.文档详细OWLAPI简介The OWL API is a java AP
目录
基础知识
知识图谱基础之RDF, RDFS与OWL 通俗易懂
OWL的基础知识, 譬如复杂类(Complex Class, unionOf, intersectionOf, complementOf)
OWL 本体构建指南 内容详细, 解释准确
RDF Formats
Extension | Language |
---|---|
.ttl | Turtle |
.nt | N-Triples |
.nq | N-Quads |
.trig | TriG |
.rdf | RDF/XML |
.owl | RDF/XML |
.jsonld | JSON-LD |
.trdf | RDF Thrift |
.rt | RDF Thrift |
.rj | RDF/JSON |
.trix | TriX |
开源库
JENA
简介
A free and open source java framework for building Semantic Web and Linked Data applications.
文档详细
OWLAPI
简介
The OWL API is a java API for creating, manipulating and serialising OWL Ontologies
文档少, 且老旧.使用起来难度挺大.
OWLAPI使用
- IRI
owlOntology.getOntologyID().getOntologyIRI()
result = {Present@8453} "Optional.of(https://brickschema.org/schema/1.1/Brick)"
reference = {IRI@8455} "https://brickschema.org/schema/1.1/Brick"
remainder = "Brick"
namespace = "https://brickschema.org/schema/1.1/"
IRI由reminder和namespace组成
- 导入ttl
OWLOntologyManager owlOntologyManager = OWLManager.createOWLOntologyManager();
OWLOntology owlOntology = owlOntologyManager.loadOntologyFromOntologyDocument(ttl.getInputStream());
- 获取class
升级到5.0版本之后, 获取OWLClass的接口更改为classesInSignature(), 而且此函数返回的是stream()流.
List<OWLClass> owlClasses = owlOntology.classesInSignature().collect(Collectors.toList());
- 获取OWLClass下的rdfs:labe
List<String> labels = owlOntology.annotationAssertionAxioms(owlClass.getIRI())
//get only the annotations with rdf Label property
.filter(axiom -> axiom.getProperty().getIRI().getIRIString().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI().getIRIString()))
.map(axiom -> axiom.getAnnotation())
.filter(annotation-> annotation.getValue() instanceof OWLLiteral)
.map(annotation -> (OWLLiteral) annotation.getValue())
.map(literal -> literal.getLiteral())
.collect(Collectors.toList());
-
Reasoner HermiT
简介:
HermiT is reasoner for ontologies written using the Web Ontology Language (OWL). Given an OWL file, HermiT can determine whether or not the ontology is consistent, identify subsumption relationships between classes, and much more.
版本配合:
OWLAPI | HermiT |
---|---|
5.1.0 | 1.3.8.510 |
安装:
(1) Maven
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>org.semanticweb.hermit</artifactId>
<version>1.3.8.510</version>
<type>bundle</type>
</dependency>
(2) Jar包安装
下载安装包, 在控制台输入以下命令进行安装, 前提是maven已安装
mvn install:install-file -Dfile=.\org.semanticweb.hermit-1.3.8.510.jar -DgroupId=net.sourceforge.owlapi -DartifactId=org.semanticweb.hermit -Dversion=1.3.8.510 -Dpackaging=jar
使用
(1) 获取OWLClass的subClasses
OWLReasonerFactory owlReasonerFactory = new ReasonerFactory();
OWLReasoner owlReasoner = owlReasonerFactory.createReasoner(owlOntology);
owlReasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
List<OWLClass> owlClasses = owlOntology.classesInSignature().collect(Collectors.toList());
owlClasses.forEach(owlClass -> {
owlReasoner.getSubClasses(owlClass, false).forEach(System.out::println);
});
工具
protege
简介
A free, open-source ontology editor and framework for building intellignet systems.
使用web工具导入Ontology,可以辅助理解知识图谱的概念.
更多推荐
所有评论(0)