SlideShare a Scribd company logo
1 of 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();
}

More Related Content

What's hot

Introduction to RDF
Introduction to RDFIntroduction to RDF
Introduction to RDFNarni Rajesh
 
SPARQL 사용법
SPARQL 사용법SPARQL 사용법
SPARQL 사용법홍수 허
 
Resource description framework
Resource description frameworkResource description framework
Resource description frameworkStanley Wang
 
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -Dongbum Kim
 
Introduction to Apache solr
Introduction to Apache solrIntroduction to Apache solr
Introduction to Apache solrKnoldus Inc.
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFSNilesh Wagmare
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialAdonisDamian
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkHùng Nguyễn Huy
 
온톨로지 & 규칙 추론 시스템
온톨로지 & 규칙 추론 시스템온톨로지 & 규칙 추론 시스템
온톨로지 & 규칙 추론 시스템Sang-Kyun Kim
 
FS_module_functions.pptx
FS_module_functions.pptxFS_module_functions.pptx
FS_module_functions.pptxBareen Shaikh
 
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
 
What’s New in Spring Data MongoDB
What’s New in Spring Data MongoDBWhat’s New in Spring Data MongoDB
What’s New in Spring Data MongoDBVMware Tanzu
 

What's hot (20)

Introduction to RDF
Introduction to RDFIntroduction to RDF
Introduction to RDF
 
SPARQL 사용법
SPARQL 사용법SPARQL 사용법
SPARQL 사용법
 
RDF, linked data and semantic web
RDF, linked data and semantic webRDF, linked data and semantic web
RDF, linked data and semantic web
 
Resource description framework
Resource description frameworkResource description framework
Resource description framework
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
 
Java and OWL
Java and OWLJava and OWL
Java and OWL
 
Introduction to Apache solr
Introduction to Apache solrIntroduction to Apache solr
Introduction to Apache solr
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorial
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
SHACL by example
SHACL by exampleSHACL by example
SHACL by example
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Expressjs
ExpressjsExpressjs
Expressjs
 
온톨로지 & 규칙 추론 시스템
온톨로지 & 규칙 추론 시스템온톨로지 & 규칙 추론 시스템
온톨로지 & 규칙 추론 시스템
 
FS_module_functions.pptx
FS_module_functions.pptxFS_module_functions.pptx
FS_module_functions.pptx
 
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
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Django
DjangoDjango
Django
 
What’s New in Spring Data MongoDB
What’s New in Spring Data MongoDBWhat’s New in Spring Data MongoDB
What’s New in Spring Data MongoDB
 

Viewers also liked

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
 

Viewers also liked (6)

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
 
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)
 

Similar to 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
 

Similar to 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
 

More from 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
 

More from 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
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

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(); }