apache jena 架构 Inference api sub system Manipulating SPARQL using ARQ

jena arachitecture

RDF API: 查询rdf triples,graph。支持对资源的增删查改。资源的常用表示形式

  • resource: RDF source们通常是url或者anonymous
  • literal: data values(数字,字符串等)
  • Statement: RDF triple
  • Model: whole graph

rdf graph通过interface graph进行储存,应该在store api level。实现这个接口,底层的存储介质和存储细节就不需要考虑了。

jena的语义层和储存层是分离的,inference api这一层主要处理语义相关的东西(通过RDF,RDFS和 OWL等)。他同时支持build in rule和exteranl reasoner。

sparql apl主要负责查询

ontology api支持RDFS和owl,负责语义相关的东西。


代码中ARQDatasetGraphKG中同时包含graph和schemagraph,graph是真正的数据,而schema graph作用是类型推断语义推断相关的东西。

Inference api sub system

reasoner overview

application 通过modelfactory来访问inference层。modelfactory将数据和多个reasoner结合在一起生成一个新的model。对于这个model的query会返回基于reasoner推断出的数据结果

model实现了ModelGraphInterface,所以可以getGraph。Ontology API通过OntModel可以方便的链接reasoner,RDF API通过infModel来访问和控制graph

reasoner api通过bindSchema来绑定schema 或ontology data,通过bind来绑定数据(一个或多个图)。

reasoner list:

  • Transitive reasoner: Provides support for storing and traversing class and property lattices. This implements just the transitive and reflexive properties of rdfs:subPropertyOf and rdfs:subClassOf.
  • RDFS rule reasoner: Implements a configurable subset of the RDFS entailments.
  • OWL, OWL Mini, OWL Micro Reasoners: A set of useful but incomplete implementation of the OWL/Lite subset of the OWL/Full language.
  • Generic rule reasoner: A rule based reasoner that supports user defined rules. Forward chaining, tabled backward chaining and hybrid execution strategies are supported.

Manipulating SPARQL using ARQ

SPARQL会在处理时被翻译,一种是语法(syntax)层面的(query and element),一种是代数(algebra)层面的(操作)。

举个简单的例子

1
2
3
4
5
6
7
8
9
10
SELECT ?s { ?s <http://example.com/val> ?val . FILTER ( ?val < 20 ) }
syntax:
(GROUP (PATTERN ( ?s <http://example.com/val> ?val )) (FILTER ( < ?val 20 ) ))
algebra:
(base <file:///...>
(project (?s)
(filter (< ?val 20)
(bgp (triple ?s <http://example.com/val> ?val)))))

一般情况下sparql都会被翻译成algebra的形式,然后执行得到结果。


本文采用创作共用保留署名-非商业-禁止演绎4.0国际许可证,欢迎转载,但转载请注明来自http://thousandhu.github.io,并保持转载后文章内容的完整。本人保留所有版权相关权利。

本文链接:http://thousandhu.github.io/2016/04/15/apache-jena-架构/