I try to add a bit of ontology to a (public) RDF dataset (wordnet), specifically I need to differentiate between LexicalEntries for Verbs and Nouns, separated as two subclasses. Following examples on the web and in the OWL standard, I assumed that
:LexicalEntryNoun a owl:Class ;
rdfs:subClassOf
[ a owl:Restriction ;
owl:onProperty wn:part_of_speech ;
owl:hasValue wn:noun
] .
should build a class LexicalEntryNoun, but the query (in jena fuseki)
prefix : <http://gerastree.at/2017/litonto#>
SELECT *
WHERE {
?s a :LexicalEntryNoun.
}
gives an empty result. The two URI which should be returned are included in the class represented by a blank node, which stands for the restriction, but are not reported as LexicalEntryNoun as reported in other queries.
i am new to OWL and do not find many examples of OWL in turtle syntax. Where is my error?
Thank you for help!
I constructed a very small subset of data which is loaded together with the OWL reasoner http://jena.hpl.hp.com/2003/OWLFBRuleReasoner:
#prefix wn31: <http://wordnet-rdf.princeton.edu/wn31> .
#prefix lemon: <http://lemon-model.net/lemon#> .
#prefix nlp: <http://gerastree.at/nlp_2015#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix lit: <http://gerastree.at/lit_2014#> .
#prefix wn: <http://wordnet-rdf.princeton.edu/ontology#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix ns: <http://www.example.org/ns#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix : <http://gerastree.at/2017/litonto#> .
<http://wordnet-rdf.princeton.edu/wn31/%27s+Gravenhage-n>
a _:b0 , owl:Thing , rdfs:Resource , lemon:LexicalEntry ;
lemon:canonicalForm <http://wordnet-rdf.princeton.edu/wn31/%27s+Gravenhage-n#CanonicalForm> ;
lemon:sense <http://www.lexvo.org/page/wordnet/30/noun/%27s_gravenhage_1_15_00> , <http://wordnet-rdf.princeton.edu/wn31/%27s+Gravenhage-n#1-n> ;
wn:part_of_speech wn:noun ;
owl:sameAs <http://wordnet-rdf.princeton.edu/wn31/%27s+Gravenhage-n> .
<http://wordnet-rdf.princeton.edu/wn31/%27hood-n>
a _:b0 , owl:Thing , rdfs:Resource , lemon:LexicalEntry ;
lemon:canonicalForm <http://wordnet-rdf.princeton.edu/wn31/%27hood-n#CanonicalForm> ;
lemon:sense <http://www.lexvo.org/page/wordnet/30/noun/%27hood_1_15_00> , <http://wordnet-rdf.princeton.edu/wn31/%27hood-n#1-n> ;
wn:part_of_speech wn:noun ;
owl:sameAs <http://wordnet-rdf.princeton.edu/wn31/%27hood-n> .
:LexicalEntryNoun a owl:Class ;
rdfs:subClassOf
[ a owl:Restriction ;
owl:onProperty wn:part_of_speech ;
owl:hasValue wn:noun
] .
as already posted on the Apache Jena Users mailing list, the answer is:
Change the subclassof to an equivalence. Since both resources:
http://wordnet-rdf.princeton.edu/wn31/%27s+Gravenhage-n
http://wordnet-rdf.princeton.edu/wn31/%27hood-n
would fall inside the :LexicalEntryNoun class and show up in his SPARQL query.
Regards, Barry
Related
I need to check the violations to the OWL2DL profile in this simplified ontology:
#prefix : <http://www.onto.com/test#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#base <http://www.onto.com/test#> .
<http://www.onto.com/test#> rdf:type owl:Ontology ;
rdfs:label "Test"#en .
xsd:date rdf:type rdfs:Datatype .
<http://www.onto.com/test#hasPart2> rdf:type owl:ObjectProperty .
<http://www.onto.com/test#isPartOf> rdf:type owl:ObjectProperty ,
owl:TransitiveProperty ;
rdfs:domain <http://www.onto.com/test#TestRestriction> .
<http://www.onto.com/test#isPartOf2> rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf owl:topObjectProperty ;
rdf:type owl:TransitiveProperty ;
rdfs:domain <http://www.onto.com/test#A2PartOfClass> .
<http://www.onto.com/test#maxCardinality0> rdf:type owl:ObjectProperty .
<http://www.onto.com/test#A2PartOfClass> rdf:type owl:Class .
<http://www.onto.com/test#TestRestriction> rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty <http://www.onto.com/test#isPartOf2> ;
owl:minQualifiedCardinality "0"^^xsd:nonNegativeInteger ;
owl:onClass <http://www.onto.com/test#A2PartOfClass>
] ;
rdfs:comment "A1 PartOf Class Comment"#en ;
rdfs:label "A1PartOfClass"#en .
<http://www.onto.com/test#isPartOf2> rdf:type owl:Class .
To this end, I have the following code in the OWL API to check for the violations of the given ontology to the OWL2DL profile.
OWL2DLProfile profile = new OWL2DLProfile();
OWLProfileReport report = profile.checkOntology(ontology);
for(OWLProfileViolation v:report.getViolations()) {
System.out.println(v);
}
In the console I'm getting this:
Use of non-simple property in a restriction: ObjectMinCardinality(0 <http://www.onto.com/test#isPartOf2> <http://www.onto.com/test#A2PartOfClass>) [SubClassOf(<http://www.onto.com/test#TestRestriction> ObjectMinCardinality(0 <http://www.onto.com/test#isPartOf2> <http://www.onto.com/test#A2PartOfClass>)) in OntologyID(OntologyIRI(<http://www.onto.com/test#>) VersionIRI(<null>))]
And I would like to retrieve the URIs involved, i.e., http://www.onto.com/test#isPartOf2, http://www.onto.com/test#A2PartOfClass
as well as the message of the violation, i.e., Use of non-simple property in a restriction.
How can I achieve this?
You can get the signature of the axiom involved in the violation as follows:
violation.getAxiom()
.signature()
.forEach(System.out::println);
There is no easy way to get the type of the violation besides doing the following:
violation.getClass().getSimpleName()
which will return UseOfNonSimplePropertyInCardinalityRestriction.
I have an ontology with Person and City classes. People travel to cities and this travel is represented in the traveledTo object property. I'd like to add a WorldTraveler class. People are world travelers if they have traveled to 2 or more cities. How can I do this in my ontology?
#prefix : <http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#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#> .
#base <http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64> .
<http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64> rdf:type owl:Ontology .
:traveledTo rdf:type owl:ObjectProperty ;
rdfs:domain :Person ;
rdfs:range :City .
:City rdf:type owl:Class .
:Person rdf:type owl:Class .
:Bob rdf:type owl:NamedIndividual ,
:Person ;
:traveledTo :London ,
:Ottawa ,
:Paris .
:Brussels rdf:type owl:NamedIndividual ,
:City .
:London rdf:type owl:NamedIndividual ,
:City .
:Ottawa rdf:type owl:NamedIndividual ,
:City .
:Paris rdf:type owl:NamedIndividual ,
:City .
:Ralph rdf:type owl:NamedIndividual ,
:Person ;
:traveledTo :Rome .
:Rome rdf:type owl:NamedIndividual ,
:City .
:Washington rdf:type owl:NamedIndividual ,
:City .
I tried adding the following Class but it didn't seem to work:
:WorldTraveler rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( :Person
[ rdf:type owl:Restriction ;
owl:onProperty :traveledTo ;
owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger ;
owl:onClass :City
]
) ;
rdf:type owl:Class
] .
I believe that my reasoner may not be able to infer that Ralph is not a WorldTraveler because of the open world assumption. However, it should be able to infer that Bob is a WorldTraveler because he has traveled to 3 cities.
Thanks for your help.
Chris
In addition to the open world assumption (OWA), there exists the unique name assumption (UNA). OWL does make the former (OWA) and does not make the latter (UNA).
You should explicitely make individuals different.
In the Turtle syntax, it should look like this:
:London owl:differentFrom :Paris .
or
[ rdf:type owl:AllDifferent ;
owl:distinctMembers ( :Brussels :London :Ottawa :Paris :Rome :Washington )
] .
I'm learning about reasoning and knowledge engineering and I made up the following example:
#prefix : <http://example.org#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#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#> .
#base <http://www.w3.org/2002/07/owl> .
[ rdf:type owl:Ontology
] .
:value rdf:type owl:DatatypeProperty ;
rdfs:range xsd:string .
:humiditySensor rdf:type owl:Class ;
rdfs:subClassOf :sensor .
:location rdf:type owl:Class .
:room rdf:type owl:Class ;
rdfs:subClassOf :location .
:sensor rdf:type owl:Class.
:temperatureSensor rdf:type owl:Class ;
rdfs:subClassOf :sensor .
:temp1 rdf:type owl:NamedIndividual ,
:temperatureSensor ;
:room 201 ;
:value 29 .
I'm trying to infer that temp1 is of type sensor. When I pose the following query to Eye reasoner (backward chaining) I get nothing, i.e. the fact that temp1 is of type sensor is not inferred, even though subClassOf is transitive:
#prefix : <http://example.org#>.
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
{
?x a :sensor.
?x :value ?y.
}
=>
{
?x :value ?y.
}.
If I write a couple of rules manually to express this transitivity property of subClassOf, it will work. However, CWM reasoner (forward chaining) in the proof states correctly that temp1 is of type sensor, without the additional rules.
Is this because of the difference between forward and backward chaining?
I hope I'm making sense.
I have developed an ontology and I want to add the following SWRL in protege:
Divider_intersection(?node), is_extent_of(?node, ?s), builds(?s, ?l),Segment(?s),Lane(?l),detailed_partition(?d), builds(?l, ?d)-> is_divided_at(?d, ?node)
with this I wish to add an object property, is_divided_at, between an individual from detailed_partition (?d) and a node that is classified as a divider_intersection if it is the extent of a segment (?s) that build a lane (?l) which then build the detailed?partition (?d). As noted here, I am looking for NamedIndividuals, hence I presume the SWRL should do the job.
Further research, I found Rolification (1, 2, 3) as a possible answer however I have never used it before, but I made the following chain:
r_Divider_intersection o is_extent_of o r_Segment o builds o r_Lane o builds o r_detailed_partition
still I do not get the answer. Any idea what is wrong?
Your approach works, and without seeing your ontology (your link requires permissions, and offsite links aren't very helpful anyhow) we can't see why your particular construction of it works. One thing that jumps out from your question is that the it looks like your is_divided_at property has its arguments (?d,?node) in the opposite order from what the property chain axiom would produce. Anyhow, here's a working example.
#prefix : <urn:ex:#> .
#prefix ex: <urn:ex:#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:isDividedAt a owl:ObjectProperty ;
owl:propertyChainAxiom ( ex:_DividerIntersection ex:isExtentOf ex:_Segment ex:builds ex:_Lane ex:builds ex:_DetailedPartition ) .
ex:Segment a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_Segment
] .
ex:_DetailedPartition
a owl:ObjectProperty .
ex:DividerIntersection
a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_DividerIntersection
] .
ex:_Segment a owl:ObjectProperty .
ex:_Lane a owl:ObjectProperty .
ex:builds a owl:ObjectProperty .
ex:dividerIntersection0
a owl:NamedIndividual , ex:DividerIntersection ;
ex:isExtentOf ex:segment0 .
<urn:ex:> a owl:Ontology .
ex:detailedPartition0
a owl:NamedIndividual , ex:DetailedPartition .
ex:_DividerIntersection
a owl:ObjectProperty .
ex:segment0 a owl:NamedIndividual , ex:Segment ;
ex:builds ex:lane0 .
ex:DetailedPartition a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_DetailedPartition
] .
ex:isExtentOf a owl:ObjectProperty .
ex:lane0 a owl:NamedIndividual , ex:Lane ;
ex:builds ex:detailedPartition0 .
ex:Lane a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_Lane
] .
I want to write a nested DL query in Protege. I can run a simple query like:
Person and hasFather value PersonA
It retrieves the name of all the Persons whose Father is PersonA. But I want that PersonA value should also be retrieved from some query like
Person and hasFather value (Person and hasSon value PersonB)
It is showing syntax error in Protege. Please help me with the correct format.
The reason that
Person and hasFather value (Person and hasSon value PersonB)
is a syntax error is not that it's “nested”, but that value requires an individual, but (Person and hasSon value PersonB) is a class. If you use
Person and hasFather some (Person and hasSon value PersonB)
instead, you should be all set. This query asks for individuals that are people that have a father that is a person and has person B as a son. That is, it's asking for siblings of person B, i.e., other children of person B's father.
For instance, here's a query about the Simpson family where Bart and Lisa each have Homer as their father, and Homer has each of them as a child:
The data is:
#prefix : <http://www.example.org/families#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix families: <http://www.example.org/families#> .
<http://www.example.org/families>
a owl:Ontology .
families:Person a owl:Class .
families:hasFather a owl:ObjectProperty .
families:hasChild a owl:ObjectProperty .
families:Bart a owl:NamedIndividual , families:Person ;
families:hasFather families:Homer .
families:Lisa a owl:NamedIndividual , families:Person ;
families:hasFather families:Homer .
families:Homer a owl:NamedIndividual , families:Person ;
families:hasChild families:Bart , families:Lisa .
families:Milhouse a owl:NamedIndividual , families:Person .