This commit is contained in:
Luca Trupiano 2022-09-30 12:39:59 +02:00
commit 09598255ee
1 changed files with 26 additions and 7 deletions

View File

@ -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"}}
}
`
`
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"]}`