I would like to infer an anonymous class definition for my Individuals in Protege.
I have a simple Ontology with the Classes Rain NoRain and Scene, The object Property has_weather.
My desire is to be able to infer "has_weather(?x, ?noRain), NoRain(?noRain), Scene(?x) -> (has_weather exactly 0 Rain)(?x) which i wrote in the Rules tab, where i can mix SWRL and OWL Expressions.
I am using Pellet Reasoner, however I also tried with OnTop and Hermit and none works. For example if I do the rule the other way around:
`has_weather(?x, ?noRain), (has_weather exactly 0 Rain)(?x), Scene(?x) -> Test(?x)`
It works without problems.
Is the problem, that Protege just can't infer anonymous classes? Is there any workaround? Thank you in Advance!
here is the code to the ontology
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather">
<rdfs:subPropertyOf rdf:resource="http://www.w3.org/2002/07/owl#topObjectProperty"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain -->
<owl:Class rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain">
<owl:disjointWith rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain"/>
</owl:Class>
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain -->
<owl:Class rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain"/>
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene -->
<owl:Class rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain">
<rdf:type rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene">
<rdf:type rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene"/>
<has_weather rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain"/>
</owl:NamedIndividual>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Rules
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<rdf:Description rdf:about="urn:swrl:var#x">
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable"/>
</rdf:Description>
<rdf:Description rdf:about="urn:swrl:var#noRain">
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable"/>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
<swrl:body>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
<swrl:propertyPredicate rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather"/>
<swrl:argument1 rdf:resource="urn:swrl:var#x"/>
<swrl:argument2 rdf:resource="urn:swrl:var#noRain"/>
</rdf:Description>
</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain"/>
<swrl:argument1 rdf:resource="urn:swrl:var#noRain"/>
</rdf:Description>
</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene"/>
<swrl:argument1 rdf:resource="urn:swrl:var#x"/>
</rdf:Description>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</swrl:body>
<swrl:head>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather"/>
<owl:qualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">0</owl:qualifiedCardinality>
<owl:onClass rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain"/>
</owl:Restriction>
</swrl:classPredicate>
<swrl:argument1 rdf:resource="urn:swrl:var#x"/>
</rdf:Description>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</swrl:head>
</rdf:Description>
</rdf:RDF>
`
In general a set of axioms has an infinite amout of entailments. See for example this paper. For this reason reasoners restrict inferences to known classes (not anonymous classes). I suspect this holds true for rules as well.
I therefore suggest you add a class NoRain that you set equivalent to has_weather 0 Rain and change your SWRL rule to use the class NoRain.
Related
I'm wondering if there's a way using Apache Jena or OWL API, to retrieve ontology's individuals by a given data property, and then matching the relations between those individuals from their in common object properties.
EDIT: Here's a sample of the CSV file
,California,Texas,New York,Alabama
Hillary Clinton,69%,31%,33%,67%
Donald Trump,31%,69%,67%,33%
And this is a simple domain ontology created with Protégé:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.kdm.com/OWL/elections2016#"
xml:base="http://www.kdm.com/OWL/elections2016"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:elections2016="http://www.kdm.com/OWL/elections2016#">
<owl:Ontology rdf:about="http://www.kdm.com/OWL/elections2016#"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.kdm.com/OWL/elections2016#HasVote -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#HasVote">
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Votes"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#HasVoteByClasseSociale -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#HasVoteByClasseSociale">
<rdfs:subPropertyOf rdf:resource="http://www.kdm.com/OWL/elections2016#HasVote"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#ClasseSociale"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#HasVoteByPeriode -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#HasVoteByPeriode">
<rdfs:subPropertyOf rdf:resource="http://www.kdm.com/OWL/elections2016#HasVote"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#HasVoteByRegion -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#HasVoteByRegion">
<rdfs:subPropertyOf rdf:resource="http://www.kdm.com/OWL/elections2016#HasVote"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Region"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#HasVoteByVotingAge -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#HasVoteByVotingAge">
<rdfs:subPropertyOf rdf:resource="http://www.kdm.com/OWL/elections2016#HasVote"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#VotingAge"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#hasNomineeDemocratic -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#hasNomineeDemocratic">
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#hasNomineeRepublic -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#hasNomineeRepublic">
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Democratic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#hasPartone -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#hasPartone">
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Political_parties"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Democratic"/>
</owl:ObjectProperty>
<!-- http://www.kdm.com/OWL/elections2016#haspartytwo -->
<owl:ObjectProperty rdf:about="http://www.kdm.com/OWL/elections2016#haspartytwo">
<rdfs:domain rdf:resource="http://www.kdm.com/OWL/elections2016#Republic"/>
<rdfs:range rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.kdm.com/OWL/elections2016#age -->
<owl:DatatypeProperty rdf:about="http://www.kdm.com/OWL/elections2016#age"/>
<!-- http://www.kdm.com/OWL/elections2016#asset -->
<owl:DatatypeProperty rdf:about="http://www.kdm.com/OWL/elections2016#asset"/>
<!-- http://www.kdm.com/OWL/elections2016#currentLocation -->
<owl:DatatypeProperty rdf:about="http://www.kdm.com/OWL/elections2016#currentLocation"/>
<!-- http://www.kdm.com/OWL/elections2016#name -->
<owl:DatatypeProperty rdf:about="http://www.kdm.com/OWL/elections2016#name"/>
<!-- http://www.kdm.com/OWL/elections2016#occupation -->
<owl:DatatypeProperty rdf:about="http://www.kdm.com/OWL/elections2016#occupation"/>
<!-- http://www.kdm.com/OWL/elections2016#spouse -->
<owl:DatatypeProperty rdf:about="http://www.kdm.com/OWL/elections2016#spouse"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.kdm.com/OWL/elections2016#ClasseSociale -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#ClasseSociale">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Votes"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Democratic -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Democratic">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Political_parties"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Nominee_democratic -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Nominee_democratic">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Democratic"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Nominee_republic -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Nominee_republic">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Republic"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Periode -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Periode">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Votes"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Political_parties -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Political_parties"/>
<!-- http://www.kdm.com/OWL/elections2016#Region -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Region">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Votes"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Republic -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Republic">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Political_parties"/>
</owl:Class>
<!-- http://www.kdm.com/OWL/elections2016#Votes -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#Votes"/>
<!-- http://www.kdm.com/OWL/elections2016#VotingAge -->
<owl:Class rdf:about="http://www.kdm.com/OWL/elections2016#VotingAge">
<rdfs:subClassOf rdf:resource="http://www.kdm.com/OWL/elections2016#Votes"/>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.kdm.com/OWL/elections2016#Alabama -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Alabama">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Region"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#April -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#April">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#August -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#August">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#Between_18_and_49 -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Between_18_and_49">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#VotingAge"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#December -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#December">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#DemocraticNominee -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#DemocraticNominee">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Democratic"/>
<name>HillaryClinton</name>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#DonaldTrump -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#DonaldTrump">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_republic"/>
<age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">70</age>
<asset>4,500,000,000</asset>
<currentLocation>NewYork</currentLocation>
<occupation>Businessman</occupation>
<occupation>MelaniaKnauss</occupation>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#Etudiant -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Etudiant">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#ClasseSociale"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#February -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#February">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#HillaryClinton -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#HillaryClinton">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Nominee_democratic"/>
<currentLocation>chicago</currentLocation>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#Ingenieur -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Ingenieur">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#ClasseSociale"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#January -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#January">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#July -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#July">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#June -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#June">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#March -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#March">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#May -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#May">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#New_York -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#New_York">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Region"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#November -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#November">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#October -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#October">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#Over_50 -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Over_50">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#VotingAge"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#Professeur -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Professeur">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#ClasseSociale"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#RepublicNominee -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#RepublicNominee">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Republic"/>
<name>Donald Trump</name>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#September -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#September">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Periode"/>
</owl:NamedIndividual>
<!-- http://www.kdm.com/OWL/elections2016#Texas -->
<owl:NamedIndividual rdf:about="http://www.kdm.com/OWL/elections2016#Texas">
<rdf:type rdf:resource="http://www.kdm.com/OWL/elections2016#Region"/>
</owl:NamedIndividual>
</rdf:RDF>
e.g: I'd like to get the inviduals that has a data property value equals to Hillary clinton^^xsd:string and Texas^^xsd:string , and then matching the relations between those individuals from their object properties.
It is possible here a short previous of the 2 steps you need to make it work.
Push your csv file into the ontology. Using owl-api you will have to create 'propertyAssertion' for each value. Using jena, you will have to create a 'statement' for each value.
Add a reasoner to your ontology and transform the pattern you want to "match" into a class expression (OWLClassExpression in the owlapi).
Ask the reasoner for the individuals, properties, classes of the entities that "match" the ClassExpression.
Here a simple example of individual querying using the owlapi reasoning interface an example:
OWLClassExpression expr = OWL.min(OWL.DataProperty("http://myDataProperty"), 1)
namedIndividuals = reasoner.getInstances(expr)
This simple example is a pattern matcher for individuals that have at least one property "http://myDataProperty".
When I was trying to add an image to an orbeon form, I found that in some cases works fine, and in other does not.
For example, a simple code with a form that uses a remote image by URL:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<xh:head>
<xh:title>Form with Image by URL</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<control-3>http://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif</control-3>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-3-bind" ref="control-3" name="control-3" type="xf:anyURI"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>UrlImage</application-name>
<form-name>UrlImage</form-name>
<title xml:lang="en">Form with Image by URL</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<section-1>
<label>Untitled Section</label>
</section-1>
<control-3>
<label>This is a remote image</label>
</control-3>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:output id="control-3-control" bind="control-3-bind" mediatype="image/*">
<xf:label ref="$form-resources/control-3/label"/>
<!-- No hint? -->
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:output>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
The important part is the URL http://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif, that works fine. But if you use a secure connection like https://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif is not able to obtain the image.
I am not sure, maybe the problem is similar to this one Trusting all certificates using HttpClient over HTTPS
This is something that can be override by the configuration?
Can I use an image by using the URL from a https site without adding the certificate for each server in my java store?
There are properties to configure that, but you have to be careful, because in general you really shouldn't trust all certificates!
Your example of https://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif works from Chrome without warning or error, for example, so I would expect it to work from the JVM as well. Maybe the JVM is not configured with the same set of CAs as the browser. In which case the JVM can be configured to add some, although it's a bit tricky.
Probably this behaviour is due to Orbeon does not uses the image URL directly, making a intermediate processing in the Orbeon "server-media".
Ok, seems that at the end, it only works if I add the certificate to the keystore of orbeon defined in oxf.http.ssl.keystore.uri. But this is only valid if I know the servers from where the images will be linked. Not a valid solution to link any image from any server. Java allows to disable this behaviour. Is it possible in Orbeon?
This is my first post to stack overflow so I request for an encouraging reply :) (bonus reputations)
I am trying to use SWRL to do some calculations for me. To imitate the problem, I have created a small ontology using protege 4.3. It has only two classes Parent and Son. Instances include 1 parent (John) and three sons (son1, son2, son3). John is linked with 3 sons using "hasSon" object property. Age of each son is mentioned using "hasAge" data-type property (integers).
Question-1: I need to first check that how many instances are linked with a given Parent(John) using hasSon property. How this can be achieved in SWRL?
Question-2: After knowing the number of Sons then I have to add their ages to get the total age of all the Sons again using SWRL?
For me, this require a loop like addition (a=a+b) but I dont know how this will work in SWRL. I have attached the OWL code for you.
(Please note that in actual ontology the linked instances are not 3 but are varying and counting them is part of the problem)
Thanks in advance
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY parenttrial "http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#"
xml:base="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:parenttrial="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#hasSon -->
<owl:ObjectProperty rdf:about="&parenttrial;hasSon">
<rdfs:domain rdf:resource="&parenttrial;Parent"/>
<rdfs:range rdf:resource="&parenttrial;Son"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#hasAge -->
<owl:DatatypeProperty rdf:about="&parenttrial;hasAge"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Parent -->
<owl:Class rdf:about="&parenttrial;Parent"/>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son -->
<owl:Class rdf:about="&parenttrial;Son"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#JohnF -->
<owl:NamedIndividual rdf:about="&parenttrial;JohnF">
<rdf:type rdf:resource="&parenttrial;Parent"/>
<hasSon rdf:resource="&parenttrial;Son1"/>
<hasSon rdf:resource="&parenttrial;Son2"/>
<hasSon rdf:resource="&parenttrial;Son3"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son1 -->
<owl:NamedIndividual rdf:about="&parenttrial;Son1">
<rdf:type rdf:resource="&parenttrial;Son"/>
<hasAge rdf:datatype="&xsd;integer">3</hasAge>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son2 -->
<owl:NamedIndividual rdf:about="&parenttrial;Son2">
<rdf:type rdf:resource="&parenttrial;Son"/>
<hasAge rdf:datatype="&xsd;integer">4</hasAge>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son3 -->
<owl:NamedIndividual rdf:about="&parenttrial;Son3">
<rdf:type rdf:resource="&parenttrial;Son"/>
<hasAge rdf:datatype="&xsd;integer">5</hasAge>
</owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net -->
Answer 1: There is no way through SWRL to check how many instances are connected to a certain property through SWRL. You are better off writing a sparql query with COUNT for this. Alternatively you can use an ontology framework and use an Iteratorto figure out the counts.
Answer 2: There is no way to loop a SWRL rule, perform an operation and return a value. SWRL rules are meant to add extra information about relations and not act as a programming language.
Solution: You are far better off using a ontology framework like Apache Jena or Owl api and writing a program to handle this instead of relying on SWRL. SWRL supports monotonic inferences only and thus cannot be used to loop over data in an ontology. Trying to do so will cause the rule to get executed infinitely.
Instead write a bit of code to do this. Refer to owl api or Jena ontology api and sparql in order to learn more on how to use these technologies.
I need to convert my RDF graph document into OWL (1 or 2) recognized by Protege 3.x. There is a W3C Recommendation for mapping OWL 2 Web Ontology Language Mapping to RDF Graphs which says that to declare Object Properties from RDF graphs one should add the rdf:type owl:ObjectProperty element. I have found problems for expressing OWL object properties with RDF graph formalisms in the following code:
<rdf:Property rdf:about="&uni;isTaughtBy">
<rdf:type rdf:resource="&owl;ObjectProperty"/>
<rdfs:domain rdf:resource="&uni;Course"/>
<rdfs:range rdf:resource="&uni;Proffessor"/>
</rdf:Property>
With the following specified namespaces:
xmlns:uni="http://www.mydomain.org/uni-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
Unfortunately, the upper mentioned code is not recognized and thus shown in the Protege 3.x IDE.
The following code is readable by Protege 4 (recommended version). Copy paste the block and save it in a new file, you should then be able to read it with Protege:
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY uni-ns "http://www.mydomain.org/uni-ns#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.mydomain.org/uni-ns#"
xml:base="http://www.mydomain.org/uni-ns"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:uni-ns="http://www.mydomain.org/uni-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.mydomain.org/uni-ns#"/>
<owl:ObjectProperty rdf:about="&uni-ns;isTaughtBy">
<rdfs:domain rdf:resource="&uni-ns;Course"/>
<rdfs:range rdf:resource="&uni-ns;Professor"/>
</owl:ObjectProperty>
<owl:Class rdf:about="&uni-ns;Course"/>
<owl:Class rdf:about="&uni-ns;Professor">
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
</owl:Class>
</rdf:RDF>
I have a simple ontology designed using Protégé 3.4. I've introduced some "Necessary & Sufficient" conditions, like in the defintion of the Table class:
http://postimage.org/image/f37xliqad/
Forget the two first conditions, the third one is easier to understand :)
The OWL code generated is:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#"
xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#"
xmlns:assert="http://www.owl-ontologies.com/assert.owl#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:sqwrl="http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:swrl="http://www.w3.org/2003/11/swrl#"
xmlns:swrlb="http://www.w3.org/2003/11/swrlb#"
xmlns="http://www.owl-ontologies.com/Ontology1317586695.owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:swrla="http://swrl.stanford.edu/ontologies/3.3/swrla.owl#"
xml:base="http://www.owl-ontologies.com/Ontology1317586695.owl">
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://swrl.stanford.edu/ontologies/3.3/swrla.owl"/>
<owl:imports rdf:resource="http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl"/>
</owl:Ontology>
...
<owl:Class rdf:ID="Table">
<owl:disjointWith>
<owl:Class rdf:ID="Chair"/>
</owl:disjointWith>
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Resource">
<rdf:first>
<owl:Restriction>
<owl:onProperty>
<owl:ObjectProperty rdf:ID="has_coarseArea"/>
</owl:onProperty>
<owl:someValuesFrom>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<owl:Class rdf:about="#MMAround09"/>
<owl:Class rdf:about="#MMAround1"/>
<owl:Class rdf:about="#MMAround12"/>
<owl:Class rdf:about="#MMAround15"/>
<owl:Class rdf:about="#MMAround2"/>
</owl:unionOf>
</owl:Class>
</owl:someValuesFrom>
</owl:Restriction>
</rdf:first>
<rdf:rest rdf:parseType="Resource">
<rdf:first>
<owl:Restriction>
<owl:someValuesFrom>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<owl:Class rdf:about="#MMAround07"/>
<owl:Class rdf:about="#MMAround08"/>
</owl:unionOf>
</owl:Class>
</owl:someValuesFrom>
<owl:onProperty>
<owl:ObjectProperty rdf:ID="has_coarseCentroidHeight"/>
</owl:onProperty>
</owl:Restriction>
</rdf:first>
<rdf:rest>
<rdf:List>
<rdf:first>
<owl:Restriction>
<owl:someValuesFrom>
<owl:Class rdf:about="#Horizontal"/>
</owl:someValuesFrom>
<owl:onProperty>
<owl:ObjectProperty rdf:about="#has_orientation"/>
</owl:onProperty>
</owl:Restriction>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:List>
</rdf:rest>
</rdf:rest>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
<rdfs:subClassOf>
<owl:Class rdf:ID="Furniture"/>
</rdfs:subClassOf>
</owl:Class>
If I've understood well, these conditions are interpreted as restrictions, and managed as a super-class of the Table class.
So, if I load my ontology and the class Table with Jena:
1. String NS = "http://www.owl-ontologies.com/Ontology1317586695.owl#";
2. OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
3. model.read(OWL_FILE_NAME);
4. OntClass Table = model.getOntClass( NS + "Table" );
The NS variable has a correct value since the Table OntClass is loaded correctly. Then, while executing the following code, the line the line 10 should be reached, but it's not:
5. for (Iterator<OntClass> supers = Table.listSuperClasses(true); supers.hasNext(); ) {
6. OntClass superClass = supers.next();
7.
8. if (superClass.isRestriction())
9. {
10. System.out.println("Restriction found");
11. }
12. }
I've tried with Table.listEquivalentClasses() as well without success.
Any idea about what I'm loosing in the way?
UPDATE
Testing the code nicely implemented by Ian and shared here: https://gist.github.com/4065533, it works fine. But changing
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF );
by
OntModel m = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
it stops working. It seems that Pellet doesn't recognize the restrictions as super-clases of the class.
The most common cause of such problems is that the URI's don't match exactly. If you had included a fragment of your actual data, as Turtle or RDF XML, and if you had stated what the value of NS was, that could be ruled in or out definitively.
Generally speaking, posting a screengrab of the user interface of your editing tool is not nearly as useful to people who want to help you as posting the source itself.
Update
Well, it works for me. I've put my (hint: runnable) code in a gist https://gist.github.com/4065533. The only differences I can spot between my code and yours are the OWL_FILE_NAME var (presumably you have checked that you are loading the right input source?), and the use of Pellet which I don't have available at the moment. You could check that the source of the problem is not Pellet by swapping to the Jena rule reasoner, but I strongly doubt that Pellet will be a factor.
Please try my gist code and see if that helps illuminate the problem. If you still can't get your code working, please post a runnable minimal test case. It should be runnable without having to guess or fill-in any missing information.