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-discussion] Programming with Protege-OWL generated code.

Trudy Cool trudy_cool at yahoo.com
Sun May 4 11:19:03 PDT 2008


Dear Protege Group

I've been evaluating Protege as part of an
institutional architecture.

I had expected certain functionality from the
generated Protege-OWL java code that does not
seem to be there.

Here's my test code (my questions follow) ...

---------------- o 0 o ------------------------

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
    	
        Iterator itr;
    	  try 
    	  {
    	    FileReader rd = new
FileReader("C:\\hasan\\learning\\edu\\stanford\\protege\\pizzas\\protege\\pizza_attempt_1.owl");
    	    OWLModel owlModel =
ProtegeOWL.createJenaOWLModelFromReader(rd);

    	    PizzaFactory pf = new
PizzaFactory(owlModel);
    	    DefaultMargueritaPizza mp =
(DefaultMargueritaPizza)
pf.createMargueritaPizza("Maggie");
    	    itr = mp.getHasTopping().iterator();
    	    while (itr.hasNext()) {
    	      System.out.println("Marguerita Pizza
Topping : " + itr.next().toString());
    	    }

    	    DefaultVegetarianPizza vp =
(DefaultVegetarianPizza)
pf.createVegetarianPizza("Turnip");

    	    						System.out.println("Shouldn't it
throw an exception here?");
    	   
vp.addHasTopping(pf.createHamTopping("Hamster"));

    	    boolean bOk =
vp.canAs(VegetarianPizza.class);
    	    						System.out.println("Or is it
allowed? " + bOk + "!");

    	    itr = vp.getHasTopping().iterator();
    	    while (itr.hasNext()) {
    	        System.out.println("Vegetarian Pizza
Topping : " + itr.next().toString());
    	    }
    	        
    	  } catch (java.lang.Exception ex) {
    	    ex.printStackTrace();
    	  }
    
    }
}

---------------- o 0 o ------------------------

Runtime log ...

INFO: Loading triples
INFO: Start processing ontology:
http://dummy-ontologies.com/dummy.owl Time: Sun
May 04 13:04:37 COT 2008
INFO: [ProtegeOWLParser] Completed triple loading
after 531 ms
INFO: [TripleChangePostProcessor] Completed lists
after 0 ms
INFO: [TripleChangePostProcessor] Completed
anonymous classes after 16 ms
INFO: [TripleChangePostProcessor] Completed
deprecated classes after 0 ms
INFO: [TripleChangePostProcessor] Completed
properties after 16 ms
INFO: [TripleChangePostProcessor] Completed named
classes after 15 ms
INFO: ... Loading completed after 609 ms
Shouldn't it throw an exception here?
Or is it allowed? true!
Vegetarian Pizza Topping : SimpleInstance(Hamster
of [DefaultOWLNamedClass(HamTopping,
FrameID(5:10149 1))])


---------------- o 0 o ------------------------

Observations:
1) A MargueritaPizza only exists if there is a
pizza with Mozzarella and Tomato toppings, but
this MargueritaPizza has no toppings.
2) Clearly, I should not be able to put
HamTopping on a Vegetarian Pizza.

So I'd like to ask, if I may:
1)  Am I doing something wrong?
2)  Am I expecting functionality that ought to be
there, but isn't yet?
3)  Am I expecting functionality that ought NOT
to be there, for some reason I haven't
understood?
4)  What must I do to get Java classes that
consistently obey the ontological rules?

Thanking you in advance,
Hasan




      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



More information about the protege-discussion mailing list