From 8b1392bea15e74c80a2fffd4aa2b87906870e381 Mon Sep 17 00:00:00 2001 From: cesare Date: Fri, 30 Sep 2022 10:25:52 +0200 Subject: [PATCH 1/3] gestione ricerca sottostringhe --- js/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/utils.js b/js/utils.js index f4b6335..ff34e5b 100644 --- a/js/utils.js +++ b/js/utils.js @@ -104,7 +104,11 @@ function buildSQ() { const lf = document.getElementById("lemma_forma"); const ftxt = document.getElementById("queryText"); if (ftxt.value != "") { - parsedquery.where[1].expression.args[1].value = "^" + ftxt.value + "$"; + strval=ftxt.value.trim().slice(0, -1) + if (ftxt.value.trim().slice(-1) !=='*') + strval="^" +ftxt.value.trim()+ "$"; + + parsedquery.where[1].expression.args[1].value = strval; if (lf.value == 'lemma') parsedquery.where[1].expression.args[0].value = "lm"; } From dc30e63a727a49f08814aac5ff1646fae13427b8 Mon Sep 17 00:00:00 2001 From: cesare Date: Fri, 30 Sep 2022 12:38:49 +0200 Subject: [PATCH 2/3] signature modficata alla funzione buildSQ --- js/utils.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/js/utils.js b/js/utils.js index ff34e5b..cc04f83 100644 --- a/js/utils.js +++ b/js/utils.js @@ -95,18 +95,20 @@ 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 != "") { - strval=ftxt.value.trim().slice(0, -1) + 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') @@ -119,8 +121,20 @@ 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) + } + else + alert(tmp.value) + } } - //alert(generator.stringify(parsedquery)) + return (parsedquery) } @@ -138,4 +152,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"]}` From 384ca009aabf4f94501ac5aef8d81966d6112966 Mon Sep 17 00:00:00 2001 From: cesare Date: Fri, 30 Sep 2022 12:39:43 +0200 Subject: [PATCH 3/3] eliminati alert --- js/utils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/utils.js b/js/utils.js index cc04f83..fc13124 100644 --- a/js/utils.js +++ b/js/utils.js @@ -128,10 +128,9 @@ function buildSQ(stquery) { 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 (tmp.querySelector('input[name="cla1'+ename.trim()+'"]:checked').value) } - else - alert(tmp.value) + } }