Answer Filtering
Closed this issue · 1 comments
We need to find a way to read and parse SPARQL queries. This is because we need to derive a filtering program from a query.
So far we have this:
- OWLAPI does not provide an interface to import queries;
- RDFox understands (a subset of?) SPARQL. Queries can either be provided as
String
s or built using the internal abstract syntax. There is no bridge between the two, i.e., there is no way to provide aString
/file and parse it into the internal representation; - We can use another library to manage the query import. We ignore the RDFox internal represention of a query and instead generate the filtering program directly. Here are a few libraries that should be good to use
Another option for now is to just ignore all of this and embed the queries in the code using the RDFox internal representation.
Update: it seems like RDFox functions that take a Query
as a parameter usually provide alternative signatures that accept the query as a String
. This most likely means that they have a method to parse Query
s from String
s but it's not exposed. Maybe ask Valerio about this.
Apart from importing the query we still need to:
- implement all filtering rules
- refactor code for the generation of the filtering program (a.k.a. make it easier to use it later on when putting all the pieces together)
- write a function to retrieve all bounded variables in a query. In a
SELECT-FROM-WHERE
SPARQL query this corresponds to all variables that are not named in theSELECT
statement (a.k.a. answer variables); - write a function to obtain all invividuals in an ontology. Note that this is worth doing before any convertion into LP rules since the convertion introduces newly generated constants that we don't want in the set;
- Import query from file (see above).
Turns out RDFox is indeed able to parse a query string into a Query
. While this is not documented in the JavaDoc one can proceed as follows
SPARQLParser parser = new SPARQLParser(Prefixes.s_defaultPrefixes, new ByteArrayInputStream("SELECT * WHERE {?a ?b ?c} LIMIT 5".getBytes(StandardCharsets.UTF_8)));
Query myQ = parser.parseSingleQuery();