Knowledge Representation Part II

Slides:



Advertisements
Similar presentations
1 ISWC-2003 Sanibel Island, FL IMG, University of Manchester Jeff Z. Pan 1 and Ian Horrocks 1,2 {pan | 1 Information Management.
Advertisements

SPARQL Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014.
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
Semantics Static semantics Dynamic semantics attribute grammars
An Introduction to RDF(S) and a Quick Tour of OWL
April 15, 2004SPIE1 Association in Level 2 Fusion Mieczyslaw M. Kokar Christopher J. Matheus Jerzy A. Letkowski Kenneth Baclawski Paul Kogut.
Master Informatique 1 Semantic Technologies Part 4Jena Werner Nutt.
JENA –A SEMANTIC WEB TOOL by Ranjani Sankaran & krishna Priyanka Chebrolu.
Presented by Amr Ali AL-Hossary (M.B.,B.Ch)
Of 27 lecture 7: owl - introduction. of 27 ece 627, winter ‘132 OWL a glimpse OWL – Web Ontology Language describes classes, properties and relations.
OWL TUTORIAL APT CSA 3003 OWL ANNOTATOR Charlie Abela CSAI Department.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Descriptions Robert Grimm New York University. The Final Assignment…  Your own application  Discussion board  Think: Paper summaries  Web cam proxy.
Jena --- A Java API for RDF Jing deng CSCI 7818 Web Technologies Computer Science Department University of Colorado at Boulder Wednesday, October 31, 2001.
COMP 6703 eScience Project Semantic Web for Museums Student : Lei Junran Client/Technical Supervisor : Tom Worthington Academic Supervisor : Peter Strazdins.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
From SHIQ and RDF to OWL: The Making of a Web Ontology Language
Describing Syntax and Semantics
1 Representing Data with XML September 27, 2005 Shawn Henry with slides from Neal Arthorne.
OWL and SDD Dave Thau University of Kansas
The Jena RDF Framework Konstantinos Tzonas. Contents What is Jena Capabilities of Jena Basic notions RDF concepts in Jena Persistence Ontology management.
OWL 2 in use. OWL 2 OWL 2 is a knowledge representation language, designed to formulate, exchange and reason with knowledge about a domain of interest.
Presentation : Konstantinos Kanaris.  What is Jena?  Usage of Jena  Main Concepts  Main Components  Storage Models  OWL API  RDF API  Reasoning.
Michael Eckert1CS590SW: Web Ontology Language (OWL) Web Ontology Language (OWL) CS590SW: Semantic Web (Winter Quarter 2003) Presentation: Michael Eckert.
Advanced topics in software engineering (Semantic web)
Course Overview and Road Map Computability and Logic.
EEL 5937 Ontologies EEL 5937 Multi Agent Systems Lecture 5, Jan 23 th, 2003 Lotzi Bölöni.
CS6133 Software Specification and Verification
The Semantic Web Riccardo Rosati Dottorato in Ingegneria Informatica Sapienza Università di Roma a.a. 2006/07.
Practical RDF Chapter 12. Ontologies: RDF Business Models Shelley Powers, O’Reilly SNU IDB Lab. Taikyoung Kim.
Of 35 lecture 17: semantic web rules. of 35 ece 627, winter ‘132 logic importance - high-level language for expressing knowledge - high expressive power.
WonderWeb. Ontology Infrastructure for the Semantic Web. IST Project Review Meeting, 11 th March, WP2: Tools Raphael Volz Universität.
Web Ontology Language (OWL). OWL The W3C Web Ontology Language (OWL) is a Semantic Web language designed to represent rich and complex knowledge about.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Semantic Interoperability in GIS N. L. Sarda Suman Somavarapu.
1 Knowledge Representation XI – IKT437 Knowledge Representation XI – IKT437 Part I RDF Jan Pettersen Nytun, UiA Apache Jena.
Knowledge Representation Part I Ontology Jan Pettersen Nytun Knowledge Representation Part I, JPN, UiA1.
1 Knowledge Representation XII – IKT437 Knowledge Representation XII – IKT437 Part III Div Jan Pettersen Nytun, UiA Apache Jena.
OWL (Ontology Web Language and Applications) Maw-Sheng Horng Department of Mathematics and Information Education National Taipei University of Education.
Knowledge Representation XI – IKT437 Part II OWL, SPARQL, …
Jena Ontology API 4/14/2018.
Charlie Abela Department of Intelligent Computer Systems
Knowledge Representation Part V RDF
Working with Java.
Reasoning with Rules SWRL as Example
Knowledge Representation Part II Description Logic & Introduction to Protégé Jan Pettersen Nytun.
Formal ontologies vs. triple based KR gap or convergence?
Knowledge Representation Part VII Protégé / RDFS / OWL / ++
Building Trustworthy Semantic Webs
Jena 6/8/2018.
Knowledge Representation Part I Ontology
Introduction to the Semantic Web (tutorial) 2009 Semantic Technology Conference San Jose, California, USA June 15, 2009 Ivan Herman, W3C
ece 720 intelligent web: ontology and beyond
Jan Pettersen Nytun, UiA
SPARQL Exercise Much of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3
Ontologies.
Bus Routes.
Analyzing and Securing Social Networks
Ontology.
ece 720 intelligent web: ontology and beyond
Programming Languages 2nd edition Tucker and Noonan
Linking Guide Michel Böhms.
SPARQL Exercise Most of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3
The Jena RDF Framework Konstantinos Tzonas.
Ontology.
Semantic Markup for Semantic Web Tools:
Programming Languages 2nd edition Tucker and Noonan
Representations & Reasoning Systems (RRS) (2.2)
CIS Monthly Seminar – Software Engineering and Knowledge Management IS Enterprise Modeling Ontologies Presenter : Dr. S. Vasanthapriyan Senior Lecturer.
Presentation transcript:

Knowledge Representation Part II Apache Jena Knowledge Representation Part II Jan Pettersen Nytun, UiA

This presentation is based on: Jena Ontology API http://jena. apache

… Jena is fundamentally an RDF platform, … limited to ontology formalisms built on top of RDF. … this means RDFS, the varieties of OWL.

The OWL language is sub-divided into three syntax classes:  OWL Lite, OWL DL and OWL Full. [Wikipedia]: Every legal OWL Lite ontology is a legal OWL DL ontology. Every legal OWL DL ontology is a legal OWL Full ontology.

[Wikipedia]: OWL Lite … intended to support those users primarily needing a classification hierarchy and simple constraints … Development of OWL Lite tools has … proven almost as difficult as development of tools for OWL DL, and OWL Lite is not widely used.

[Wikipedia]: OWL DL is designed to provide the maximum expressiveness possible while retaining computational completeness, decidability, and the availability of practical reasoning algorithms. OWL DL includes all OWL language constructs, but they can be used only under certain restrictions …

Soundness is the property of only being able to prove "true" things. [http://philosophy.stackexchange.com/questions/6992/ the-difference-between-soundness-and-completeness] Soundness is the property of only being able to prove "true" things. Completeness is the property of being able to prove all true things. So a given logical system is sound if and only if the inference rules of the system admit only valid formulas. Or another way, if we start with valid premises, the inference rules do not allow an invalid conclusion to be drawn. A system is complete if and only if all valid formula can be derived from the axioms and the inference rules. So there are no valid formula that we can't prove. Together they imply that all and only validities are provable.

Decidability [Wikipedia]: The logically valid formulas of a system are sometimes called the theorems of the system, … A logical system is decidable if there is an effective method for determining whether arbitrary formulas are theorems of the logical system. Upper case: Φ lower case: φ = phi (pronounced “pai”) Φ is either true or false in the theory…

Gödel's incompleteness theorem [Wikipedia]: Recursively axiomatizable first-order theories that are rich enough to allow general mathematical reasoning to be formulated cannot be complete, as demonstrated by Gödel's incompleteness theorem. … For any such system, there will always be statements about the natural numbers that are true, but that are unprovable within the system.

[Wikipedia]: OWL Full[edit] … a class can be treated simultaneously as a collection of individuals and as an individual in its own right ... OWL Full allows an ontology to augment the meaning of the pre-defined (RDF or OWL) vocabulary. OWL Full is undecidable, so no reasoning software is able to perform complete reasoning for it.

Jena Graph Interface Graph is an internal Jena interface that supports the composition of sets of RDF triples. The asserted statements, which may have been read in from an ontology document, are held in the base graph.

The reasoner, or inference engine, can use the contents of the base graph and the semantic rules of the language to show a more complete set of base and entailed triples. This is also presented via a Graph interface, so the OntModel works only with the outermost interface.

The base graph can be an in-memory store, a database-backed persistent store, or some other storage structure altogether …

Creating Ontology Models OntModel m = ModelFactory.createOntologyModel(); This will create an ontology model with the default settings: OWL-Full language in-memory storage RDFS inference, which principally produces entailments from the sub-class and sub-property hierarchies.

An OWL model that performs no reasoning at all can be created with: In many applications, such as driving a GUI, RDFS inference is too strong.  An OWL model that performs no reasoning at all can be created with: OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );

Testing Reasoning in Jena Input Ontology @prefix : <http://www.uia.no/janpettersennytun/inference#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xml: <http://www.w3.org/XML/1998/namespace> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . :hasApprovedId a owl:DatatypeProperty ; rdfs:subPropertyOf :hasSomeId . :hasSomeId a owl:DatatypeProperty . :hasHusband a owl:ObjectProperty ; owl:inverseOf :hasWife . :hasWife a owl:ObjectProperty . :Man a owl:Class ; rdfs:subClassOf :Human . :Woman a owl:Class ; rdfs:subClassOf :Human . :Human a owl:Class . :Homer a owl:NamedIndividual , :Man ; :hasSomeId "Homer_ID1_SomeID" . :Marge a owl:NamedIndividual , :Woman ; :hasApprovedId "Marge_ID1_Approved" ; :hasHusband :Homer .

Testing Reasoning in Jena Application Heading package testreasoners; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; 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.RDFNode; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.Statement; import org.apache.jena.rdf.model.StmtIterator; import org.apache.jena.util.FileManager;

Testing Reasoning in Jena Method Overview public class TestReasoners { private static String inputFileName = "InferenceTest__InputFile.ttl"; private static String outputFileName = "InferenceTest__OutputFile.ttl"; public static void main(String[] args){ … } public static List<String> getSortedTriples(Model model){ … } public static OntModel readFile(OntModelSpec ontModelSpec){ … } }

Testing Reasoning in Jena readFile - Method public static OntModel readFile(OntModelSpec ontModelSpec){ OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec); InputStream in = FileManager.get().open( inputFileName ); if (in == null) { System.out.println("File: " + inputFileName + " not found"); System.exit(1); } // read the Turtle file ontModel.read(in, null, "Turtle"); //ontModel.write(System.out, "Turtle"); return ontModel;

Testing Reasoning in Jena getSortedTriples- Method public static List<String> getSortedTriples(Model model){ List<String> triples = new ArrayList<String>(); StmtIterator iter = model.listStatements(); String format = "%-20s"; String defaultNamespace = model.getNsPrefixMap().get(""); if (defaultNamespace == null) return triples;

while (iter. hasNext()) { Statement stmt = iter while (iter.hasNext()) { Statement stmt = iter.nextStatement(); // get next statement Resource subject = stmt.getSubject(); // get the subject String namespace = subject.getNameSpace(); if (namespace == null || !namespace.equals(defaultNamespace)) continue; Property predicate = stmt.getPredicate(); // get the predicate RDFNode object = stmt.getObject(); // get the object String tripleAsString = String.format(format, subject.getLocalName().toString()); tripleAsString = tripleAsString + String.format(format, predicate.getLocalName().toString()); if (object instanceof Resource) { tripleAsString = tripleAsString + object.asResource().getLocalName().toString() + " ."; } else { // object is a literal tripleAsString = tripleAsString + " \"" + object.toString() + "\"" + " ."; } triples.add(tripleAsString); Collections.sort(triples); return triples; }

public static void main(String[] args){ OntModel model_OWL_DL_MEM = readFile(OntModelSpec.OWL_DL_MEM); List<String> triples_OWL_DL_MEM = getSortedTriples(model_OWL_DL_MEM); System.out.println("Triple found in model_OWL_DL_MEM"); System.out.println("............................................................................."); for (String oneTriple : triples_OWL_DL_MEM) System.out.println(oneTriple); System.out.println(".............................................................................\n"); model_OWL_DL_MEM.close(); …

Triple found in model_OWL_DL_MEM. Homer hasSomeId "Homer_ID1_SomeID" Triple found in model_OWL_DL_MEM ................................................................ Homer hasSomeId "Homer_ID1_SomeID" . Homer type Man . Homer type NamedIndividual . Human type Class . Man subClassOf Human . Man type Class . Marge hasApprovedId "Marge_ID1_Approved" . Marge hasHusband Homer . Marge type NamedIndividual . Marge type Woman . Woman subClassOf Human . Woman type Class . hasApprovedId subPropertyOf hasSomeId . hasApprovedId type DatatypeProperty . hasHusband inverseOf hasWife . hasHusband type ObjectProperty . hasSomeId type DatatypeProperty . hasWife type ObjectProperty .

OntModel model_OWL_DL_MEM_RDFS_INF = readFile(OntModelSpec OntModel model_OWL_DL_MEM_RDFS_INF = readFile(OntModelSpec.OWL_DL_MEM_RDFS_INF); List<String> triples_OWL_DL_MEM_RDFS_INF = getSortedTriples(model_OWL_DL_MEM_RDFS_INF); System.out.println("Triple found in model_OWL_DL_MEM_RDFS_INF"); System.out.println("............................................................................."); for (String oneTriple : triples_OWL_DL_MEM_RDFS_INF) { System.out.println(oneTriple); } System.out.println(".............................................................................\n"); model_OWL_DL_MEM_RDFS_INF.close();

Triple found in model_OWL_DL_MEM_RDFS_INF Triple found in model_OWL_DL_MEM_RDFS_INF ................................................................. Homer hasSomeId "Homer_ID1_SomeID" . Homer type Human . Homer type Man . Homer type NamedIndividual . Human subClassOf Human . Human type Class . Human type Resource . Man subClassOf Human . Man subClassOf Man . Man type Class . Man type Resource . Marge hasApprovedId "Marge_ID1_Approved" . Marge hasHusband Homer . Marge hasSomeId "Marge_ID1_Approved" . Marge type Human . Marge type NamedIndividual . Marge type Woman .

Woman subClassOf Human. Woman subClassOf Woman. Woman type Class Woman subClassOf Human . Woman subClassOf Woman . Woman type Class . Woman type Resource . hasApprovedId subPropertyOf hasApprovedId . hasApprovedId subPropertyOf hasSomeId . hasApprovedId type DatatypeProperty . hasApprovedId type Property . hasApprovedId type Resource . hasHusband inverseOf hasWife . hasHusband type ObjectProperty . hasSomeId subPropertyOf hasSomeId . hasSomeId type DatatypeProperty . hasSomeId type Property . hasSomeId type Resource . hasWife type ObjectProperty . .........................................................

OntModel model_OWL_DL_MEM_RULE_INF = readFile(OntModelSpec OntModel model_OWL_DL_MEM_RULE_INF = readFile(OntModelSpec.OWL_DL_MEM_RULE_INF); List<String> triples_OWL_DL_MEM_RULE_INF = getSortedTriples(model_OWL_DL_MEM_RULE_INF); System.out.println("Triple found in model_OWL_DL_MEM_RULE_INF"); System.out.println("............................................................................."); for (String oneTriple : triples_OWL_DL_MEM_RULE_INF) System.out.println(oneTriple); System.out.println(".............................................................................\n"); try { OutputStream outFile = new FileOutputStream(outputFileName); model_OWL_DL_MEM_RULE_INF.write(outFile,"Turtle"); } catch (FileNotFoundException e) { e.printStackTrace(); } model_OWL_DL_MEM_RULE_INF.close();

Triple found in model_OWL_DL_MEM_RULE_INF Triple found in model_OWL_DL_MEM_RULE_INF .................................................... Homer hasSomeId "Homer_ID1_SomeID" . Homer hasWife Marge . Homer sameAs Homer . Homer type Human . Homer type Man . Homer type NamedIndividual . Homer type Resource . Homer type Thing . Human equivalentClass Human . Human subClassOf Human . Human subClassOf Resource . Human subClassOf Thing . Human type Class . Human type Resource .

Man equivalentClass Man. Man subClassOf Human. Man subClassOf Man Man equivalentClass Man . Man subClassOf Human . Man subClassOf Man . Man subClassOf Resource . Man subClassOf Thing . Man type Class . Man type Resource . Marge hasApprovedId "Marge_ID1_Approved" . Marge hasHusband Homer . Marge hasSomeId "Marge_ID1_Approved" . Marge sameAs Marge . Marge type Human . Marge type NamedIndividual . Marge type Resource . Marge type Thing . Marge type Woman .

Woman equivalentClass Woman. Woman subClassOf Human Woman equivalentClass Woman . Woman subClassOf Human . Woman subClassOf Resource . Woman subClassOf Thing . Woman subClassOf Woman . Woman type Class . Woman type Resource . hasApprovedId subPropertyOf hasApprovedId . hasApprovedId subPropertyOf hasSomeId . hasApprovedId type DatatypeProperty . hasApprovedId type Property . hasApprovedId type Resource .

hasHusband domain Resource. hasHusband domain Thing hasHusband domain Resource . hasHusband domain Thing . hasHusband inverseOf hasWife . hasHusband range Resource . hasHusband range Thing . hasHusband subPropertyOf hasHusband . hasHusband type ObjectProperty . hasHusband type Property . hasHusband type Resource . hasSomeId subPropertyOf hasSomeId . hasSomeId type DatatypeProperty . hasSomeId type Property . hasSomeId type Resource .

hasWife domain Resource. hasWife domain Thing hasWife domain Resource . hasWife domain Thing . hasWife inverseOf hasHusband . hasWife range Resource . hasWife range Thing . hasWife subPropertyOf hasWife . hasWife type ObjectProperty . hasWife type Property . hasWife type Resource . ...................................................