1 / 29

Jena

Jena. a introduction. Semantic Web Tools. Jena - Background.

dylan
Télécharger la présentation

Jena

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Jena a introduction Semantic Web Tools

  2. Jena - Background 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.

  3. Introduction 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.

  4. Architecture

  5. Jena Interfaces and Pluggable API 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. https://github.com/shellac/java-rdfa

  6. Parsers and Writers 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

  7. Parsers and Writers example http://www.w3.org/2001/sw/grddl-wg/td/hCardFabien-RDFa.html

  8. Parsers and Writers example Here we read an RDFa document and write out in N3 notation.

  9. RDF API 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.

  10. RDF API - continued

  11. Ontologies 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)

  12. Ontology Api: Creating RDFS inference model 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: 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

  13. 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 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.

  14. Ontology API (RDFS - schema) @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.

  15. Ontology API (RDF data) @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 .

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

  17. Inference API - Reasoners 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.

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

  19. Fuseki 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.

  20. Store API • 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.

  21. Querying a Database 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

  22. Querying a persistent store Some sample code using the MySQL JDBC database connector to build a model from an MySQL relational database http://www.ibm.com/developerworks/xml/library/j-jena/

  23. Protégé 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.

  24. JenaBean 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.

  25. JenaBean 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

  26. JenaBean 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.

  27. D2RQ 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.

  28. 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.

  29. Jena Summary 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.

More Related