I'm student and I am working on ontologies(jena+java).

I need a way to calculate the mincardinality of a property of a class, and I know there's a mincardiality method, but I'm not able to use it .

help me,please

asked 09 Oct '10, 09:19

fateme.hosseini's gravatar image

fateme.hosseini
154
accept rate: 0%



if(someClass instanceof MinCardinalityRestriction){
  MinCardinalityRestriction mcr = (MinCardinalityRestriction)someClass;
  int minCard = mcr.getMinCardinality();
}

To check if it's on a certain property


  ...
  //toCheck instanceof Property
  if(mcr.onProperty(toCheck)){
    ...
  }

EDIT: Your code from the comment


//cc1 a class, op a property


if(cc1 instanceof MinCardinalityRestriction){ //check if an owl:Class represented
                                              //by cc1 has a valid
                                              //min-cardinality restriction 
                                              //defined

   MinCardinalityRestriction mcr = (MinCardinalityRestriction)cc1;      
                                              //cast it to an object from 
                                              //which you can
                                              //the cardinality information

   int minCard = mcr.getMinCardinality();     //get the value of the cardinality
                                              //from that object


   if( mcr.onProperty(op)) {                  //check if the cardinality is for 
                                              //the given property op
      System.out.println("minncarrrdinality"); 

   } 
} 


I don't know where to start I'm afraid. To explain what might be going wrong would be to explain Java, and that could take some time. You seem to be tackling three new things at once: Java, OWL and Jena.

I commented the code to try explain what goes on at each line.

link

answered 09 Oct '10, 09:33

Signified's gravatar image

Signified ♦
23.1k623
accept rate: 38%

edited 10 Oct '10, 11:08

Don't use Jena myself, so someone might have a cleaner solution.

(09 Oct '10, 09:35) Signified ♦ Signified's gravatar image

what is someclaz? what is claz? i write this:(cc1 is a class and op is a property) MinCardinalityRestriction mcr = null; if(cc1 instanceof MinCardinalityRestriction){ mcr = (MinCardinalityRestriction)cc1; int minCard = mcr.getMinCardinality(); } if( mcr.onProperty(op)) { System.out.println("minncarrrdinality"); } but ............... Exception in thread "main" java.lang.NullPointerException at pak2.ontology1.main(ontology1.java:612)

(10 Oct '10, 09:07) fateme.hosseini fateme.hosseini's gravatar image

it always creates null pointer....... please help

(10 Oct '10, 09:27) fateme.hosseini fateme.hosseini's gravatar image

The NullPointerException is in your code... I can't give you an explanation.

(10 Oct '10, 11:11) Signified ♦ Signified's gravatar image

Wait... change if( mcr.onProperty(op)) to if(mcr!=null && mcr.onProperty(op))

(10 Oct '10, 11:14) Signified ♦ Signified's gravatar image

i run this code for an ontology. i see this in ontology source: """"<rdfs:subclassof> <owl:restriction> <owl:onproperty rdf:resource="#shoesize"/> <owl:mincardinality>1</owl:mincardinality> </owl:restriction> </rdfs:subclassof> """" but by this code ,i Don't see anything.

(28 Nov '10, 04:44) fateme.hosseini fateme.hosseini's gravatar image

thanks . but i have some problem again. it seems doesn't work correctly?! can you help me???

(28 Nov '10, 08:20) fateme.hosseini fateme.hosseini's gravatar image

In the ontology, you should have a datatype of xsd:nonNegativeInteger, like <owl:minCardinality rdf:datatype="h-ttp://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:minCardinality>. See if that helps.

(28 Nov '10, 18:17) Signified ♦ Signified's gravatar image

what about this:"""""<rdfs:subclassof> <owl:restriction> <owl:onproperty rdf:resource="#shoesize"/> <owl:mincardinality>1</owl:mincardinality> </owl:restriction> </rdfs:subclassof> """"" shoesiza is a property with mincardinality=1

(29 Nov '10, 06:17) fateme.hosseini fateme.hosseini's gravatar image

You still need the datatype. See above.

(29 Nov '10, 15:54) Signified ♦ Signified's gravatar image

i express my question elsewhere.this is answers::::::

List the superclasses, for each test if it is a minCardinality restriction (with n>0) or a someValuesFrom restriction, or a Cardinality restriction (with n>0). OntClass gives you methods for doing such tests.

The properties are in the restrictions. You can get some helps by example? thanks

(30 Nov '10, 09:51) fateme.hosseini fateme.hosseini's gravatar image
showing 5 of 11 show 6 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×597
×543

Asked: 09 Oct '10, 09:19

Seen: 1,147 times

Last updated: 10 Oct '10, 11:08