Discussion:
Programming with Protege-OWL generated code.
Trudy Cool
2008-05-04 18:19:03 UTC
Permalink
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
_______________________________________________
protege-discussion mailing list
protege-***@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-discussion

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Samson Tu
2008-05-04 21:37:18 UTC
Permalink
In the future, please send OWL-related questions to
protege-***@lists.stanford.edu.

See in-line comments.
Post by Trudy Cool
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) ...
...
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.
1) Am I doing something wrong?
You need to call a DL Reasoner (e.g., pellet) explicitly first before
you can query for inferred statements. So MargueritaPizza has no
*asserted* toppings.

Similarly, when you asserted that a vegetarian pizza has "Hamster"
topping, you need to call the Reasoner explicitly to inferred that such
toppings leads to an inconsistent ontology.
Post by Trudy Cool
2) Am I expecting functionality that ought to be
there, but isn't yet?
The functionality is there.
Post by Trudy Cool
3) Am I expecting functionality that ought NOT
to be there, for some reason I haven't
understood?
Calling the Reasoner is an expensive operation. Protege shouldn't call
it every time the ontology is changed.
Post by Trudy Cool
4) What must I do to get Java classes that
consistently obey the ontological rules?
It's not trivial to identify, when you have an inconsistent ontology,
the assertion that need to be retracted.

With best regard,
Samson Tu

_______________________________________________
protege-discussion mailing list
protege-***@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-discussion

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Loading...