Jena
Alex Genadinik
Shamod Lacoul
A Semantic Web framework
Jena API
ARQ/SPRQL
SDB/TDB
Inference
Jena RDF API
// some definitions
String personURI = "http://somewhere/JohnSmith";
String givenName = "John";
String family...
Jena Ontology API
// create the base model
String SOURCE = "http://www.eswc2006.org/technologies/ontology";
String NS = SO...
ARQ for SPARQL
String query = " PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
" PREFIX user: <http://www.switter.com/user#...
SDB
Store store = SDBFactory.connectStore("sdb.ttl") ;
Model model = SDBFactory.connectDefaultModel(store) ;
StmtIterator ...
TDB
TDB
// Direct way: Make a TDB-backed Jena model in the named directory.
String directory = "MyDatabases/DB1" ;
Model m...
Inference
Model schema = FileManager.get().loadModel("file:data/owlDemoSchema.owl");
Model data = FileManager.get().loadMo...
Thank you! Questions?
Jena framework
Upcoming SlideShare
Loading in …5
×

Jena framework

3,050
-1

Published on

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,050
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
75
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Jena framework

  1. 1. Jena Alex Genadinik Shamod Lacoul
  2. 2. A Semantic Web framework Jena API ARQ/SPRQL SDB/TDB Inference
  3. 3. Jena RDF API // some definitions String personURI = "http://somewhere/JohnSmith"; String givenName = "John"; String familyName = "Smith"; String fullName = givenName + " " + familyName; // create an empty Model Model model = ModelFactory.createDefaultModel(); // create the resource // and add the properties cascading style Resource johnSmith = model.createResource(personURI) .addProperty(VCARD.FN, fullName) .addProperty(VCARD.N, model.createResource() .addProperty(VCARD.Given, givenName) .addProperty(VCARD.Family, familyName));
  4. 4. Jena Ontology API // create the base model String SOURCE = "http://www.eswc2006.org/technologies/ontology"; String NS = SOURCE + "#"; OntModel base = ModelFactory.createOntologyModel( OWL_MEM ); base.read( SOURCE, "RDF/XML" ); // create the reasoning model using the base OntModel inf = ModelFactory.createOntologyModel( OWL_MEM_MICRO_RULE_INF, base ); // create a dummy paper for this example OntClass paper = base.getOntClass( NS + "Paper" ); Individual p1 = base.createIndividual( NS + "paper1", paper ); // list the asserted types for (Iterator i = p1.listRDFTypes(); i.hasNext(); ) { System.out.println( p1.getURI() + " is asserted in class " + i.next() ); } // list the inferred types p1 = inf.getIndividual( NS + "paper1" ); for (Iterator i = p1.listRDFTypes(); i.hasNext(); ) { System.out.println( p1.getURI() + " is inferred to be in class " + i.next() ); }
  5. 5. ARQ for SPARQL String query = " PREFIX foaf: <http://xmlns.com/foaf/0.1/> " + " PREFIX user: <http://www.switter.com/user#> " + " PREFIX twit: <http://www.twitter.com/twit#> " + " SELECT ?name ?screen_name WHERE " + "{ " + "user:me foaf:knows ?person . " + "?person foaf:name ?name . " + "?person twit:screen_name ?screen_name . " + "} "; Dataset ds = DatasetStore.create(store) ; QueryExecution qe = QueryExecutionFactory.create(query, ds) ;try { ResultSet rs = qe.execSelect(); ResultSetFormatter.outputAsXML(rs);} finally { qe.close() ; store.close(); }
  6. 6. SDB Store store = SDBFactory.connectStore("sdb.ttl") ; Model model = SDBFactory.connectDefaultModel(store) ; StmtIterator sIter = model.listStatements() ; for ( ; sIter.hasNext() ; ) { Statement stmt = sIter.nextStatement() ; System.out.println(stmt) ; } sIter.close() ; store.close() ;
  7. 7. TDB TDB // Direct way: Make a TDB-backed Jena model in the named directory. String directory = "MyDatabases/DB1" ; Model model = TDBFactory.createModel(directory) ; ... model.close() ;
  8. 8. Inference 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);
  9. 9. Thank you! Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×