∀Defense_Argument, OldCase, NewCase,
applied_to(Defense_Argument, OldCase),
similar_to(OldCase, NewCase) ⇒ applied_to(Defense_Argument, NewCase).
I want to represent this using Protege. Thanks in advance.
Related
I am new to rdflib (and RDF/OWL), so I'm having some trouble understanding the rdflib documentation in the absence of concrete examples / layman's guides.
I have an OWL subClass for which I want to create three possible values. I found this official tennis example with the "end result" I assume I would need, which I wanted to recreate with my data using rdflib.
I found rdflib's "rdflib.extras.infixowl.EnumeratedClass", and tried modifying and running the sample code, but my serialized output doesn't resemble the tennis example output.
My code:
from rdflib import URIRef, BNode, Literal, Namespace, Graph
from rdflib.namespace import RDF, RDFS, OWL
from rdflib.extras.infixowl import EnumeratedClass, Individual
from rdflib.collection import Collection
from rdflib.util import first
n = Namespace("http://example.org/example/")
g = Graph()
g.bind("owl",OWL)
g.bind("", n)
my_class = n.my_class
g.add((my_class, RDF.type, OWL.Class))
g.add((my_class, RDFS.subClassOf, OWL.Thing))
g.add((my_class, RDF.ID, Literal("my_class")))
my_subclass = n.my_subclass
g.add((my_subclass, RDF.type, OWL.Class))
g.add((my_subclass, RDF.ID, Literal("my_subclass")))
g.add((my_subclass, OWL.subClassOf, my_class))
Individual.factoryGraph = g
my_list = EnumeratedClass(n.my_list,
members=[n.listitem1,
n.listitem2,
n.listitem3])
col = Collection(g, first(
g.objects(predicate=OWL.oneOf,
subject=my_list.identifier)))
[g.qname(item) for item in col]
This gives me:
<owl:Class rdf:about="http://example.org/example/my_subclass">
<rdf:ID>my_subclass</rdf:ID>
<owl:oneOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://example.org/example/listitem1"/>
<rdf:Description rdf:about="http://example.org/example/listitem2"/>
<rdf:Description rdf:about="http://example.org/example/listitem3"/>
</owl:oneOf>
<owl:subClassOf rdf:resource="http://example.org/datacategories/my_class"/>
</owl:Class>
and not the "first/rest" format seen in the official tennis example.
First: Is this wrong?
Second: If someone can explain to me what the effective difference is between these two formats, and whether there is a preference, I would really appreciate it.
Thanks!
This is my ontology created with protege 5 .
If i make cl1 and cl2 disjoint, then the ontology is being inconsistent , but if i uncheck is_friend_of reflexive , the ontology is not inconsistent any more . whats wrong with my ontology ?
I want only cl1 class individuals have is_friend_of property.
Reflexivity of :is_friend_of is essential for inconsistency.
Take a look at Reasoner > Inconsistent ontology explanation :
I'll try to translate this explanation into (poor) English:
Since :is_friend_of is reflexive, then :c2_inst :is_friend_of :c2_inst.
Since the domain of :is_friend_of is :cl1, then c2_inst rdf:type :cl1.
Also, c2_inst rdf:type :cl2.
But :cl1 and :cl2 are disjoint — contradiction.
In fact, the domain of every reflexive property is owl:Thing.
As a workaround, you could uncheck reflexivity of is_friend_of and define :cl1 in this way:
Class: cl1
EquivalentTo:
is_friend_of some owl:Thing,
is_friend_of some Self
We know that in Protege is possible to create axioms with role chain and since Protege is based on OWLAPI should be possible to create them.
I did not found examples in the official documentation, so it is possible to do it?
One example here:
With the OWL syntax we have:
Declaration( ObjectProperty( :isEmployedAt ) )
ObjectPropertyAssertion( :isEmployedAt :Martin :SC )
SubObjectPropertyOf( ObjectPropertyChain( :isEmployedAt :isPartOf ) :isEmployedAt)
So, what is the equivalent in OWLAPI?
OWLDataFactory::getOWLSubPropertyChainOfAxiom(java.util.List<? extends OWLObjectPropertyExpression> chain,OWLObjectPropertyExpression superProperty)
See Javadoc
I have a file containing an ontology without an ontology id (the ontology tag <Ontology/> is empty). The used serialization format is RDF/XML. My goal is to serialize the file, set an ontology id and write the file back using the OWLAPI. Unfortunatly I don't know how to do this. I tried the following:
ontology = ontologyManager.loadOntologyFromOntologyDocument(new File("filename"));
ontologyManager.setOntologyDocumentIRI(ontology, IRI.create("http://www.mydesiredIri.com/abc"));
ontologyManager.saveOntology(ontology,new FileOutputStream(new File("outputfile")));
By running the code, the Ontology-ID is not added to the ontology. Instead of <Ontology rdf:about="http://www.mydesiredIri.com/abc"/> the tag is still emtpy. What I am doing wrong?
Thank you!
Kind regards
OWLOntologyManager.setOntologyDocumentIRI() is for setting the document IRI of the ontology, not the ontology IRI itself. The difference between the two is that the document IRI is a resolvable URL or a file path (i.e., int can be used to parse the ontology), while the ontology IRI is the symbolic name of the ontology (it does not need to be resolvable and it can even be missing - which is the case for anonymous ontologies).
To set the ontology IRI, use:
//versionIRI can be null
OWLOntologyID newOntologyID = new OWLOntologyID(ontologyIRI, versionIRI);
// Create the change that will set our version IRI
SetOntologyID setOntologyID = new SetOntologyID(ontology, newOntologyID);
// Apply the change
manager.applyChange(setOntologyID);
After this, save the ontology as usual.
I'm new at OWL-API.
I need to represent an intersection of N concepts
So, intersectionOf (C1, C2, ..... CN).
IntersectionOf has two arguments, but how can I do the general purpose solution?
Is it good enough to build an HashSet and then put it into the arguments?
OWLDataFactory has methods for obtaining an intersection that accept collections - usually sets- of class expressions. I believe that's what you're after.
Just like Ignazio said, but with code:
Java Code:
OWLDataFactory factory = manager.getOWLDataFactory();
Set<OWLClassExpression> mySet = new HashSet<OWLClassExpression>();
factory.getOWLObjectIntersectionOf(mySet);
HTH