Re: SPARQL QUERY - UNEXPECTED RESULTS

Posted by Jiba on
URL: http://owlready.306.s1.nabble.com/SPARQL-QUERY-UNEXPECTED-RESULTS-tp3235p3240.html

Hi,

The SPARQL engine does not takes into account inverse properties, and symmetric properties are considered as a special type of inverse property.

The reasoner does not infer inverse relations, as they are considered as too trivial (and they can be voluminous).

The best solution is probably to modify the query in order to take into account the symmetric nature of the property:

pre_query = """?x rdf:type owl:NamedIndividual. ?x rdfs:label "{keyword}". { ?x <id.rdf#relationship2> ?y } UNION { ?y <id.rdf#relationship2> ?x } .  ?y rdfs:label ?ylabel.""".format(keyword=str(search_term))

Jiba