This sounds like a question for the Jena email lists:
http://sourceforge.net/mail/?group_id=40417 (01)
Jack (02)
On Sat, Sep 25, 2010 at 9:58 PM, fatemeh hosseini
<fa.hosseinim@xxxxxxxxx> wrote:
> dear all
>
> i use jena and java for ontology programming.I'm new to Java, and jena. I
> use Eclipse IDE.
> I have some problem (please help me)?
>
> 1-- how can i calculate distance between two classes in an ontology(number
> of links between two classes)??
>
> 2-- how can i get mincardinality of a property for a given Class?
> i tried to do it.
> i add these :
> import com.hp.hpl.jena.ontology.MinCardinalityQRestriction;
> import com.hp.hpl.jena.ontology.*;
> import com.hp.hpl.jena.ontology.Restriction;
>
> i write this code but it doesn't work correctly.(it gives all properties
> !!)
> for (Iterator i = c.listDeclaredProperties(true); i.hasNext(); )
> { //begin
>
> OntProperty op = (OntProperty) i.next();
> System.out.println("op: " + op+" **class**
> "+c.getLocalName());
> // restriction with a given URI
> Restriction r = m.getRestriction(
>c.getURI() );
>
> // anonymous restriction on property op
> Restriction anonr = m.createRestriction(
>op );
>
> //to convert the anonymous restriction
> MinCardinalityRestriction avf =
> anonr.convertToMinCardinalityRestriction(1);
>
> System.out.println("cardin*** " +avf.getOnProperty().getLocalName());
>
>
> } //end
> output is this(+error):
>
>op: http://www.atl.lmco.com/projects/ontology/ontologies/animals/animalsA.owl#hasFemaleParent
> **class** Animal
> cardin+**+ hasFemaleParent
>
>op: http://www.atl.lmco.com/projects/ontology/ontologies/animals/animalsA.owl#hasFather
> **class** Animal
> cardin+**+ hasFather
>
> Exception in thread "main" java.lang.NullPointerException
> at pak2.ontology1.main(ontology1.java:445)
>
>
>
> 3- how can i get level of a resource in an ontology?
> thanks advance.
> fatemeh hosseini
>
> _________________________________________________________________
> Message Archives: http://ontolog.cim3.net/forum/ontolog-forum/
> Config Subscr: http://ontolog.cim3.net/mailman/listinfo/ontolog-forum/
> Unsubscribe: mailto:ontolog-forum-leave@xxxxxxxxxxxxxxxx
> Shared Files: http://ontolog.cim3.net/file/
> Community Wiki: http://ontolog.cim3.net/wiki/
> To join: http://ontolog.cim3.net/cgi-bin/wiki.pl?WikiHomePage#nid1J
> To Post: mailto:ontolog-forum@xxxxxxxxxxxxxxxx
>
> (03)
_________________________________________________________________
Message Archives: http://ontolog.cim3.net/forum/ontolog-forum/
Config Subscr: http://ontolog.cim3.net/mailman/listinfo/ontolog-forum/
Unsubscribe: mailto:ontolog-forum-leave@xxxxxxxxxxxxxxxx
Shared Files: http://ontolog.cim3.net/file/
Community Wiki: http://ontolog.cim3.net/wiki/
To join: http://ontolog.cim3.net/cgi-bin/wiki.pl?WikiHomePage#nid1J
To Post: mailto:ontolog-forum@xxxxxxxxxxxxxxxx (04)
|