HyperAgents / hmas

An ontology to describe Hypermedia Multi-Agent Systems, interactions, and organizations.
https://purl.org/hmas/
1 stars 0 forks source link

SPARQL Queries for Competency Questions: ASK or SELECT or both #142

Closed gnardin closed 1 year ago

gnardin commented 1 year ago

Some of the Competency Questions (more specifically Q4, Q5, and Q6) in the Create an Organization motivating scenario (Branch: scenario-logistics-create-organization; Path: domains/logistics/create-organization) does not seem to be possible to represent using ASK queries.

Q4 must guarantee that both Organization Models exist and Q5 must guarantee that both Organizational Values exist. Q6 is more complex since it must identify all the elements composing a Organization Model (i.e., Organization Specification).

Does anyone know if there is a way of expressing/representing these Competency Questions as ASK queries?

As far as I remember, please correct me if I am wrong, we have discussed on and decided to use only ASK queries for expressing/representing the competency questions in order to make the formulation homogeneous and simplify the testing script. However, if the competency questions cannot be expressed/represented as ASK queries, are we allowed to use SELECT query? If so, where should we store the answers to the SELECT query to be checked by the script?

DrLeturc commented 1 year ago

I was asking the same question to my colleagues here: should we use SELECT/WHERE or ASK for unit tests ?

Using "ASK" for unit tests is useful to check if the Competency Questions has been checked and can be expressed. For instance checking "What are the list of regulative norms? " ask { bind (ex:safetyRule as ?i) ?i rdf:type hmas:RegulativeNorm . }

In order to know the list of individuals to test and to get and check automatically if the CQ is still expressed. Nested "SELECT" queries can be used.

To answer to your question in your post I don't see why you couldn't write your test with ASK since you just need a "multi-bind value" . Actually you wrote a FILTER but you could simply write : values ?orgModel { ex:Logistics ex:Manufacturing } And you add in your ASK question all the triplets that should be verified. Like idk e.g. ?orgModel a hmas:Organization . and all other triplets that should be in the dataset.

gnardin commented 1 year ago

I will start replying your last statement. I tested the ASK query you suggested, i.e., values ?orgModel { ex:Logistics ex:Manufacturing }. But contrary to what you state, SPARQL does not guarantee the existence of both Organizational Model, i.e., ex:Logistics and ex:Manufacturing, it returns true even if only one Organizational Model exists in the dataset. This is the same outcome we had using the filter.

This leads me to your comment of being preferable to use SELECT rather than ASK queries. In this case, it seems that, if we do not find an alternative using ASK, the only option would be to use SELECT and have a result text file containing the expected outcomes from the SELECT, which the test script could check against.

The first think we need to understand is if the ASK query are adequate to answer all Competency Questions. If we find a way, it will be Okay to using them.

But if we do not find a solution to write the Competency Questions as ASK questions, wouldn't better to change all the queries to SELECT queries?

@FabienGandon @Antoine-Zimmermann @vcharpenay @maximelefrancois86 Do you have any suggestions here?

maximelefrancois86 commented 1 year ago

After some discussion during the internal meeting today, I do agree that in some cases it is more natural to have competency questions written as SELECT queries, and the expected result in a separate file in the same folder.

We take the action to implement automatic checking of such competency questions

gnardin commented 1 year ago

We discussed this issue in the Ontology TF on April 7, 2023. Everybody agreed to use the SELECT query instead of the ASK query to represent the Competency Questions. The reasons were: (1) simpler to map Competency Questions to SELECT queries and (2) in some scenarios, ASK queries do not contain variables, which is not attracting. Due to this new agreement, the consequences are: (1) more complex scripts to check the output of the SPARQL queries, (2) rework to convert ASK to SELECT queries, (3) query results have to be provided together with the query.

The query results should be stored in a file with the same filename in the same directory as the query file, but with the .csv extension. For instance, the result of the query in the q1.rq file should be stored in the q1.csv file. The results should be generated using the output of the Apache Jena's sparql program. A command syntax example would be

sparql --data dataset.ttl --query q1.rq --results=CSV > q1.csv

NOTE: Further information on how to install and setup the tool for your computer environment can be found at Apache Jena.