Jena 101
From Tetherless World Wiki
Contents |
Jena Introduction
The content in this section is mainly based on Jena Home Page
A few facts about jena
- Jena is a JAVA toolkit for Semantic Web applications
- parse, validate and write RDF documents in various formats
- RDF data access API (in-memory and database backend)
- support SPARQL query
- support RDFS reasoning and some kinds of OWL reasoning
- Jena is open source maintained by HP Labs
how to install
- install JAVA, e.g. sun J2SE 1.5
- [optional] download and install eclipse IDE if you prefer GUI JAVA programming
- download jena most recent release (v2.5.4 as of Oct 2007) from http://jena.sourceforge.net/downloads.html
- build a java project and include all libs under JENAHOME/lib in your java classpath.
Jena programming basics
An Introduction to RDF and the Jena RDF API
- Model, Statement, Resource, Literal, URIResource, Property
- "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "N3"
- read, write, query, createDefaultModel, setNsPrefix
read write listStatement listSubjectWithProperty
- xml prolog, character encoding (mainly based on Sun J2SE)
- override RDFReader to intercept parsing errors
Ontology and Inference
- create ontology model
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM ); setProcessImports( false )
- OntResoure, OntClass, OntProperty
- Caching
setCacheModels( boolean caching ) OntModel m = ModelFactory.createOntologyModel(); OntDocumentManager dm = m.getDocumentManager(); dm.addAltEntry( "http://www.xfront.com/owl/ontologies/camera/", "file:" + JENA + "src-examples/data/camera.owl" ); m.read( "http://www.xfront.com/owl/ontologies/camera/" );
- validation (OWL validation may take longer)
Model data = FileManager.get().loadModel(fname);
InfModel infmodel = ModelFactory.createRDFSModel(data);
ValidityReport validity = infmodel.validate();
if (validity.isValid()) {
System.out.println("OK");
} else {
...
- variations of RDFS and OWL Inference
- Advanced: rule based inference, inference models
advanced topics
Exercises
RDF Syntax converter
- translate from/to RDF/XML, N3, NTriples, Turtle
- make it an online service
- [optional] render parsing errors if the input file was not correct
- [optional] compare it with at least one RDF tool other than Jena
RDF graph summary
- summarize an RDF graph, e.g. "how many node, arc, and degree distribution of node"
- scalability test
OWL ontology summary
- summarize an RDF graph using RDFS/OWL inference, e.g. "given an RDF graph, list classes, properties, and instances, and show how many triples were used to describe each of them"
- render an ontology and its summary in human readable manner (e.g. text/html)
RDF loader
- load an RDF graph from file or URL, print as much as possible metadata
- generate scalability performance report on loading RDF data, show statistics and bottleneck
- [optional] compare it with at least one RDF tool other than Jena
OWL form generator
- generate a HTML form for a given class using a given RDF graph consisting both ontology and instance data
- if the form is a property-value sheet, try to fill with applicable properties and property-values (maybe in drop list)
- you may use ontology specification to generate the form, or use the usage examples from similar instance data
