2. What is the Jena?
a Java framework for building Semantic Web
applications
A Java API for RDF
Developed by Brian McBride of HP
Derived from SiRPAC API
Can parse, create, and search RDF models
Easy to use
3. the Jena Framework includes:
an API for reading, processing and writing RDF data in XML, N
-triples and Turtle formats;
an ontology API for handling OWL and RDFS ontologies;
a rule-based inference engine for reasoning with RDF and OW
L data sources;
stores to allow large numbers of RDF triples to be efficiently s
tored on disk;
a query engine compliant with the latest SPARQL specification
servers to allow RDF data to be published to other application
s using a variety of protocols, including SPARQL
4. What can we do?
User interface and applications
Trust
Proof
Unifying logic
ARQ Ontologies: Rules:
Cryptography
Querying: OWL RIF/SWRL
SPARQL
Taxonomies: RDFS
Jena(ARP)
Data interchange: RDF
Syntax: XML
SDB + TDB
Identifiers: URI
Character set:
UNICODE
5. Install and Run Jena
Get package from
http://www.apache.org/dist/jena/
Unzip it
Setup environments (CLASSPATH)
Online documentation
Tutorial
http://jena.apache.org/documentation/index.html
API Doc
http://jena.apache.org/documentation/javadoc/
6. Resource Description Framework
a general method for conceptual description or
modeling of information, especially web resources
7. Graph and Model
Graph
a simpler Java API intended for extending Jena's
functionality
Model
a rich Java API with many convenience methods for Java
application developers
10. Core Classes
What is a Model?
one RDF graph which is represented by the Model
interface
Ontology
Model
(RDF Graph)
Jena Programming
Interface
11. Core Classes
ModelFactory Class
methods for creating standard kinds of Model
Model Interface
creating resources, properties and literals and the S
tatements
adding statements
removing statements from a model
querying a model and set operations for combining
models.
12. How to make Model
read Methods
Model read(String url, String base, String lang)
Model read(InputStream in, String base, String lang)
Model read(Reader reader, String base, String lang)
Parameters
base - the base uri to be used when converting relative
URI's to absolute URI's
lang - "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and
"N3"
13. How to make Model
Model model = ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open(“BadBoy.owl");
model.read(in, null, “RDF/XML”);
14. How to write Model
write Methods
Model write(OutputStream out, String lang, String base)
Model write(Writer writer, String lang, String base)
model.write(System.out);
model.write(System.out, "N-TRIPLE");
String fn = “temp/test.xml”;
model.write(new PrintWriter(new FileOutputStream(fn)));
15. Interfaces related to nodes
Resource Interface
An RDF Resource
Property Interface
An RDF Property
RDFNode Interface
Interface covering RDF resources and literals
16. How to create nodes
from Model Interface
to create new nodes whose model is this model
from ResourceFactory Class
to create resources and properties are not associat
ed with a user-modifiable model
17. Resource and Property
Methods
Resource createResource(String uri)
Property createProperty(String uriref)
Resource s = model.createResource(“…”);
Property p = ResourceFactory.createProperty(“…”);
19. Literal
Typed Literal
Literal createTypedLiteral(Object value)
Literal l = model.createTypedLiteral(new Integer(25));
Java class xsd type Java class xsd type
Float float Byte byte
Double double BigInteger integer
Integer int BigDecimal decimal
Long long Boolean Boolean
Short short String string
20. RDF Triple and Statement Interface
RDF Triple (Statement)
arc in an RDF Model
asserts a fact about a resource
consists of subject, predicate, and object
Triple
Subject Predicate Object
Resource Property RDFNode Jena Programming
Interface
Statement
21. Interfaces related to triples
Statement Interface
represents a triple
consists of Resource, Property, and RDFNode
StmtIterator Interface
a set of statements (triples)
23. To list the ‘selected’ statements in the Model
// making nodes for query
Resource husband =
model.createResource("http://iwec.yonsei.ac.kr/family#MyungjinLee");
Property type =
model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
// querying a model
StmtIterator iter = model.listStatements(husband, type, (RDFNode) null);
while (iter.hasNext()) {
Statement stmt = iter.nextStatement();
Resource subject = stmt.getSubject();
Property predicate = stmt.getPredicate();
RDFNode object = stmt.getObject();
System.out.println(subject + " " + predicate + " " + object);
}
25. Ontologies and reasoning
to derive additional truths about the concepts
Jena2 inference subsystem
to allow a range of inference engines or reasoners to be
plugged into Jena
http://jena.sourceforge.net/inference/index.html
26. 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.
DAML micro reasoner
Used internally to enable the legacy DAML API to provide minimal (RDFS scale)
inferencing.
Generic rule reasoner
A rule based reasoner that supports user defined rules. Forward chaining,
tabled backward chaining and hybrid execution strategies are supported.
27. hasWife
Person
inverseOf
type subClassOf subClassOf type
hasHusband
Male Female
type type
Myungj hasWife Yejin
in Lee Son
hasHusband
29. If someone's husband is Myungjin Lee,
she is a happy woman.
subClassOf Happy
Person
Woman
subClassOf subClassOf
Male Female
type
type type
Myungj hasWife Yejin
in Lee Son
32. SPARQL(SPARQL Protocol and RDF Query Language)
an RDF query language, that is, a query language for
databases
to retrieve and manipulate data stored in Resource
Description Framework format
Simple Example
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?email
WHERE {
?person rdf:type
foaf:Person.
?person foaf:name ?name.
?person foaf:mbox ?email.
}