Closed hafsabajwa closed 2 years ago
The problem in this code is that the EntitySearcher call result is ignored (the syntax isn't valid either but that's a compile problem).
property.isLiteral()
will return whether the annotation property is a literal, which cannot be true - literals and annotation properties are distinct and no instance of one can be an instance of the other.
You should check the results returned by EntitySearcher to see if their annotation values are literals, and print them in that case
EntitySearcher.getannotationObjects(clazz, ontology, property)
.map(OWLAnnotation::annotationValue)
.map(OWLAnnotationValue::asLiteral)
// contents of the stream are now Optional<OWLLiteral> instances
.filter(Optional::isPresent)
.forEach(value->System.out.println(value.get()));
Is there any way to say, If the annotation value is Literal, then print "This is literal." I am doing: