On 25/01/13 21:44, Emanuel Santos wrote:
Hi,
Thanks for the reply.
Yes, I understood that.
But what is strange is that the class that gives an error (of the first
error) is defined in my file as
<owl:Class rdf:about="http://bla.bla/B">
So it should be defined in the basic model as a class. Right ?
The most likely explanation is a mismatch in the URIs.
Dave
On 25 January 2013 21:40, Tayfun Gökmen Halaç
<[email protected]>wrote:
2013/1/25 Dave Reynolds <[email protected]>
On 25/01/13 14:25, Tayfun Gökmen Halaç wrote:
Hi,
Nothing changes if the model creation is done by
ModelFactory.**createOntologyModel(**OntModelSpec.OWL_MEM_TRANS_**INF)
in my
example code.
What does "as(OntClass.class) part doesn't work" mean? If you get an
exception like com.hp.hpl.jena.ontology.**ConversionException, your
class
resources do not have a type assertion.
It means there's no type assertion on that class :)
By default OntModels work in strict mode, so to know that something can
be
treated as a class it is looking for a statement that it is of type
owl:Class. If you have inference this may be inferred for you but in any
case it is best practice to explicitly declare classes.
Here's the example.
OntModel model = ModelFactory
.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
OntClass classA = model.createClass("http://bla.bla/A");
Resource classB = model.createResource("http://bla.bla/B");
classA.addDisjointWith(classB);
ExtendedIterator<OntClass> classes = model.listClasses();
while (classes.hasNext()) {
OntClass ontClass = (OntClass) classes.next();
System.out.println(ontClass);
}
If you create model with
OntModelSpec.OWL_MEM_MICRO_RULE_INF,
OntModelSpec.OWL_MEM_MINI_RULE_INF, OntModelSpec.OWL_MEM_RULE_INF,
OntModel infers the class assertion for the class B. But, it is not done
by OntModelSpec.OWL_MEM, OntModelSpec.OWL_MEM_RDFS_INF,
OntModelSpec.OWL_MEM_TRANS_INF.
You can use ontmodel.setStrictMode(false) to disable this checking.
Dave
Best,
Tayfun
2013/1/25 Dave Reynolds <[email protected]>
You don't need to load your ontology twice. An OntModel is just a
wrapper
round an underlying model so you can construct both a with-inference
and
a
without-inference OntModel over the same Model.
Dave
On 25/01/13 03:35, Emanuel Santos wrote:
Hi Tayfun,
Thank you so much!
That way only works if I choose a model without any class-hierarchy
inference. Of course.
When I'm working with a model with class-hierarchy inference (e.g.
OWL_MEM_TRANS_INF
ou a reasoner) can I still get the direct Disjointwith classes ?? I
tried
it getting them using the baseModel but the "as(OntClass.class)" part
doesn't work. If there isn't any other way...I'm doomed to load 2x my
ontology... it is not good :) Any ideas ?
Thanks!
best,
Emanuel
On 24 January 2013 22:32, Tayfun Gökmen Halaç
<[email protected]>****wrote:
Hi Emanuel,
Not with a direct method. You can obtain those sets with a modified
version
of previous solution.
// create the ontology...
OntModel model = ModelFactory.****createOntologyModel();
OntClass classA = model.createClass("http://bla.****bla/A<
http://bla.bla/A>
");
OntClass classB = model.createClass("http://bla.****bla/B<
http://bla.bla/B>
");
OntClass classC = model.createClass("http://bla.****bla/C<
http://bla.bla/C>
");
OntClass classD = model.createClass("http://bla.****bla/D<
http://bla.bla/D>
");
classA.addDisjointWith(classB)****;
classA.addDisjointWith(classC)****;
classC.addDisjointWith(classD)****;
// list disjoint sets...
ResIterator classesHasDisjoint = model
.listResourcesWithProperty(****OWL.disjointWith);
while (classesHasDisjoint.hasNext()) {
OntClass cls = classesHasDisjoint.next().as(****OntClass.class);
List<OntClass> disjointList = cls.listDisjointWith().toList(****);
disjointList.add(0, cls);
System.out.println(****disjointList);
}
Console output:
[http://bla.bla/A, http://bla.bla/C, http://bla.bla/B]
[http://bla.bla/C, http://bla.bla/D]
Best,
Tayfun
2013/1/24 Emanuel Santos <[email protected]>
Hi,
Thanks for the reply!
Maybe I was not clear.
For instance, given these classes:
<owl:Class rdf:about="http://bla#A!>
<owl:disjointWith rdf:resource="http:/bla#B"/>
<owl:disjointWith rdf:resource="http:/bla#C"/>
</owl:Class>
<owl:Class rdf:about="http://bla#C">
<owl:disjointWith rdf:resource="http:/bla#D"/>
</owl:Class>
I want to obtain these sets : {A,B,C} and {C,D}.
Only the direct classes.
Thanks!
On 24 January 2013 14:03, Fabio Aiub Sperotto <[email protected]
wrote:
Hi Emanuel,
I don't know if I have a good solution for you (I'm not the best
programmer), but recently I made this: Search for all classes of
ontology.
For each class X, return the set of classes that is disjoint with
X:
model.read(new InputStreamReader(in), ""); //read the
ontology
Iterator classes = model.listClasses(); //list all
classes
in
ontology
while (classes.hasNext()){
OntClass ontologyClass = (OntClass) classes.next();
//get
one
class
//get list of disjoint classes from ontologyClass
Iterator disjointClasses =
ontologyClass.****listDisjointWith();
while(disjointClasses.hasNext(****)){
System.out.print("Class
"+ontologyClass.getLocalName()
****+"
is
disjoint with: ");
System.out.println(****disjointClasses.next());
}
System.out.println("");
}
This will help? My some mistake?
2013/1/24 Emanuel Santos <[email protected]>
Hi,
I just started using Jena.
Any easyway to get all set of classes "disjointWith" ?
Thanks
--
Fabio Aiub Sperotto
Mestrando em Modelagem Computacional
about.me/fabiosperotto
www.twitter.com/fabio_gk