diff --git a/js/utils.js b/js/utils.js index f4b6335..fc13124 100644 --- a/js/utils.js +++ b/js/utils.js @@ -95,16 +95,22 @@ function getStatements(){ } -function buildSQ() { - const sparqlgen = sparqljs.Generator; - const generator = new sparqlgen({orl: "http://www.w3.org/2000/01/rdf-schema#" }) +function buildSQ(stquery) { + //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 (ftxt.value.trim() != "") { + + if (ftxt.value.trim().slice(-1) !=='*') + strval="^" +ftxt.value.trim()+ "$"; + else + strval=ftxt.value.trim().slice(0, -1) + + parsedquery.where[1].expression.args[1].value = strval; if (lf.value == 'lemma') parsedquery.where[1].expression.args[0].value = "lm"; } @@ -115,8 +121,19 @@ function buildSQ() { mycg=document.getElementById("grammtypes1") if (mycg !=null && mycg.value != "all"){ parsedquery.where[0].triples.push(JSON.parse(data21)[mycg.value]); + //test per sottocategorie + lst_sc=JSON.parse(sottoCategorie)[mycg.value] + for (msc in lst_sc){ + ename=lst_sc[msc].split(',')[0] + esize=lst_sc[msc].split(',')[1] + tmp=document.getElementById("cla1"+ename) + if (tmp!=null && esize=='2' && tmp.querySelector('input[name="cla1'+ename.trim()+'"]:checked')!=null){ + //alert (tmp.querySelector('input[name="cla1'+ename.trim()+'"]:checked').value) + } + + } } - //alert(generator.stringify(parsedquery)) + return (parsedquery) } @@ -134,4 +151,6 @@ data21 = `{"verbovolgare": {"subject": {"termType": "Variable", "value":"form"}, "citazionevolgare": {"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/resource/ORL/FormaCitazioneVolgare"}}, "locuzionevolgare": {"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/resource/ORL/FormaLocuzioneVolgare"}} } - ` \ No newline at end of file + ` +sottoCategorie=`{"verbovolgare": ["Diatesi,2", "Transitivita,2", "Genere,2", "Numero,2", "Pers,1", "Rifl,1", "Coniugazione,n", "Tempi,n", "Persona,n", "Funzione,n", "Declinazione,n"], +"sostantivovolgare": ["pippo,2", "pluto,2"]}`