I am facing a problem extracting the Individual's name from the Jena Graph (RDF Inference Model with Generic Rule Reasoner and OntSpec is RDFS_MEM_RDFS_INF ). It may be a simple case but I am not able to find proper tutorial online to get this done (new to jena rules). What is the proper api to call for in this case?
infStmts = pModel.listStatements().filterKeep( new Filter<Statement>() {
@Override
public boolean accept(Statement o) {
boolean ex = false;
Property prop1 = pModel.getProperty(prefix + "hasPropertyP1");
String predicateName = o.asTriple().getPredicate().getLocalName();
if(predicateName.equalsIgnoreCase(prop1.getLocalName()) )
ex = true;
return ex;
}
});
Statement s = infStmts.next();
Statement st = ResourceFactory.createStatement(s.getSubject(), s.getPredicate(), s.getObject());
System.out.println(st.getSubject().toString() + "****" + pModel.getRDFNode(st.getSubject().asNode()).as(Individual.class));
Exception in thread "Thread-37" com.hp.hpl.jena.ontology.ConversionException: Cannot convert node 4e62503a:14b01762f42:-7eea to Individual
at com.hp.hpl.jena.ontology.impl.IndividualImpl$1.wrap(IndividualImpl.java:61)
at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:152)
at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:31)
at com.hp.hpl.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:62)
at com.hp.hpl.jena.enhanced.EnhNode.as(EnhNode.java:107)
...
The Jena rules file has the following rule
[rule: ( :Subject1 :hasPropertyP2 :Object1) ->
( ?x rdf:type :Class1)
( ?x :hasPropertyP1 :Object2)]
I need the value of ?x in terms of individuals' names