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. 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 >>>>> >>>>> >>>> >>> >> >
