[Pellet-users] null pointer exception at getIndividuals()
Alexander Becker
trennung at weinenvorglueck.de
Wed Jun 18 21:26:39 UTC 2008
Dear all!
I want to fetch all individuals of an ontology, that have a certain property.
Unfortunately, I get one of these ugly null pointer exceptions, and as usual, I don't have any idea where the error comes from (no, the line number is no sufficent information :>).
This is the error:
[quote]
Testcase: get_ind_by_props_depr(Test.ReasonerTest): Caused an ERROR
null
java.lang.NullPointerException
at org.mindswap.pellet.owlapi.PelletVisitor.addSimpleProperty(PelletVisitor.java:220)
at org.mindswap.pellet.owlapi.PelletVisitor.visit(PelletVisitor.java:683)
at uk.ac.manchester.cs.owl.OWLObjectSelfRestrictionImpl.accept(OWLObjectSelfRestrictionImpl.java:53)
at org.mindswap.pellet.owlapi.PelletLoader.term(PelletLoader.java:173)
at org.mindswap.pellet.owlapi.Reasoner.getIndividuals(Reasoner.java:550)
at Test.ReasonerTest.get_ind_by_props_depr(ReasonerTest.java:270)
[/quote]
And here is the code:
[code]
@Test
/**
* Get all individuals by property. Uses a depreciated api.
*/
public void get_ind_by_props_depr() {
// input:
String property = "hasCase";
String propertyValue = "Genitive";
// The way we do it atm.
Set result = new HashSet();
Set<OWLIndividual> all_ind = new HashSet();
all_ind = reasoner.getIndividuals();
for( OWLIndividual owl_individual : all_ind ) {
Map opv = reasoner.getObjectPropertyRelationships(owl_individual);
Set<OWLProperty> object_property_values_keyset = opv.keySet();
if (opv.size() > 0) {
for( OWLProperty oprop : object_property_values_keyset ) {
if (oprop.toString().endsWith(property)) {
if (reasoner.getPropertyValue(owl_individual, (OWLObjectProperty) oprop).toString().endsWith(propertyValue.toLowerCase())) {
result.add(owl_individual.getURI().getFragment());
}
}
}
}
}
System.out.println("get_ind_by_props_depr: " + result.toString());
// Thats how it should (propably) work, but it doesn't.
OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
OWLObjectProperty objectprop = factory.getOWLObjectProperty(URI.create(url + "#hasCase"));
OWLObjectSelfRestriction clsC = factory.getOWLObjectSelfRestriction(objectprop);
Set result2 = reasoner.getIndividuals(clsC, false); // line 270 here
System.out.println("get_ind_by_props_depr: " + result2.toString());
assertTrue(result.equals(result2));
}
[/code]
Maybe someone sees the error and / or may help me with that task.
Best regards, Alex
--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx
More information about the Pellet-users
mailing list