29
Jena a introduction Semantic Web Tools

Jena

  • Upload
    dylan

  • View
    58

  • Download
    0

Embed Size (px)

DESCRIPTION

Jena. a introduction. Semantic Web Tools. Jena - Background. - PowerPoint PPT Presentation

Citation preview

Page 1: Jena

Jenaa introduction

Semantic Web Tools

Page 2: Jena

Originally devised by HP Labs in Bristol, it was developed by Brian McBride of Hewlett-Packard and was derived from the SiRPAC API which offered only a command line interface. The framework is open-source and is offered under the BSD license.

Jena - Background

Page 3: Jena

Jena is built on java and gives the semantic web developers an assortment of tools at his or her disposal.

Vast use of interfaces allow developers to extend Jena’s functionality by using the plugin interface.

Introduction

Page 4: Jena

Architecture

Page 5: Jena

Here we plug in a RFDa reader that allows Jena to parse the extracted RDF into a model.

This works as it conforms to a Jena interface and hence extends theramework.

Jena Interfaces and Pluggable API

https://github.com/shellac/java-rdfa

Page 6: Jena

We have just shown how to extend a parser to create a model. Here we can read and write to an stream via

• RDF/XML• RDF/XML-ABBREV• N-TRIPLE• N3 - Notation3• TTL or Turtle

Parsers and Writers

Page 7: Jena

Parsers and Writers example

http://www.w3.org/2001/sw/grddl-wg/td/hCardFabien-RDFa.html

Page 8: Jena

Parsers and Writers example

Here we read an RDFa document and write out in N3 notation.

Page 9: Jena

Jena manipulates RDF data in directed graph structures also called models. The RDF API is extendable to include reasoners to allow for inference of extended RDF data in a newly created model.

RDF API

Page 10: Jena

RDF API - continued

Page 11: Jena

Supported in Jena -• Transitive• DAML + OIL• RDFS• General Rule Based• OWL Full(Limits) (only as an

external)• OWL Lite (partially

implemented)• OWL Micro (one of the partial

implementations)

Ontologies

Page 12: Jena

The following code shows loading some data and a schema from disk then how simple it is to create an inference model in Jena that could be interrogated by a reasoner:

Ontology Api: Creating RDFS inference model

Model schema = FileManager.get().loadModel("file:data/rdfsDemoSchema.rdf");Model data = FileManager.get().loadModel("file:data/rdfsDemoData.rdf");InfModel infmodel = ModelFactory.createRDFSModel(schema, data);

http://openjena.org/inference/#rdfs

Page 13: Jena

Where an RDFS inference model only requires the schema and data an OWL inference model needs a reasoner which in turn uses the OWL schema.

Ontology Api: Creating an OWL inference model

Model schema = FileManager.get().loadModel("file:data/owlDemoSchema.owl");Model data = FileManager.get().loadModel("file:data/owlDemoData.rdf");Reasoner reasoner = ReasonerRegistry.getOWLReasoner();reasoner = reasoner.bindSchema(schema);InfModel infmodel = ModelFactory.createInfModel(reasoner, data);

http://openjena.org/inference/#owl

Page 14: Jena

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .@prefix :

<http://dig.csail.mit.edu/2010/LinkedData/testdata/family#> .

:Mammal rdf:type rdfs:Class.:Person rdfs:subClassOf :Mammal.:Male rdfs:subClassOf :Person.:Female rdfs:subClassOf :Person.

:parent rdf:type rdf:Property.

:mother rdfs:subPropertyOf :parent; rdfs:range :Female; rdfs:domain :Person.

:father rdfs:subPropertyOf :parent; rdfs:range :Male; rdfs:domain :Person.

Ontology API (RDFS - schema)

Page 15: Jena

@prefix fam: <http://dig.csail.mit.edu/2010/LinkedData/testdata/family#> .@prefix : <http://dig.csail.mit.edu/2010/LinkedData/testdata/family_data#> .

:Mary a fam:Mammal .:Mary a fam:Female .:Frank a fam:Male .

Ontology API (RDF data)

Page 16: Jena

Below we look at build an inferred RDFS model and show the results specific to our inference about the resource 'Male'

Ontology API

Page 17: Jena

Jena allows pluggable or standard reasoners to extend its graph of connected resources or models.

Using the reasoners, additional RDF data is added to give return an inferred model.

Inference API - Reasoners

Page 18: Jena

SPARQL implementation in Jena resembles a striking similarity with that of the JDBC API.

SPARQL API

Page 19: Jena

A REST style SPARQL web service. SPARQL 1.1 queries can be called over the HTTP protocol.

Uses lightweight Jetty as a Web Servlet container. There are plans to create a war archive to allow other servlet engines to be able to host Fuseki.

Fuseki

Page 20: Jena

• TDB - a ACID compliant dedicated triple store written in Java that includes an inbuilt query optimiser.

• Memory - a volatile store.• SDB - an adapter library that allows for

RDF data to be persisted to a conventional relational database.

• Custom - custom implementations can be created to store triples such as text files or some other binary format.

Store API

Page 21: Jena

Querying a database in Jena is very similar to querying a regular relational database in java, we need a database connection with which to run queries and update the database. Due to the modular design of Java we

are free to use whatever connector that will suit our data source

Querying a Database

Page 22: Jena

Some sample code using the MySQL JDBC database connector to build a model from an MySQL relational database

Querying a persistent store

http://www.ibm.com/developerworks/xml/library/j-jena/

Page 23: Jena

Protégé-OWL has always had a close relationship with Jena.

The Jena ARP parser is still used in the Protégé-OWL parser, and various other services such as species validation and data type handling have been reused from Jena.

Protégé

Page 24: Jena

A library which aims to simplify the process of creating rdf data. Jenabean attempts to resolve the following Jena pain points

• You need to create unique URI’s for every entity.

• You must specify the type of each primitive value.

• Properties must be created for each bean property.

JenaBean

Page 25: Jena

Three annotations to help describe RDF data from Java Beans.

• @Id specifies unique field• @Namespace provides a domain• @RdfProperty maps java properties

to RDF properties

JenaBean

Page 26: Jena

Bean2RDF or RDF2Bean can be used to parse and write. These are wrapper classes around the Jena library.

By annotating objects/beans data can be retrieved from any source and have RDF data added. This allows for flexibility when using in conjunction with legacy data stores.

JenaBean

Page 27: Jena

Provides access to relational databases as RDF graphs. This allows users to publish linked data to the web and has the ability to be queried via SPARQL.

D2RQ includes a mapping interface to help convert/translate relational data into RDF.

D2RQ

Page 28: Jena

D2RQ overview• Mapping files are

read by the D2RQ engine that converts relational database data into RDF format.

• D2R server then provides an interface for presenting or querying of data.

Page 29: Jena

Provides a fine framework for creating semantic web applications. It serves as a base to allow for other libraries extend its capabilities allowing developers to keep up with changes of the various protocols.

In order to fully utilise Jena in a web app we can use tools such as Protege to design schema's for inference and then have this stored for use with Jena's Ontology.

Jena Summary