Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] Help needed in using Protege search results in mathematical expressions

Thomas Russ tar at ISI.EDU
Wed Feb 7 00:13:02 PST 2007


On Feb 6, 2007, at 8:08 PM, Leaelaf M Hailemariam wrote:

> Dear forum
>
> My name is Leaelaf Hailemariam. I am currently working on a system  
> that
> does the following:
>
> 1. Accept inputs x1 and x2 (numbers) and m1 and m2 (material
> names) through a textfield from a user.
>
> 2. Search for an OWLIndividual  named 'm1'.
>
> 3. Access m1's OWLDataType property p1 and convert it to float.

Not that this is your problem, but...

In your code below, it seems you are doing this in a very round-about  
fashion.  Instead of taking the Float object (which is what should  
come back from the following, I think you should be able to get  
directly at the value of the Float object, using appropriate casts.

     float p1;
     Object p1v = individual.getPropertyValue(Composition);
     if (p1v != null) {
	p1 = p1v.floatValue()
     } else {
         ... no value, do something about it....
     }

>
> 4. Do steps 2 and 3 above for an OWLIndividual named 'm2'.
>
> 5. Multiply x1 by p1 and x2 by p2 (after all are converted  
> respectively to
> float).
>
> It is in step 5 that I am encountering problems: there seems to be  
> no way
> to access the OWLDataTypeProperty Value of the query result. I have
> attached the relevant code sections below:




>
>
> [0] Creating the OWL instances
>
>   OWLDatatypeProperty Composition =
> owlModel4.createOWLDatatypeProperty("composition");
>
> Composition.setRange(owlModel4.getXSDint());

If the data type is XSD:int, why are you setting Float values
further below?  Shouldn't you be setting the range to XSD:float
instead?

>
> Composition.setDomain(processMaterialClass);
>
>  				       OWLDatatypeProperty Yield_Strength
> = owlModel4.createOWLDatatypeProperty("yield_strength");
>
> Yield_Strength.setRange(owlModel4.getXSDint());
>
> Yield_Strength.setDomain(processMaterialClass);
>
>
>    OWLIndividual cycloserine =
> Solid_Material.createOWLIndividual("Cycloserine");
>
> cycloserine.setPropertyValue(Composition, new Float(1.0));
>
> cycloserine.setPropertyValue(Yield_Strength, new Float(3000));
>
>  				       OWLIndividual starch =
> Solid_Material.createOWLIndividual("Starch");
>
> starch.setPropertyValue(Composition, new Float(1.0));
>
> starch.setPropertyValue(Yield_Strength, new Float(2500));
>
>
> [1] Searching for the OWL individual and conversion to float
>
>    Collection mat_query_result = Solid_Material.getInstances(false);
>  				       assert
> (mat_query_result.contains(starch));
>  				       assert (mat_query_result.size() ==
> 1);

Does this assert actually succeed?  I would have though that you  
would get two instances, since you created both starch and  
cycloserine as instances of Solid_Material.

>
>  				       //---- Display the instance
>
>
>  				       for (Iterator jt =
> mat_query_result.iterator(); jt.hasNext();) {
>  				            OWLIndividual individual =
> (OWLIndividual) jt.next();
>  				            String p1s =
> individual.getPropertyValue(Composition).toString();
>  				            float p1 =
> Float.valueOf(p1s.trim()).floatValue();
>  				        }
>
> [2] Getting user inputs
>
> String x1s = material_1_composition_value.getText();
>  				       float x1 =
> Float.valueOf(x1s.trim()).floatValue();
>
> [3] Multiplication **************** here is where the problem lies  
> *****
>
> float mix_prop= p1*x1 + p2*x2;
>
> Does anyone have any ideas??

So, what error do you get here?
It doesn't look like you are setting the value of p2 at all, and the  
declaration of the float p1 is inside the scope of a for loop, so it  
won't be visible once you exit that loop.

These all look like Java rather than Protege/OWL problems.




More information about the protege-owl mailing list