SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Dr. Myungjin Lee
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
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
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
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/
Resource Description Framework
  a general method for conceptual description or
  modeling of information, especially web resources
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
Nodes and Triples
                 Statement
                                       Resource


      Resource                         Property




                             Literal




                                            Model
Interface Hierarchy
Core Classes
  What is a Model?
     one RDF graph which is represented by the Model
     interface


          Ontology
                                     Model
          (RDF Graph)




                                 Jena Programming
                                      Interface
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.
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"
How to make Model
Model model = ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open(“BadBoy.owl");
model.read(in, null, “RDF/XML”);
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)));
Interfaces related to nodes
  Resource Interface
     An RDF Resource


  Property Interface
     An RDF Property


  RDFNode Interface
     Interface covering RDF resources and literals
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
Resource and Property
  Methods
      Resource createResource(String uri)
      Property createProperty(String uriref)


Resource s = model.createResource(“…”);
Property p = ResourceFactory.createProperty(“…”);
Literal
  Un-typed Literal
      Literal createLiteral(String v, String language)
      Literal createLiteral(String v, boolean wellFormed)


Literal l1 = model.createLiteral("chat", "en")
Literal l2 = model.createLiteral("<em>chat</em>", true);
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
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
Interfaces related to triples
  Statement Interface
     represents a triple
     consists of Resource, Property, and RDFNode

  StmtIterator Interface
     a set of statements (triples)
Getting Triples
StmtIterator iter = model.listStatements();
while (iter.hasNext()) {
    Statement stmt      = iter.nextStatement();
    Resource subject    = stmt.getSubject();
    Property predicate = stmt.getPredicate();
    RDFNode   object    = stmt.getObject();
}
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);
}
Add a relation of resource
Resource husband =
model.createResource("http://iwec.yonsei.ac.kr/family#MyungjinLe
e");
Property marry =
model.createProperty("http://iwec.yonsei.ac.kr/family#hasWife");
Resource wife =
model.createResource("http://iwec.yonsei.ac.kr/family#YejinSon");
husband.addProperty(marry, wife);
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
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.
hasWife
                           Person
                                                                        inverseOf
type          subClassOf                subClassOf          type

                                                                   hasHusband
       Male                                  Female



       type                                          type




       Myungj               hasWife          Yejin
       in Lee                                Son
                           hasHusband
Jena OWL reasoners
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner,
model);
Property husband =
model.createProperty("http://www.semantics.kr/family#hasH
usband");
StmtIterator iterHusband = infmodel.listStatements(null,
husband, myungjin);
while (iterHusband.hasNext()) {
    Statement stmt = iterHusband.nextStatement();
    Resource subject = stmt.getSubject();
    Property predicate = stmt.getPredicate();
    RDFNode object = stmt.getObject();
    System.out.println(subject + " " + predicate + " " +
object);
}
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
family.rules

1. @prefix base: <http://www.semantics.kr/family#>.

2. [HappyWoman:
        (?x rdf:type base:Female),
        (base:MyungjinLee base:hasWife ?x)
               -> (?x rdf:type base:HappyWoman)]
Resource configuration = model.createResource();
configuration.addProperty
        (ReasonerVocabulary.PROPruleMode, "forward");
configuration.addProperty
        (ReasonerVocabulary.PROPruleSet, "family.rules");
Reasoner domainReasoner =
GenericRuleReasonerFactory.theInstance().create(configuration);
InfModel domaininfmodel =
ModelFactory.createInfModel(domainReasoner, infmodel);
StmtIterator happyIter =
domaininfmodel.listStatements(wife, type, (RDFNode) null);
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.
   }
family.sparql

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
PREFIX base: <http://www.semantics.kr/family#>

SELECT ?x
WHERE {
             ?x                       rdf:type         base:Female.
             base:MyungjinLee         base:hasWife     ?x.
}
try {
    // make a query string from SPARQL file
    FileReader fr = new FileReader("family.sparql");
    BufferedReader br = new BufferedReader(fr);
    StringBuffer queryString = new StringBuffer();
    String temp;
    while ((temp = br.readLine()) != null) {
        queryString.append(temp);
    }
    Query query = QueryFactory.create(queryString.toString());
    // create a object for query
    QueryExecution qexec = QueryExecutionFactory.create(query,
domaininfmodel);
        ResultSet results = qexec.execSelect(); // execute SPARQL query
        while(results.hasNext()) {
            QuerySolution soln = results.nextSolution();
            RDFNode r = soln.get("x"); // get a result
            System.out.println(r.toString());
        }
} catch (Exception e) {
    e.printStackTrace();
}

Weitere ähnliche Inhalte

Was ist angesagt?

Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLEmanuele Della Valle
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개Dongbum Kim
 
SHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data MudSHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data MudRichard Cyganiak
 
Understanding RDF: the Resource Description Framework in Context (1999)
Understanding RDF: the Resource Description Framework in Context  (1999)Understanding RDF: the Resource Description Framework in Context  (1999)
Understanding RDF: the Resource Description Framework in Context (1999)Dan Brickley
 
Semantic Web, Ontology, and Ontology Learning: Introduction
Semantic Web, Ontology, and Ontology Learning: IntroductionSemantic Web, Ontology, and Ontology Learning: Introduction
Semantic Web, Ontology, and Ontology Learning: IntroductionKent State University
 
Ontologies and semantic web
Ontologies and semantic webOntologies and semantic web
Ontologies and semantic webStanley Wang
 
Tutorial on Ontology editor: Protege
Tutorial on Ontology editor: Protege Tutorial on Ontology editor: Protege
Tutorial on Ontology editor: Protege Biswanath Dutta
 
RDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data MiningRDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data MiningPetar Ristoski
 
Towards an Open Research Knowledge Graph
Towards an Open Research Knowledge GraphTowards an Open Research Knowledge Graph
Towards an Open Research Knowledge GraphSören Auer
 
SPARQL 사용법
SPARQL 사용법SPARQL 사용법
SPARQL 사용법홍수 허
 
Querying Linked Data with SPARQL
Querying Linked Data with SPARQLQuerying Linked Data with SPARQL
Querying Linked Data with SPARQLOlaf Hartig
 
Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020Ontotext
 
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language Biswanath Dutta
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQLOpen Data Support
 
Introduction to the Data Web, DBpedia and the Life-cycle of Linked Data
Introduction to the Data Web, DBpedia and the Life-cycle of Linked DataIntroduction to the Data Web, DBpedia and the Life-cycle of Linked Data
Introduction to the Data Web, DBpedia and the Life-cycle of Linked DataSören Auer
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVCDzmitry Naskou
 
Resource description framework
Resource description frameworkResource description framework
Resource description frameworkStanley Wang
 

Was ist angesagt? (20)

Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
SHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data MudSHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data Mud
 
Understanding RDF: the Resource Description Framework in Context (1999)
Understanding RDF: the Resource Description Framework in Context  (1999)Understanding RDF: the Resource Description Framework in Context  (1999)
Understanding RDF: the Resource Description Framework in Context (1999)
 
Semantic Web, Ontology, and Ontology Learning: Introduction
Semantic Web, Ontology, and Ontology Learning: IntroductionSemantic Web, Ontology, and Ontology Learning: Introduction
Semantic Web, Ontology, and Ontology Learning: Introduction
 
Ontologies and semantic web
Ontologies and semantic webOntologies and semantic web
Ontologies and semantic web
 
Tutorial on Ontology editor: Protege
Tutorial on Ontology editor: Protege Tutorial on Ontology editor: Protege
Tutorial on Ontology editor: Protege
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
RDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data MiningRDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data Mining
 
Towards an Open Research Knowledge Graph
Towards an Open Research Knowledge GraphTowards an Open Research Knowledge Graph
Towards an Open Research Knowledge Graph
 
SPARQL 사용법
SPARQL 사용법SPARQL 사용법
SPARQL 사용법
 
Querying Linked Data with SPARQL
Querying Linked Data with SPARQLQuerying Linked Data with SPARQL
Querying Linked Data with SPARQL
 
Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020Property graph vs. RDF Triplestore comparison in 2020
Property graph vs. RDF Triplestore comparison in 2020
 
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQL
 
Introduction to the Data Web, DBpedia and the Life-cycle of Linked Data
Introduction to the Data Web, DBpedia and the Life-cycle of Linked DataIntroduction to the Data Web, DBpedia and the Life-cycle of Linked Data
Introduction to the Data Web, DBpedia and the Life-cycle of Linked Data
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Resource description framework
Resource description frameworkResource description framework
Resource description framework
 

Andere mochten auch

PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordeskgrandis
 
Face Recognition with OpenCV and scikit-learn
Face Recognition with OpenCV and scikit-learnFace Recognition with OpenCV and scikit-learn
Face Recognition with OpenCV and scikit-learnShiqiao Du
 
Face Recognition using OpenCV
Face Recognition using OpenCVFace Recognition using OpenCV
Face Recognition using OpenCVVasile Chelban
 
Semantic Web - Ontology 101
Semantic Web - Ontology 101Semantic Web - Ontology 101
Semantic Web - Ontology 101Luigi De Russis
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Luigi De Russis
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Luigi De Russis
 

Andere mochten auch (7)

PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
 
Face Recognition with OpenCV and scikit-learn
Face Recognition with OpenCV and scikit-learnFace Recognition with OpenCV and scikit-learn
Face Recognition with OpenCV and scikit-learn
 
Java and OWL
Java and OWLJava and OWL
Java and OWL
 
Face Recognition using OpenCV
Face Recognition using OpenCVFace Recognition using OpenCV
Face Recognition using OpenCV
 
Semantic Web - Ontology 101
Semantic Web - Ontology 101Semantic Web - Ontology 101
Semantic Web - Ontology 101
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)
 

Ähnlich wie Jena Programming

070517 Jena
070517 Jena070517 Jena
070517 Jenayuhana
 
RDF APIs for .NET Framework
RDF APIs for .NET FrameworkRDF APIs for .NET Framework
RDF APIs for .NET FrameworkAdriana Ivanciu
 
2009 Dils Flyweb
2009 Dils Flyweb2009 Dils Flyweb
2009 Dils FlywebJun Zhao
 
Sparql semantic information retrieval by
Sparql semantic information retrieval bySparql semantic information retrieval by
Sparql semantic information retrieval byIJNSA Journal
 
2008 11 13 Hcls Call
2008 11 13 Hcls Call2008 11 13 Hcls Call
2008 11 13 Hcls CallJun Zhao
 
Bio it 2005_rdf_workshop05
Bio it 2005_rdf_workshop05Bio it 2005_rdf_workshop05
Bio it 2005_rdf_workshop05Joanne Luciano
 
Semantic web
Semantic webSemantic web
Semantic webtariq1352
 
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIsJosef Petrák
 
SPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONS
SPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONSSPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONS
SPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONSIJNSA Journal
 
2010 03 Lodoxf Openflydata
2010 03 Lodoxf Openflydata2010 03 Lodoxf Openflydata
2010 03 Lodoxf OpenflydataJun Zhao
 
Rdf Processing On The Java Platform
Rdf Processing On The Java PlatformRdf Processing On The Java Platform
Rdf Processing On The Java Platformguestc1b16406
 
Hack U Barcelona 2011
Hack U Barcelona 2011Hack U Barcelona 2011
Hack U Barcelona 2011Peter Mika
 
Integrating a Domain Ontology Development Environment and an Ontology Search ...
Integrating a Domain Ontology Development Environment and an Ontology Search ...Integrating a Domain Ontology Development Environment and an Ontology Search ...
Integrating a Domain Ontology Development Environment and an Ontology Search ...Takeshi Morita
 
Java Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY DucatJava Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY DucatShri Prakash Pandey
 

Ähnlich wie Jena Programming (20)

070517 Jena
070517 Jena070517 Jena
070517 Jena
 
RDF APIs for .NET Framework
RDF APIs for .NET FrameworkRDF APIs for .NET Framework
RDF APIs for .NET Framework
 
2009 Dils Flyweb
2009 Dils Flyweb2009 Dils Flyweb
2009 Dils Flyweb
 
Sparql semantic information retrieval by
Sparql semantic information retrieval bySparql semantic information retrieval by
Sparql semantic information retrieval by
 
2008 11 13 Hcls Call
2008 11 13 Hcls Call2008 11 13 Hcls Call
2008 11 13 Hcls Call
 
Bio it 2005_rdf_workshop05
Bio it 2005_rdf_workshop05Bio it 2005_rdf_workshop05
Bio it 2005_rdf_workshop05
 
Semantic web
Semantic webSemantic web
Semantic web
 
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
 
SWT Lecture Session 2 - RDF
SWT Lecture Session 2 - RDFSWT Lecture Session 2 - RDF
SWT Lecture Session 2 - RDF
 
RDF and Java
RDF and JavaRDF and Java
RDF and Java
 
SPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONS
SPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONSSPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONS
SPARQL: SEMANTIC INFORMATION RETRIEVAL BY EMBEDDING PREPOSITIONS
 
2010 03 Lodoxf Openflydata
2010 03 Lodoxf Openflydata2010 03 Lodoxf Openflydata
2010 03 Lodoxf Openflydata
 
Rdf Processing On The Java Platform
Rdf Processing On The Java PlatformRdf Processing On The Java Platform
Rdf Processing On The Java Platform
 
Semantic web
Semantic web Semantic web
Semantic web
 
Hack U Barcelona 2011
Hack U Barcelona 2011Hack U Barcelona 2011
Hack U Barcelona 2011
 
RDF validation tutorial
RDF validation tutorialRDF validation tutorial
RDF validation tutorial
 
Integrating a Domain Ontology Development Environment and an Ontology Search ...
Integrating a Domain Ontology Development Environment and an Ontology Search ...Integrating a Domain Ontology Development Environment and an Ontology Search ...
Integrating a Domain Ontology Development Environment and an Ontology Search ...
 
Java Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY DucatJava Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY Ducat
 
Jpl presentation
Jpl presentationJpl presentation
Jpl presentation
 
Jpl presentation
Jpl presentationJpl presentation
Jpl presentation
 

Mehr von Myungjin Lee

지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)
지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)
지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)Myungjin Lee
 
JSP 프로그래밍 #05 HTML과 JSP
JSP 프로그래밍 #05 HTML과 JSPJSP 프로그래밍 #05 HTML과 JSP
JSP 프로그래밍 #05 HTML과 JSPMyungjin Lee
 
JSP 프로그래밍 #04 JSP 의 기본
JSP 프로그래밍 #04 JSP 의 기본JSP 프로그래밍 #04 JSP 의 기본
JSP 프로그래밍 #04 JSP 의 기본Myungjin Lee
 
JSP 프로그래밍 #03 서블릿
JSP 프로그래밍 #03 서블릿JSP 프로그래밍 #03 서블릿
JSP 프로그래밍 #03 서블릿Myungjin Lee
 
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기Myungjin Lee
 
JSP 프로그래밍 #01 웹 프로그래밍
JSP 프로그래밍 #01 웹 프로그래밍JSP 프로그래밍 #01 웹 프로그래밍
JSP 프로그래밍 #01 웹 프로그래밍Myungjin Lee
 
관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)
관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)
관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)Myungjin Lee
 
오픈 데이터와 인공지능
오픈 데이터와 인공지능오픈 데이터와 인공지능
오픈 데이터와 인공지능Myungjin Lee
 
법령 온톨로지의 구축 및 검색
법령 온톨로지의 구축 및 검색법령 온톨로지의 구축 및 검색
법령 온톨로지의 구축 및 검색Myungjin Lee
 
도서관과 Linked Data
도서관과 Linked Data도서관과 Linked Data
도서관과 Linked DataMyungjin Lee
 
공공데이터, 현재 우리는?
공공데이터, 현재 우리는?공공데이터, 현재 우리는?
공공데이터, 현재 우리는?Myungjin Lee
 
LODAC 2017 Linked Open Data Workshop
LODAC 2017 Linked Open Data WorkshopLODAC 2017 Linked Open Data Workshop
LODAC 2017 Linked Open Data WorkshopMyungjin Lee
 
Introduction of Deep Learning
Introduction of Deep LearningIntroduction of Deep Learning
Introduction of Deep LearningMyungjin Lee
 
쉽게 이해하는 LOD
쉽게 이해하는 LOD쉽게 이해하는 LOD
쉽게 이해하는 LODMyungjin Lee
 
서울시 열린데이터 광장 문화관광 분야 LOD 서비스
서울시 열린데이터 광장 문화관광 분야 LOD 서비스서울시 열린데이터 광장 문화관광 분야 LOD 서비스
서울시 열린데이터 광장 문화관광 분야 LOD 서비스Myungjin Lee
 
LOD(Linked Open Data) Recommendations
LOD(Linked Open Data) RecommendationsLOD(Linked Open Data) Recommendations
LOD(Linked Open Data) RecommendationsMyungjin Lee
 
Interlinking for Linked Data
Interlinking for Linked DataInterlinking for Linked Data
Interlinking for Linked DataMyungjin Lee
 
Linked Open Data Tutorial
Linked Open Data TutorialLinked Open Data Tutorial
Linked Open Data TutorialMyungjin Lee
 
Linked Data Usecases
Linked Data UsecasesLinked Data Usecases
Linked Data UsecasesMyungjin Lee
 
공공데이터와 Linked open data
공공데이터와 Linked open data공공데이터와 Linked open data
공공데이터와 Linked open dataMyungjin Lee
 

Mehr von Myungjin Lee (20)

지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)
지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)
지식그래프 개념과 활용방안 (Knowledge Graph - Introduction and Use Cases)
 
JSP 프로그래밍 #05 HTML과 JSP
JSP 프로그래밍 #05 HTML과 JSPJSP 프로그래밍 #05 HTML과 JSP
JSP 프로그래밍 #05 HTML과 JSP
 
JSP 프로그래밍 #04 JSP 의 기본
JSP 프로그래밍 #04 JSP 의 기본JSP 프로그래밍 #04 JSP 의 기본
JSP 프로그래밍 #04 JSP 의 기본
 
JSP 프로그래밍 #03 서블릿
JSP 프로그래밍 #03 서블릿JSP 프로그래밍 #03 서블릿
JSP 프로그래밍 #03 서블릿
 
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
 
JSP 프로그래밍 #01 웹 프로그래밍
JSP 프로그래밍 #01 웹 프로그래밍JSP 프로그래밍 #01 웹 프로그래밍
JSP 프로그래밍 #01 웹 프로그래밍
 
관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)
관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)
관광 지식베이스와 스마트 관광 서비스 (Knowledge base and Smart Tourism)
 
오픈 데이터와 인공지능
오픈 데이터와 인공지능오픈 데이터와 인공지능
오픈 데이터와 인공지능
 
법령 온톨로지의 구축 및 검색
법령 온톨로지의 구축 및 검색법령 온톨로지의 구축 및 검색
법령 온톨로지의 구축 및 검색
 
도서관과 Linked Data
도서관과 Linked Data도서관과 Linked Data
도서관과 Linked Data
 
공공데이터, 현재 우리는?
공공데이터, 현재 우리는?공공데이터, 현재 우리는?
공공데이터, 현재 우리는?
 
LODAC 2017 Linked Open Data Workshop
LODAC 2017 Linked Open Data WorkshopLODAC 2017 Linked Open Data Workshop
LODAC 2017 Linked Open Data Workshop
 
Introduction of Deep Learning
Introduction of Deep LearningIntroduction of Deep Learning
Introduction of Deep Learning
 
쉽게 이해하는 LOD
쉽게 이해하는 LOD쉽게 이해하는 LOD
쉽게 이해하는 LOD
 
서울시 열린데이터 광장 문화관광 분야 LOD 서비스
서울시 열린데이터 광장 문화관광 분야 LOD 서비스서울시 열린데이터 광장 문화관광 분야 LOD 서비스
서울시 열린데이터 광장 문화관광 분야 LOD 서비스
 
LOD(Linked Open Data) Recommendations
LOD(Linked Open Data) RecommendationsLOD(Linked Open Data) Recommendations
LOD(Linked Open Data) Recommendations
 
Interlinking for Linked Data
Interlinking for Linked DataInterlinking for Linked Data
Interlinking for Linked Data
 
Linked Open Data Tutorial
Linked Open Data TutorialLinked Open Data Tutorial
Linked Open Data Tutorial
 
Linked Data Usecases
Linked Data UsecasesLinked Data Usecases
Linked Data Usecases
 
공공데이터와 Linked open data
공공데이터와 Linked open data공공데이터와 Linked open data
공공데이터와 Linked open data
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Kürzlich hochgeladen (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Jena Programming

  • 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
  • 8. Nodes and Triples Statement Resource Resource Property Literal Model
  • 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(“…”);
  • 18. Literal Un-typed Literal Literal createLiteral(String v, String language) Literal createLiteral(String v, boolean wellFormed) Literal l1 = model.createLiteral("chat", "en") Literal l2 = model.createLiteral("<em>chat</em>", true);
  • 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)
  • 22. Getting Triples StmtIterator iter = model.listStatements(); while (iter.hasNext()) { Statement stmt = iter.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); }
  • 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); }
  • 24. Add a relation of resource Resource husband = model.createResource("http://iwec.yonsei.ac.kr/family#MyungjinLe e"); Property marry = model.createProperty("http://iwec.yonsei.ac.kr/family#hasWife"); Resource wife = model.createResource("http://iwec.yonsei.ac.kr/family#YejinSon"); husband.addProperty(marry, wife);
  • 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
  • 28. Jena OWL reasoners Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); InfModel infmodel = ModelFactory.createInfModel(reasoner, model); Property husband = model.createProperty("http://www.semantics.kr/family#hasH usband"); StmtIterator iterHusband = infmodel.listStatements(null, husband, myungjin); while (iterHusband.hasNext()) { Statement stmt = iterHusband.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); System.out.println(subject + " " + predicate + " " + object); }
  • 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
  • 30. family.rules 1. @prefix base: <http://www.semantics.kr/family#>. 2. [HappyWoman: (?x rdf:type base:Female), (base:MyungjinLee base:hasWife ?x) -> (?x rdf:type base:HappyWoman)]
  • 31. Resource configuration = model.createResource(); configuration.addProperty (ReasonerVocabulary.PROPruleMode, "forward"); configuration.addProperty (ReasonerVocabulary.PROPruleSet, "family.rules"); Reasoner domainReasoner = GenericRuleReasonerFactory.theInstance().create(configuration); InfModel domaininfmodel = ModelFactory.createInfModel(domainReasoner, infmodel); StmtIterator happyIter = domaininfmodel.listStatements(wife, type, (RDFNode) null);
  • 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. }
  • 33. family.sparql PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . PREFIX base: <http://www.semantics.kr/family#> SELECT ?x WHERE { ?x rdf:type base:Female. base:MyungjinLee base:hasWife ?x. }
  • 34. try { // make a query string from SPARQL file FileReader fr = new FileReader("family.sparql"); BufferedReader br = new BufferedReader(fr); StringBuffer queryString = new StringBuffer(); String temp; while ((temp = br.readLine()) != null) { queryString.append(temp); } Query query = QueryFactory.create(queryString.toString()); // create a object for query QueryExecution qexec = QueryExecutionFactory.create(query, domaininfmodel); ResultSet results = qexec.execSelect(); // execute SPARQL query while(results.hasNext()) { QuerySolution soln = results.nextSolution(); RDFNode r = soln.get("x"); // get a result System.out.println(r.toString()); } } catch (Exception e) { e.printStackTrace(); }