aggiunta funzione per generare query

This commit is contained in:
cesare 2022-09-30 09:43:32 +02:00
parent 7e02244cbc
commit 57b957b003
1 changed files with 35 additions and 4 deletions

View File

@ -9,8 +9,9 @@ PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX olires:<https://dantenetwork.it/ontology/OLIRes/>
SELECT (?form as ?IRIForma) (?Rappresentazione as ?Forma) (?textver as ?Verso) ?NumVerso (?t_canto as ?Canto) (?t_cantica as ?Cantica)
(?lm as ?Lemma)
SELECT (?form as ?IRIForma) (?Rappresentazione as ?Forma) (?lm as ?Lemma) (?textver as ?Verso) ?NumVerso
(?t_canto as ?Canto) (?t_cantica as ?Cantica)
WHERE {
?fa orl:occurrenceOf ?form;
@ -28,7 +29,9 @@ WHERE {
FILTER regex(?Rappresentazione,"^farò$","i") .
#FILTER regex(?lm,"^fare$","i") .
FILTER langMatches(lang(?Rappresentazione),"it")
}`
} ORDER BY ?Cantica ?Canto ?NumVerso
LIMIT 50`
//Togliere LIMIT in prod
function writesparqlquery(query) {
return (query);
@ -51,7 +54,7 @@ function writesearchValue(form) {
function gimmespq(){
var SparqlParser = sparqljs.Parser;
var parser = new SparqlParser();
var parser = new SparqlParser();
return parser.parse(ontoSparqlQuery);
@ -87,7 +90,35 @@ function gimmespqfromjson(form){
}
function getStatements(){
return data21
}
function buildSQ() {
const sparqlgen = sparqljs.Generator;
const generator = new sparqlgen({orl: "http://www.w3.org/2000/01/rdf-schema#" })
var SparqlParser = sparqljs.Parser;
var parser = new SparqlParser();
const parsedquery =parser.parse(ontoSparqlQuery);
const lf = document.getElementById("lemma_forma");
const ftxt = document.getElementById("queryText");
if (ftxt.value != "") {
parsedquery.where[1].expression.args[1].value = "^" + ftxt.value + "$";
if (lf.value == 'lemma')
parsedquery.where[1].expression.args[0].value = "lm";
}
else{
parsedquery.where.splice(1, 1)
}
//categorie grammaticali
mycg=document.getElementById("grammtypes1")
if (mycg !=null && mycg.value != "all"){
parsedquery.where[0].triples.push(JSON.parse(data21)[mycg.value]);
}
//alert(generator.stringify(parsedquery))
return (parsedquery)
}
data21 = `{"verbovolgare": {"subject": {"termType": "Variable", "value":"form"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"termType": "NamedNode", "value": "http://dantenetwork.it/ontology/ORL/FormaVerboVolgare"}},