Open tfrancart opened 6 months ago
Metaphacts also have something like this when saving queries:
<spar-natural-form
src="config.ttl"
query="query.json"
form="form.json"
/>
form.json :
{
"bindings": [
{
"variable" : "Country_4",
"node" : {
"type" : "UserPrompt",
"name" : {
"en" : "Country",
"fr" : "Pays"
}
}
},
{
"variable" : "Person_10",
"node" : {
"type" : "UserPrompt",
"name" : {
"en" : "Author",
"fr" : "Auteur"
}
}
}
]
}
query.json:
{
"distinct": true,
"variables": [
{
"termType": "Variable",
"value": "Artwork_1"
},
{
"termType": "Variable",
"value": "Country_4"
},
{
"termType": "Variable",
"value": "Image_6"
}
],
"order": null,
"branches": [
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#displayedAt",
"o": "Museum_2",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Museum",
"values": []
},
"children": [
{
"line": {
"s": "Museum_2",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#country",
"o": "Country_4",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Museum",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Country",
"values": []
},
"children": []
}
]
},
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#thumbnail",
"o": "Image_6",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Image",
"values": []
},
"children": [],
"optional": true
},
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#description",
"o": "Text_8",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Text",
"values": []
},
"children": [],
"optional": true
},
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#author",
"o": "Person_10",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Person",
"values": []
},
"children": [],
"optional": true
}
]
}
Si l'utilisateur saisi seulement le pays mais pas l'auteur, alors:
Requête JSON finale:
{
"distinct": true,
"variables": [
{
"termType": "Variable",
"value": "Artwork_1"
},
{
"termType": "Variable",
"value": "Country_4"
},
{
"termType": "Variable",
"value": "Image_6"
}
],
"order": null,
"branches": [
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#displayedAt",
"o": "Museum_2",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Museum",
"values": []
},
"children": [
{
"line": {
"s": "Museum_2",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#country",
"o": "Country_4",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Museum",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Country",
"values": [
{
"label": "France (3987)",
"rdfTerm": {
"type": "uri",
"value": "http://fr.dbpedia.org/resource/France"
}
}
]
},
"children": []
}
]
},
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#thumbnail",
"o": "Image_6",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Image",
"values": []
},
"children": [],
"optional": true
},
{
"line": {
"s": "Artwork_1",
"p": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#description",
"o": "Text_8",
"sType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Artwork",
"oType": "http://ontologies.sparna.fr/sparnatural-demo-dbpedia#Text",
"values": []
},
"children": [],
"optional": true
}
]
}
Par exemple pour positionner une variable à la date du jour, ou par un bout de script:
{
"bindings": [
{
"variable" : "Country_1",
"node" : {
"type" : "UserPrompt",
"name" : {
"en" : "Select a country",
"fr" : "Sélectionner un pays"
}
}
},
{
"variable" : "Date_2",
"node" : {
"type" : "DynamicValueProvider",
"valueProvider" : "TypescriptClassNameOfTheValueProvider"
}
}
]
}
This would greatly fit our use of sparnatural for the GRACEFUL17 project!
Hopefully this development could be done end of 2024.
The goal is to create query templates, and indicate which variables in this query template could be choosed by a user. Then users can be proposed with very simple forms containing only these variables to select, without having to redesign the entire query. This opens the possibility to offer multiple simple forms to end-users, using the same value selection widgets as in Sparnatural.
The story is the following:
VocBench actually has this functionnality:
end-user selects a value:
@antoine37120