[Pellet-Users] Exception and a question
Evren Sirin
evren at cs.umd.edu
Fri Feb 17 22:23:46 EST 2006
The below exception is a recently fixed bug (I think last week). If you
get the latest nightly build it should be ok. In any case I would
suggest you to use an OntModel where Pellet is attached as the reasoner
(you can use OntModelSpec PelletResonerFactory.THE_SPEC to create the
OntModel) . When you use OntModel changes to the model are automatically
detected (as you have discovered this is not true for OWLReasoner).
There are also some simple optimizations in PelletInfGraph (which is the
underlying graph for the OntModel) to handle changes. For example, if
adding only new instances will not force computing the classification
(as long as there are no nominals in the ontology). Chris is working on
much more sophisticated optimizations for incremental changes which will
be integrated into a future release.
Regards,
Evren
Dean Wilkinson wrote:
> Hi all,
>
> I am new to Pellet and run some experiments to evaluate its features.
> I wrote a program that creates a small test ontology, runs the
> classifier, then adds a domain statement (to change the classification
> results) and finally queries the classified model again. The complete
> test program is below. Here are my questions:
>
> 1) I noticed that adding the domain does not immediately have an
> impact on the classification: calling reasoner.getSubClasses() after
> the change does not return different results.
>
> 2) So I guess I need to tell Pellet somehow that the graph has
> changed. However, calling reasoner.load() again throws an Exception
> (listed below). How can I correctly update Pellet's internal model and
> how would it behave in terms of performance if do various changes to
> the model?
>
> Thanks for any insights!
> Dean
>
> --------
>
> import java.util.Set;
>
> import org.mindswap.pellet.jena.DisjointMultiUnion;
> import org.mindswap.pellet.jena.OWLReasoner;
>
> import com.hp.hpl.jena.ontology.OntClass;
> import com.hp.hpl.jena.ontology.OntModel;
> import com.hp.hpl.jena.ontology.OntProperty;
> import com.hp.hpl.jena.ontology.Restriction;
> import com.hp.hpl.jena.rdf.model.ModelFactory;
> import com.hp.hpl.jena.vocabulary.OWL;
>
> import junit.framework.TestCase;
>
>
> public class IncrementalClassificationTestCase extends TestCase {
>
> public void testIncremental() {
>
> OntModel ontModel = ModelFactory.createOntologyModel();
> String NS = "http://my.com/my.owl#";
> OntClass person = ontModel.createClass(NS + "Person");
> OntProperty hasChildren = ontModel.createObjectProperty(NS +
> "hasChildren");
> OntClass parent = ontModel.createClass(NS + "Parent");
> Restriction restriction =
> ontModel.createMinCardinalityRestriction(null, hasChildren, 1);
> parent.addEquivalentClass(restriction);
>
> DisjointMultiUnion dmu = new
> DisjointMultiUnion(ontModel.getBaseModel().getGraph());
> OWLReasoner reasoner = new OWLReasoner();
> reasoner.load(dmu);
>
> Set oldSubClasses = reasoner.getSubClasses(person);
> assertEquals(1, oldSubClasses.size());
> Set oldFirst = (Set) oldSubClasses.iterator().next();
> assertTrue(oldFirst.contains(OWL.Nothing));
>
> hasChildren.setDomain(person); // Should trigger inference
> reasoner.load(dmu);
>
> Set newSubClasses = reasoner.getSubClasses(person);
> assertEquals(2, newSubClasses.size());
> }
> }
>
>
>
>
> java.lang.UnsupportedOperationException
> at java.util.AbstractList.add(Unknown Source)
> at java.util.AbstractList.add(Unknown Source)
> at
> org.mindswap.pellet.taxonomy.TaxonomyNode.addSub(TaxonomyNode.java:75)
> at
> org.mindswap.pellet.taxonomy.TaxonomyBuilder.init(TaxonomyBuilder.java:172)
>
> at
> org.mindswap.pellet.taxonomy.TaxonomyBuilder.classify(TaxonomyBuilder.java:107)
>
> at org.mindswap.pellet.KnowledgeBase.classify(KnowledgeBase.java:744)
> at
> org.mindswap.pellet.KnowledgeBase.getSubClasses(KnowledgeBase.java:1679)
> at
> org.mindswap.pellet.KnowledgeBase.getSubClasses(KnowledgeBase.java:1414)
> at
> org.mindswap.pellet.jena.OWLReasoner.getSubClasses(OWLReasoner.java:732)
> at
> tests.IncrementalClassificationTestCase.testIncremental(IncrementalClassificationTestCase.java:42)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>
>
>
> _______________________________________________
> Pellet-Users mailing list
> Pellet-Users at lists.mindswap.org
> http://lists.mindswap.org/mailman/listinfo/pellet-users
>
>
--
Evren Sirin evren at cs.umd.edu
Graduate Research Assistant
Computer Science Department
Univ of Maryland, College Park, MD 20742
Phone: (301) 405-7027, Fax: (301) 405-6707
More information about the Pellet-Users
mailing list