The document discusses processing OWL ontologies using the Jena ontology API in Java. It describes how to create an ontology model, read an existing ontology, retrieve classes and properties, and examine class and property hierarchies. Key points include getting ontology classes and iterating over them, examining class relationships and restrictions, retrieving object and datatype properties, and getting property domains and ranges. The document provides examples of working with ontologies using the Jena API in Java.
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODOChris Mungall
NOTE THAT I HAVE MOVED AWAY FROM SLIDESHARE TO ZENODO
The identical presentation is now here:
https://doi.org/10.5281/zenodo.7778641
General introduction to LinkML, The Linked Data Modeling Language.
Adapter from presentation given to NIH May 2022
https://linkml.io/linkml
Build an application upon Semantic Web models. Brief overview of Apache Jena and OWL-API.
Semantic Web course
e-Lite group (https://elite.polito.it)
Politecnico di Torino, 2017
Elastic search
Moteur de recherche
Crée en 2010 par Shay Banon
Basé sur Apache Lucene (+multi-nodes)
Développé en Java
Open source (Licence Apache)
La société a été crée en 2012
La version courante est 2.0
Site officiel: https://www.elastic.co/
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODOChris Mungall
NOTE THAT I HAVE MOVED AWAY FROM SLIDESHARE TO ZENODO
The identical presentation is now here:
https://doi.org/10.5281/zenodo.7778641
General introduction to LinkML, The Linked Data Modeling Language.
Adapter from presentation given to NIH May 2022
https://linkml.io/linkml
Build an application upon Semantic Web models. Brief overview of Apache Jena and OWL-API.
Semantic Web course
e-Lite group (https://elite.polito.it)
Politecnico di Torino, 2017
Elastic search
Moteur de recherche
Crée en 2010 par Shay Banon
Basé sur Apache Lucene (+multi-nodes)
Développé en Java
Open source (Licence Apache)
La société a été crée en 2012
La version courante est 2.0
Site officiel: https://www.elastic.co/
Although RDF is a corner stone of semantic web and knowledge graphs, it has not been embraced by everyday programmers and software architects who need to safely create and access well-structured data. There is a lack of common tools and methodologies that are available in more conventional settings to improve data quality by defining schemas that can later be validated. Two technologies have recently been proposed for RDF validation: Shape Expressions (ShEx) and Shapes Constraint Language (SHACL). In the talk, we will review the history and motivation of both technologies. We will also and enumerate some challenges and future work with regards to RDF validation.
This was a short introduction to Scala programming language.
me and my colleague lectured these slides in Programming Language Design and Implementation course in K.N. Toosi University of Technology.
Slides from my talk at the Feb 2011 Seattle Tech Startups meeting. More info here (along with powerpoint slides): http://www.startupmonkeys.com/2011/02/scala-frugal-mechanic/
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Christian Schneider
The hidden danger of Java deserialization vulnerabilities – which often lead to remote code execution – has gained extended visibility in the past year. The issue has been known for years; however, it seems that the majority of developers were unaware of it until recent media coverage around commonly used libraries and major products. This talk aims to shed some light about how this vulnerability can be abused, how to detect it from a static and dynamic point of view, and -- most importantly -- how to effectively protect against it. The scope of this talk is not limited to the Java serialization protocol but also other popular Java libraries used for object serialization.
The ever-increasing number of new vulnerable endpoints and attacker-usable gadgets has resulted in a lot of different recommendations on how to protect your applications, including look-ahead deserialization and runtime agents to monitor and protect the deserialization process. Coming at the problem from a developer’s perspective and triaging the recommendations for you, this talk will review existing protection techniques and demonstrate their effectiveness on real applications. It will also review existing techniques and present new gadgets that demonstrates how attackers can actually abuse your application code and classpath to craft a chain of gadgets that will allow them to compromise your servers.
This talk will also present the typical architectural decisions and code patterns that lead to an increased risk of exposing deserialization vulnerabilities. Mapping the typical anti-patterns that must be avoided, through the use of real code examples we present an overview of hardening techniques and their effectiveness. The talk will also show attendees what to search the code for in order to find potential code gadgets the attackers can leverage to compromise their applications. We’ll conclude with action items and recommendations developers should consider to mitigate this threat.
--
This talk was presented by Alvaro Muñoz & Christian Schneider at the OWASP AppSecEU 2016 conference in Rome.
Find the answers to:
Why go semantic?
Should i use RDF or OWL?
What is the difference, what is the link?
Did you say smart data?
In this presentations you can check RDF Integration examples, learn about Ontologies and OWL
By Tara Raafat, (PhD) Chief Ontologist at Mphasis.
I used these slides for an introductory lecture (90min) to a seminar on SPARQL. This slideset introduces the RDF query language SPARQL from a user's perspective.
Slides for Data Syndrome one hour course on PySpark. Introduces basic operations, Spark SQL, Spark MLlib and exploratory data analysis with PySpark. Shows how to use pylab with Spark to create histograms.
Tutoriel sous forme d'exercices pour découvrir le sparql endpoint mis à disposition par la plateforme HAL, archive ouverte d'article scientifiques de toutes disciplines des institutions de recherches françaises. Attention ! Ce tutoriel a pour pré-requis la connaissance du langage de requêtes SPARQL.
JDBC tutorial with full example, including CRUD sql statement with JDBC Statement and PreparedStatement, interact Stored Procedure with CallableStatement, JDBC transaction
Face Recognition with OpenCV and scikit-learnShiqiao Du
A lightweight implementation of Face Recognition system with Python. OpenCV and scikit-learn.
Python, OpenCv, scikit-learnによる簡易な顔認識システムの実装. Tokyo.Scipy5にて発表。
Although RDF is a corner stone of semantic web and knowledge graphs, it has not been embraced by everyday programmers and software architects who need to safely create and access well-structured data. There is a lack of common tools and methodologies that are available in more conventional settings to improve data quality by defining schemas that can later be validated. Two technologies have recently been proposed for RDF validation: Shape Expressions (ShEx) and Shapes Constraint Language (SHACL). In the talk, we will review the history and motivation of both technologies. We will also and enumerate some challenges and future work with regards to RDF validation.
This was a short introduction to Scala programming language.
me and my colleague lectured these slides in Programming Language Design and Implementation course in K.N. Toosi University of Technology.
Slides from my talk at the Feb 2011 Seattle Tech Startups meeting. More info here (along with powerpoint slides): http://www.startupmonkeys.com/2011/02/scala-frugal-mechanic/
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Christian Schneider
The hidden danger of Java deserialization vulnerabilities – which often lead to remote code execution – has gained extended visibility in the past year. The issue has been known for years; however, it seems that the majority of developers were unaware of it until recent media coverage around commonly used libraries and major products. This talk aims to shed some light about how this vulnerability can be abused, how to detect it from a static and dynamic point of view, and -- most importantly -- how to effectively protect against it. The scope of this talk is not limited to the Java serialization protocol but also other popular Java libraries used for object serialization.
The ever-increasing number of new vulnerable endpoints and attacker-usable gadgets has resulted in a lot of different recommendations on how to protect your applications, including look-ahead deserialization and runtime agents to monitor and protect the deserialization process. Coming at the problem from a developer’s perspective and triaging the recommendations for you, this talk will review existing protection techniques and demonstrate their effectiveness on real applications. It will also review existing techniques and present new gadgets that demonstrates how attackers can actually abuse your application code and classpath to craft a chain of gadgets that will allow them to compromise your servers.
This talk will also present the typical architectural decisions and code patterns that lead to an increased risk of exposing deserialization vulnerabilities. Mapping the typical anti-patterns that must be avoided, through the use of real code examples we present an overview of hardening techniques and their effectiveness. The talk will also show attendees what to search the code for in order to find potential code gadgets the attackers can leverage to compromise their applications. We’ll conclude with action items and recommendations developers should consider to mitigate this threat.
--
This talk was presented by Alvaro Muñoz & Christian Schneider at the OWASP AppSecEU 2016 conference in Rome.
Find the answers to:
Why go semantic?
Should i use RDF or OWL?
What is the difference, what is the link?
Did you say smart data?
In this presentations you can check RDF Integration examples, learn about Ontologies and OWL
By Tara Raafat, (PhD) Chief Ontologist at Mphasis.
I used these slides for an introductory lecture (90min) to a seminar on SPARQL. This slideset introduces the RDF query language SPARQL from a user's perspective.
Slides for Data Syndrome one hour course on PySpark. Introduces basic operations, Spark SQL, Spark MLlib and exploratory data analysis with PySpark. Shows how to use pylab with Spark to create histograms.
Tutoriel sous forme d'exercices pour découvrir le sparql endpoint mis à disposition par la plateforme HAL, archive ouverte d'article scientifiques de toutes disciplines des institutions de recherches françaises. Attention ! Ce tutoriel a pour pré-requis la connaissance du langage de requêtes SPARQL.
JDBC tutorial with full example, including CRUD sql statement with JDBC Statement and PreparedStatement, interact Stored Procedure with CallableStatement, JDBC transaction
Face Recognition with OpenCV and scikit-learnShiqiao Du
A lightweight implementation of Face Recognition system with Python. OpenCV and scikit-learn.
Python, OpenCv, scikit-learnによる簡易な顔認識システムの実装. Tokyo.Scipy5にて発表。
A presentation on Design Patterns. This was created for the workshop at NED University of Engineering and Technology Karachi, Pakistan CIS Department held on April 7, 2012.
Had a wonderful experience
Java is a computer programming language developed by James Gosling at Sun Microsystems. Java was first released in 1995 and has since become one of the most popular programming languages with an estimated 12 million developers using it.
This presentation educates you about objectives of python with example syntax, OOP Terminology, Creating Classes, Creating Instance Objects, Accessing Attributes and Built-In Class Attributes.
Integrating a Domain Ontology Development Environment and an Ontology Search ...Takeshi Morita
In order to reduce the cost of building domain ontologies manually, in this paper, we propose a method and a tool named DODDLE-OWL for domain ontology construction reusing texts and existing ontologies extracted by an ontology search engine: Swoogle. In the experimental evaluation, we applied the method to a particular field of law and evaluated the acquired ontologies.
OWSCIS: Ontology and Web Service based Cooperation of Information SourcesRaji Ghawi
OWSCIS: Ontology and Web Service based Cooperation of Information Sources.
3rd International Conference on Signal-Image Technology & Internet-based Systems (SITIS' 2007), Shanghai, China, December 2007.
Building Ontologies from Multiple Information SourcesRaji Ghawi
This is the powerpoint presentation of my paper: "Building Ontologies from Multiple Information Sources", presented at IT2009 conference in Kaunas, Lithuania, 23/04/2009.
Database-to-Ontology Mapping Generation for Semantic InteroperabilityRaji Ghawi
This is the powerpoint presentation of my paper: "Database-to-Ontology Mapping Generation for Semantic Interoperability", presented at the Third International Workshop on Database Interoperability (InterDB 2007), held in conjunction with VLDB 2007, Vienna, Austria, September 2007.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
2. Outline
What is Jena ?
Reading an Existing Ontology
Classes
Properties
Individuals
Creating a New Ontology
30/03/2010
Classes
Properties
Individuales
2
3. What is Jena ?
Jena is a Java framework
for building Semantic Web applications
includes
30/03/2010
an RDF API
reading and writing RDF in RDF/XML, N3 and N-Triples
an OWL API
in-memory and persistent storage
SPARQL query engine
http://jena.sourceforge.net/
3
5. Outline
What is Jena ?
Reading an Existing Ontology
Classes
Properties
Individuals
Creating a New Ontology
30/03/2010
Classes
Properties
Individuales
5
6. Create Ontology Model
Jena provides an ontology model that allows to specify:
Ontology language
Storage model
Inference mode
OntModel model = ModelFactory.createOntologyModel();
default settings:
30/03/2010
OWL-Full language
in-memory storage
RDFS inference
6
7. OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
OntModelSpec
Language profile
Storage model
Reasoner
OWL_MEM
OWL full
in-memory
none
OWL_MEM_TRANS_INF
OWL full
in-memory
transitive class-hierarchy inference
OWL_MEM_RULE_INF
OWL full
in-memory
rule-based reasoner with OWL rules
OWL_MEM_MICRO_RULE_INF
OWL full
in-memory
optimised rule-based reasoner with OWL rules
OWL_MEM_MINI_RULE_INF
OWL full
in-memory
rule-based reasoner with subset of OWL rules
OWL_DL_MEM
OWL DL
in-memory
none
OWL_DL_MEM_RDFS_INF
OWL DL
in-memory
rule reasoner with RDFS-level entailment-rules
OWL_DL_MEM_TRANS_INF
OWL DL
in-memory
transitive class-hierarchy inference
OWL_DL_MEM_RULE_INF
OWL DL
in-memory
rule-based reasoner with OWL rules
OWL_LITE_MEM
OWL Lite
in-memory
none
OWL_LITE_MEM_TRANS_INF
OWL Lite
in-memory
transitive class-hierarchy inference
OWL_LITE_MEM_RDFS_INF
OWL Lite
in-memory
rule reasoner with RDFS-level entailment-rules
OWL_LITE_MEM_RULES_INF
OWL Lite
in-memory
rule-based reasoner with OWL rules
DAML_MEM
DAML+OIL
in-memory
none
DAML_MEM_TRANS_INF
DAML+OIL
in-memory
transitive class-hierarchy inference
DAML_MEM_RDFS_INF
DAML+OIL
in-memory
rule reasoner with RDFS-level entailment-rules
DAML_MEM_RULE_INF
DAML+OIL
in-memory
rule-based reasoner with DAML rules
RDFS_MEM
RDFS
in-memory
none
RDFS_MEM_TRANS_INF
RDFS
in-memory
transitive class-hierarchy inference
RDFS_MEM_RDFS_INF
RDFS
in-memory
rule reasoner with RDFS-level entailment-rules
30/03/2010
7
8. Read a File into Ontology Model
String fileName = "univ.owl";
try {
File file = new File(fileName);
FileReader reader = new FileReader(file);
OntModel model = ModelFactory
.createOntologyModel(OntModelSpec.OWL_DL_MEM);
model.read(reader,null);
model.write(System.out,"RDF/XML-ABBREV");
} catch (Exception e) {
e.printStackTrace();
}
30/03/2010
8
9. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Retrieve Ontology Classes
Iterator classIter = model.listClasses();
while (classIter.hasNext()) {
OntClass ontClass = (OntClass) classIter.next();
String uri = ontClass.getURI();
if(uri != null)
System.out.println(uri);
}
We can also use ontClass.getLocalName() to get the class name only.
If a class has no name (e.g. a restriction class), then ontClass.getURI()
returns null.
http://www.something.com/myontology#Professor
http://www.something.com/myontology#Module
http://www.something.com/myontology#Diploma
http://www.something.com/myontology#Person
http://www.something.com/myontology#Student
30/03/2010
output
9
10. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Retrieve a Specified Class
A specifed class is called by its URI
String classURI = "http://www.something.com/myontology#Professor";
OntClass professor = model.getOntClass(classURI );
// ...
If we know the class name only, we can get its URI by concatenating the
ontology URI with the class name:
ClassURI = OntologyURI + ‘#’ + ClassName
30/03/2010
10
11. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Get the Ontology URI
String ontologyURI = null;
Iterator iter = model.listOntologies();
if(iter.hasNext()){
Ontology onto = (Ontology) iter.next();
ontologyURI = onto.getURI();
System.out.println("Ontology URI = "+ontologyURI);
}
String className = "Professor";
String classURI = ontologyURI+"#"+className;
OntClass professor = model.getOntClass(classURI );
30/03/2010
11
12. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Class Hierarchy
OntClass student = model.getOntClass(uri+"#Student");
System.out.println(student.getSuperClass());
System.out.println(student.getSubClass());
http://www.something.com/myontology#Person
null
OntClass person = model.getOntClass(uri+"#Person");
System.out.println(person.getSuperClass());
System.out.println(person.getSubClass());
null
http://www.something.com/myontology#Professor
30/03/2010
12
13. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Class Hierarchy
Iterator supIter = person.listSuperClasses();
while (supIter.hasNext()) {
OntClass sup = (OntClass) supIter.next();
System.out.println(sup);
}
System.out.println("----------------");
Iterator subIter = person.listSubClasses();
while (subIter.hasNext()) {
OntClass sub = (OntClass) subIter.next();
System.out.println(sub);
}
---------------http://www.something.com/myontology#Professor
http://www.something.com/myontology#Student
30/03/2010
13
14. Reading an Existing Ontology
Creating a New Ontology
Classes
Properties
Individuales
Class Hierarchy
true
direct sub-classes
false
all sub-classes (default)
true
direct super-classes
false
all super-classes (default)
listSubClasses(boolean)
listSuperClasses(boolean)
A
B, C
->
B, C, D
D.listSuperClasses(true)
->
C
C
D
30/03/2010
->
A.listSubClasses(false)
B
A.listSubClasses(true)
D.listSuperClasses(false) ->
C, A
14
15. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Class Hierarchy
<OntClass>.isHierarchyRoot()
This function returns true if this class is the root of the class
hierarchy in the model:
this class has owl:Thing as a direct super-class,
or it has no declared super-classes
owl:Thing
Professor
Person
30/03/2010
Module
Diploma
Student
15
16. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Intersection / Union / Complement
if(ontClass.isIntersectionClass()){
IntersectionClass intersection = ontClass.asIntersectionClass();
RDFList operands = intersection.getOperands();
for (int i = 0; i < operands.size(); i++) {
RDFNode rdfNode = operands.get(i);
...
}
} else if(ontClass.isUnionClass()){
UnionClass union = ontClass.asUnionClass();
RDFList operands = union.getOperands();
...
} else if(ontClass.isComplementClass()){
ComplementClass compl = ontClass.asComplementClass();
RDFList operands = compl.getOperands();
...
}
30/03/2010
16
17. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Retrieve the Properties of a Specified Class
OntClass student = model.getOntClass(uri+"#Student");
Iterator propIter = student.listDeclaredProperties();
while (propIter.hasNext()) {
OntProperty property = (OntProperty) propIter.next();
System.out.println(property.getLocalName());
}
output
studentNumber
age
personName
enrolledIn
email
true
directly associated properties
false
all properties (direct + inhereted)
listDeclaredProperties(boolean)
(default)
30/03/2010
17
18. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Property Types
1
Two ways to know whether a property is datatype property or
object property:
if(property.isObjectProperty()){
// ... this is an object property
} else if (property.isDatatypeProperty()){
// ... this is an datatype property
}
property.isFunctionalProperty();
property.isSymmetricProperty();
property.isTransitiveProperty();
property.isInverseOf(anotherProperty);
30/03/2010
18
19. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Property Types
Two ways to know whether a property is datatype property or
object property:
Resource propertyType = property.getRDFType();
System.out.println(propertyType);
2
if(propertyType.equals(OWL.DatatypeProperty)){
// ... this is an datatype property
} else if(propertyType.equals(OWL.ObjectProperty)){
// ... this is an object property
}
http://www.w3.org/2002/07/owl#DatatypeProperty
http://www.w3.org/2002/07/owl#DatatypeProperty
http://www.w3.org/2002/07/owl#DatatypeProperty
http://www.w3.org/2002/07/owl#ObjectProperty
http://www.w3.org/2002/07/owl#DatatypeProperty
30/03/2010
output
19
20. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Property Domain and Range
String propertyName = property.getLocalName();
String dom = "";
String rng = "";
if(property.getDomain()!=null)
dom = property.getDomain().getLocalName();
if(property.getRange()!=null)
rng = property.getRange().getLocalName();
System.out.println(propertyName +": t("+dom+") t -> ("+rng+") ");
listDeclaredProperties(boolean);
true
studentNumber:
enrolledIn:
(Student)
(Student)
false
studentNumber:
age:
personName:
enrolledIn:
email:
(Student)
(Person)
(Person)
(Student)
(Person)
30/03/2010
-> (string)
-> (Diploma)
->
->
->
->
->
output
(string)
(int)
(string)
(Diploma)
(string)
20
21. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Datatype Properties
list all datatype properties in the model:
Iterator iter = model.listDatatypeProperties();
while (iter.hasNext()) {
DatatypeProperty prop = (DatatypeProperty) iter.next();
String propName = prop.getLocalName();
String dom = "";
String rng = "";
if(prop.getDomain()!=null)
dom = prop.getDomain().getLocalName();
if(prop.getRange()!=null)
rng = prop.getRange().getLocalName();
System.out.println(propName +": t("+dom+") t -> ("+rng+") ");
}
diplomaName:
studentNumber:
moduleName:
age:
personName:
email:
30/03/2010
(Diploma)
(Student)
(Module)
(Person)
(Person)
(Person)
-> (string)
-> (string)
-> (string)
-> (int)
-> (string)
-> (string)
output
21
22. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Object Properties
list all object properties in the model:
Iterator iter = model.listObjectProperties();
while (iter.hasNext()) {
ObjectProperty prop = (ObjectProperty) iter.next();
String propName = prop.getLocalName();
String dom = "";
String rng = "";
if(prop.getDomain()!=null)
dom = prop.getDomain().getLocalName();
if(prop.getRange()!=null)
rng = prop.getRange().getLocalName();
System.out.println(propName +": t("+dom+") t -> ("+rng+") ");
}
enrolledIn:
hasModule:
taughtBy:
teach:
(Student) -> (Diploma)
(Diploma) -> (Module)
(Module) -> (Professor)
(Professor) -> (Module)
getInverse()
30/03/2010
→
output
(OntProperty)
22
23. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Other Types of Properties
Using the same way, we may list (iterate) other properties:
model.listFunctionalProperties()
model.listInverseFunctionalProperties()
model.listSymmetricProperties()
model.listTransitiveProperties()
30/03/2010
23
24. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Restrictions
if(ontClass.isRestriction()){
Restriction rest = ontClass.asRestriction();
OntProperty onProperty = rest.getOnProperty();
...
}
30/03/2010
24
26. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
HasValue
if(rest.isHasValueRestriction()){
HasValueRestriction hvr = rest.asHasValueRestriction();
RDFNode hv = hvr.getHasValue();
...
}
30/03/2010
26
27. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Cardinality / MinCardinality / MaxCardinality
if(rest.isCardinalityRestriction()){
CardinalityRestriction cr = rest.asCardinalityRestriction();
int card = cr.getCardinality();
...
}
if(rest.isMinCardinalityRestriction()){
MinCardinalityRestriction mcr = rest.asMinCardinalityRestriction();
int minCard = minCR.getMinCardinality();
...
}
if(rest.isMaxCardinalityRestriction()){
MaxCardinalityRestriction mcr = rest.asMaxCardinalityRestriction();
int maxCard = maxCR.getMaxCardinality();
...
}
30/03/2010
27
28. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Individuals
list all individuals in the model
Iterator individuals = model.listIndividuals();
while (individuals.hasNext()) {
Individual individual = (Individual) individuals.next();
...
}
list individuals of a specific class
Iterator iter = ontClass.listInstances();
while (iter.hasNext()) {
Individual individual = (Individual) iter.next();
...
}
30/03/2010
28
29. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Individuals
list properties and property values of an individual
Iterator props = individual.listProperties();
while (props.hasNext()) {
Property property = (Property) props.next();
RDFNode value = individual.getPropertyValue(property);
...
}
list values of a specific property of an individual
Iterator values = individual.listPropertyValues(property);
while (values.hasNext()) {
RDFNode value = values.next();
...
}
30/03/2010
29
30. Reading an Existing Ontology
Classes
Creating a New Ontology
Properties
Individuales
Individuals
get the class to which an individual belongs
Resource rdfType = individual.getRDFType();
OntClass ontClass = model.getOntClass(rdfType.getURI());
in recent versions of Jena
OntClass ontClass = individual.getOntClass();
30/03/2010
30
31. Outline
What is Jena ?
Reading an Existing Ontology
Classes
Properties
Individuals
Creating a New Ontology
30/03/2010
Classes
Properties
Individuales
31
32. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Create the ontology model
OntModel model =
ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
String uriBase = "http://www.something.com/myontology";
model.createOntology(uriBase);
30/03/2010
32
33. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Create Classes
//create
OntClass
OntClass
OntClass
OntClass
OntClass
30/03/2010
classes
person = model.createClass(uriBase+"#Person");
module = model.createClass(uriBase+"#Module");
diploma = model.createClass(uriBase+"#Diploma");
student = model.createClass(uriBase+"#Student");
professor = model.createClass(uriBase+"#Professor");
33
34. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Set Sub-Classes
//set sub-classes
person.addSubClass(student);
person.addSubClass(professor);
30/03/2010
34
35. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Intersection / Union / Complement
RDFNode[] classes = new RDFNode[] {class1, class2, ...};
RDFList list = model.createList(classes);
IntersectionClass intersection =
model.createIntersectionClass(uri, list);
UnionClass union = model.createUnionClass(uri, list);
ComplementClass compl =
model.createComplementClass(uri, resource);
30/03/2010
35
36. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Create Datatype Properties
//create datatype properties
DatatypeProperty personName =
model.createDatatypeProperty(uriBase+"#personName");
personName.setDomain(person);
personName.setRange(XSD.xstring);
DatatypeProperty age = model.createDatatypeProperty(uriBase+"#age");
age.setDomain(person);
age.setRange(XSD.integer);
//
... ...
30/03/2010
36
38. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Inverse-of / Functional
set inverse properties
// set inverse properties
teach.setInverseOf(taughtBy);
set functional properties
// set functional properties
enrolledIn.setRDFType(OWL.FunctionalProperty);
30/03/2010
38
40. Creating a New Ontology
Reading an Existing Ontology
Classes
Properties
Individuales
Individuales
create an individual
Individual indv = ontClass.createIndividual(uri);
or
Individual indv = model.createIndividual(uri, ontClass);
set a property value of an individual
indv.setPropertyValue(property, rdfNode);
30/03/2010
40
41. Write Ontology Model
write the model to standard output
// write out the model
model.write(System.out,"RDF/XML-ABBREV");
save the model to a string
StringWriter sw = new StringWriter();
model.write(sw, "RDF/XML-ABBREV");
String owlCode = sw.toString();
30/03/2010
41
42. Save the Model to a File
File file = new File(filePath);
try{
FileWriter fw = new FileWriter(file);
fw.write(owlCode);
fw.close();
} catch(FileNotFoundException fnfe){
fnfe.printStackTrace();
} catch(IOException ioe){
ioe.printStackTrace();
}
30/03/2010
42