1 Knowledge Representation XI – IKT437 Knowledge Representation XI – IKT437 Part I RDF Jan Pettersen Nytun, UiA Apache Jena.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 10 API Review; Where Next.
Advertisements

Dr. Leo Obrst MITRE Information Semantics Information Discovery & Understanding Command & Control Center February 6, 2014February 6, 2014February 6, 2014.
Alexandra Cristea & Matthew Yau 1.
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
Language (Formalisms) For Ontology Building Neda Alipanah 22 October 2012.
Master Informatique 1 Semantic Technologies Part 4Jena Werner Nutt.
RDF Tutorial.
JENA –A SEMANTIC WEB TOOL by Ranjani Sankaran & krishna Priyanka Chebrolu.
Jena Sparql 4/11/2017.
Progress Update Semantic Web, Ontology Integration, and Web Query Seminar Department of Computing David George.
Triple Stores
Semantic Web Tools Vagan Terziyan Department of Mathematical Information Technology, University of Jyvaskyla ;
Semantic Web Course Introduction Vagan Terziyan Department of Mathematical Information Technology, University of Jyvaskyla ;
Jena --- A Java API for RDF Jing deng CSCI 7818 Web Technologies Computer Science Department University of Colorado at Boulder Wednesday, October 31, 2001.
Internet Technologies1 RDF Bibliography: “XML How To Program” by Deitel, Deitel, Nieto, Lin and Sadhu. “XML Bible” by Elliotte Rusty Harold. HP’s Jena.
Internet Technologies 1 Master of Information System Management Internet Technologies The Resource Description Framework (RDF)
RDF: Building Block for the Semantic Web Jim Ellenberger UCCS CS5260 Spring 2011.
Jena 4/17/2017.
Using Java in Linked Data Applications Fuming Shih Oct 12.
Triple Stores.
What Can Do for You! Fabian Christ
Example: Jena and Fuseki
TOOLS FOR LLD Vocabularies, linking, and application programming.
Java: Chapter 1 Computer Systems Computer Programming II.
Entity Recognition via Querying DBpedia ElShaimaa Ali.
Logics for Data and Knowledge Representation
The Jena RDF Framework Konstantinos Tzonas. Contents What is Jena Capabilities of Jena Basic notions RDF concepts in Jena Persistence Ontology management.
Master Informatique 1 Semantic Technologies Part 11Direct Mapping Werner Nutt.
 Open source RDF framework in Java.  Supports RDF Schema inferencing and querying.  Supports SPARQL 1.1 query, update, federated query.
Presentation : Konstantinos Kanaris.  What is Jena?  Usage of Jena  Main Concepts  Main Components  Storage Models  OWL API  RDF API  Reasoning.
Developing “Geo” Ontology Layers for Web Query Faculty of Design & Technology Conference David George, Department of Computing.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Triple Stores. What is a triple store? A specialized database for RDF triples Can ingest RDF in a variety of formats Supports a query language – SPARQL.
THE SEMANTIC WEB By Conrad Williams. Contents  What is the Semantic Web?  Technologies  XML  RDF  OWL  Implementations  Social Networking  Scholarly.
Everyday Tools for the Semantic Web Developer Rob Vesse Cray Inc.
CMPE58H Project Progress Presentation QAPoint H.Tuğçe Özkaptan Gözde Kaymaz Serkan Kırbaş
Steven Perry Dave Vieglais. W a s a b i Web Applications for the Semantic Architecture of Biodiversity Informatics Overview WASABI is a framework for.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Appendix I: Getting Started with Web Servers, PHP and the.
Chapter 04 Semantic Web Application Architecture 23 November 2015 A Team 오혜성, 조형헌, 권윤, 신동준, 이인용.
Knowledge Representation Part I Ontology Jan Pettersen Nytun Knowledge Representation Part I, JPN, UiA1.
1 RDF Storage and Retrieval Systems Jan Pettersen Nytun, UiA.
Jan Pettersen Nytun, UIA, page 1 Knowledge Representation Part IV The Semantics Web Starting with XML Jan Pettersen Nytun, UiA.
1 Knowledge Representation XII – IKT437 Knowledge Representation XII – IKT437 Part III Div Jan Pettersen Nytun, UiA Apache Jena.
Knowledge Representation XI – IKT437 Part II OWL, SPARQL, …
Jim Fawcett CSE687 – Object Oriented Design Spring 2001
Knowledge Representation Part IV The Semantics Web Starting with XML
Knowledge Representation Part VI
Knowledge Representation Part V RDF
Knowledge Representation Part II Description Logic & Introduction to Protégé Jan Pettersen Nytun.
Triple Stores.
Chapter No. : 1 Introduction to Java.
Jena 6/8/2018.
Knowledge Representation Part I Ontology
Knowledge Representation Part VI
Middleware independent Information Service
Knowledge Representation Part II
Jan Pettersen Nytun, UiA
Miguel Azurin, Andrew Engroff, Ahmad Sadiq
Jena Sparql (for Mac) 9/22/2018.
Triple Stores.
Using the Java Library API
Knowledge Representation (Part I)
Example: Jena and Fuseki
Knowledge Representation Part VII Protégé / RDFS / OWL / ++
Triple Stores.
Triple Stores.
Knowledge Representation Part III
Knowledge Representation Mandatory Exercise II IKT
Presentation transcript:

1 Knowledge Representation XI – IKT437 Knowledge Representation XI – IKT437 Part I RDF Jan Pettersen Nytun, UiA Apache Jena

S O P Apache Jena is an open source Semantic Web framework for Java. It provides an API to extract data from and write to RDF graphs. Jan Pettersen Nytun, UIA, page 2 From Wikipedia, the free encyclopedia

S O P The Jena Framework Includes – A RDF API Reading and writing RDF in RDF/XML, Turtle, … Triples can be stored in memory or in database. – ARQ Engine ARQ is a query engine that supports SPARQL. Jan Pettersen Nytun, UIA, page 3

S O P – TDB Engine TDB can be used as a high performance RDF store on a single machine. A TDB store can be accessed and managed with the provided command line scripts and via the Jena API. – Apache Jena Fuseki Apache Jena Fuseki is a SPARQL server supporting query and update. Fuseki is tightly integrated with TDB to provide a robust, transactional persistent storage layer. Jan Pettersen Nytun, UIA, page 4

S O P - The framework has various internal reasoners and the Pellet reasoner can be set up to work in Jena.Pellet reasoner - An OWL API Jan Pettersen Nytun, UIA, page 5 From Wikipedia, the free encyclopedia:

6 Framework Architecture [6] Fuseki is an HTTP interface to RDF data. It supports SPARQL for querying and updating.

7 Focus of rest of this presentation:

S O P Some Useful Links Jena project page: Some Jena tutorials: The API Javadocs: Jena documentation overview: Tutorial: Jena Semantic Web Framework: Jena: A Semantic Web Framework: Jan Pettersen Nytun, UIA, page 8

S O P Start Using Jena (11 September 2015) I downloaded and installed Eclipse Mars (4.5) Release for Windows. ( Jan Pettersen Nytun, UIA, page 9

S O P package task; public class TaskApp { public static void main(String[] args) { System.out.println("TaskApp started!"); System.out.println(System.getProperty("java.vendor")); System.out.println(System.getProperty("java.vendor.url")); System.out.println(System.getProperty("java.version")); } Gave output: TaskApp started! Oracle Corporation _31 Jan Pettersen Nytun, UIA, page 10 Apache Jena 3 requires Java 8 (from Jena version onwards) I Tested Eclipse

S O P I used: A complete beginner's guide to starting a Jena project in Eclipse ( This guide is a bit outdated, but still useful. Jan Pettersen Nytun, UIA, page 11

S O P I performed Step 3: Adding the Jena libraries I downloaded and unzipped the Jena libraries. – Download site: Added the libraries to the Eclipse project as described in “A complete beginner's guide to starting a Jena project in Eclipse”. Jan Pettersen Nytun, UIA, page 12

S O P Jan Pettersen Nytun, UIA, page 13 The new version of Jena has new package names, it should be org.apache.jena…. But package com.hp.jena… is still not found?

S O P Fixing the package names: Jan Pettersen Nytun, UIA, page 14

S O P Another Problem! Jan Pettersen Nytun, UIA, page 15

S O P …. Jena use log4j as logging system, and the warning messages tell explicitly that you are lacking of a log4j.properties to initialize it… Jan Pettersen Nytun, UIA, page 16

S O P Solve the “logging” problem Jan Pettersen Nytun, UIA, page 17 The downloaded Jena contains file jena-log4j. Copy this file to the bin catalog of you Eclipse project and rename it to log4j.

S O P Start Programming in Jena Jan Pettersen Nytun, UIA, page 18

package task; import org.apache.jena.datatypes.xsd.XSDDatatype; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; public class TaskApp { public static void main(String[] args) { Model m = ModelFactory.createDefaultModel(); String NS = " Resource r = m.createResource(NS + "r"); Property p = m.createProperty(NS + "p"); r.addProperty(p, "HelloWorld",XSDDatatype.XSDstring); m.write(System.out,"Turtle"); } Output: "HelloWorld". Making a triple with Jena

20 Output: "do task one". "TASK SET NO. 1". Output: "do task one". "TASK SET NO. 1".

public static void printTriples(Model model){ StmtIterator iter = model.listStatements(); while (iter.hasNext()) { Statement stmt = iter.nextStatement(); // get next statement Resource subject = stmt.getSubject(); // get the subject Property predicate = stmt.getPredicate(); // get the predicate RDFNode object = stmt.getObject(); // get the object System.out.print(subject.toString()); System.out.print(" " + predicate.toString() + " "); if (object instanceof Resource) { System.out.print(object.toString()); } else { // object is a literal System.out.print(" \"" + object.toString() + "\""); } System.out.println("."); } Jan Pettersen Nytun, UIA, page 21 Print all triples

S O P … String fileName = "testFile.ttl"; … try { OutputStream outFile = new FileOutputStream(fileName); model. write (outFile,"Turtle"); } catch (FileNotFoundException e) { e.printStackTrace(); } …… 22 Write model to file

S O P … String fileName = "testFile.ttl"; … InputStream in = FileManager.get().open( fileName ); if (in == null) { throw new IllegalArgumentException( "File: " + fileName + " not found"); } else { model. read (in, null, "Turtle"); } … 23 Read model from file

S O P References Jan Pettersen Nytun, UIA, page 24 [1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations of Computational Agents, Cambridge University Press, 2010, [2] [3] SPARQL 1.1 Query Language, W3C Recommendation 21 March 2013, [4] Semantic Web for the Working Ontologist, Second Edition: Effective Modeling in RDFS and OWL, May 20, 2011, by Dean Allemang, James Hendler [5] Appreciating SPARQL CONSTRUCT more, Bob DuCharme's weblog, [6] Getting started with Apache Jena,

S O P Tutorial: Jena Semantic Web Framework: Jena: A Semantic Web Framework: nlp.blogspot.no/2013/06/introduction-to- jena.htmlhttp://trimc- nlp.blogspot.no/2013/06/introduction-to- jena.html Videregående Jena: 9f606b8b485f.html 9f606b8b485f.html Jan Pettersen Nytun, UIA, page 25