implementazione query cond multiple, progress

This commit is contained in:
cesare 2025-02-14 12:55:54 +01:00
parent d079a84ea6
commit b937d25ca3
3 changed files with 42 additions and 24 deletions

View File

@ -682,11 +682,11 @@
<select <select
class="custom-select text-muted bg-light border border-success btn-outline-success " class="custom-select text-muted bg-light border border-success btn-outline-success "
id="unitaRicerca"> id="unitaRicerca">
<option value="versi">Versi</option> <option value="verso">Versi</option>
<option value="frase">Frasi</option> <option value="frase">Frasi</option>
<option value="periodo">Periodi</option> <option value="periodo">Periodi</option>
<option value="discorso">Discorsi</option> <option value="discorso">Discorsi</option>
<option value="riferimenti">Riferimenti</option> <option value="riferimento">Riferimenti</option>
</select> </select>
<!-- <select <!-- <select
class="custom-select text-muted bg-light border border-success btn-outline-success " class="custom-select text-muted bg-light border border-success btn-outline-success "

View File

@ -278,15 +278,14 @@ $(document).ready(function() {
*/ */
var prevstart = -1 //var prevstart = -1
var prevoffset = -1 //var prevoffset = -1
jQuery.manageResultList = function manageResultList(start, offset = showOffset) { jQuery.manageResultList = function manageResultList(start, offset = showOffset) {
/*if (offset == prevoffset && start == prevstart && cantoDisplayed == '#vistaFrasi')
return*/
console.log('Paginazione...') console.log('Paginazione...')
prevstart = start //prevstart = start
prevoffset = offset //prevoffset = offset
if (cantoDisplayed != '#vistaFrasi') { if (cantoDisplayed != '#vistaFrasi') {
prevCantoDisplayed = cantoDisplayed; prevCantoDisplayed = cantoDisplayed;
$(cantoDisplayed).css("display", "none"); $(cantoDisplayed).css("display", "none");
@ -1508,7 +1507,7 @@ $(document).ready(function() {
unitaRicerca = 'forma' unitaRicerca = 'forma'
else else
unitaRicerca = jsonQuery['unitaRicerca'] unitaRicerca = jsonQuery['unitaRicerca']
if (unitaRicerca=='riferimenti'){ if (unitaRicerca=='riferimento'){
var esprLR=jsonQuery.EsprLogicaRif var esprLR=jsonQuery.EsprLogicaRif
if(esprLR.length && esprLR.length==1){ if(esprLR.length && esprLR.length==1){
listaRisultatiCommenti=queryRiferimenti(jsonQuery[esprLR[0].trim()], cantoDisplayed) listaRisultatiCommenti=queryRiferimenti(jsonQuery[esprLR[0].trim()], cantoDisplayed)
@ -2012,7 +2011,7 @@ $(document).ready(function() {
listaClausoleRisultatoContesti = [] listaClausoleRisultatoContesti = []
//Unità di ricerca è 'frase' //Unità di ricerca è 'frase'
if ((!listarisultati.length && unitaRicerca == 'forme') || unitaRicerca == 'frase' || unitaRicerca == 'versi') { if ((!listarisultati.length && unitaRicerca == 'forme') || unitaRicerca == 'frase' || unitaRicerca == 'verso') {
//if (unitaRicerca == 'frase') { //if (unitaRicerca == 'frase') {
unitaRicerca = 'frase' unitaRicerca = 'frase'
resultsInCantica = [] resultsInCantica = []
@ -2162,8 +2161,7 @@ $(document).ready(function() {
// mostra lista risultati // mostra lista risultati
//$.manageResultList(0, showOffset); //$.manageResultList(0, showOffset);
$("#cantica0").trigger("click"); $("#cantica0").trigger("click");
//$("#vistaFrasi").css("display", "none");
}); });
//var queryExecuted = true; //var queryExecuted = true;
//$(cantoDisplayed).attr('style', 'display: d-flex;'); //$(cantoDisplayed).attr('style', 'display: d-flex;');

View File

@ -420,7 +420,7 @@ function buildSPQuery(guiquery) {
theguiQ = guiquery; theguiQ = guiquery;
var SparqlParser = sparqljs.Parser; var SparqlParser = sparqljs.Parser;
var spqparser = new SparqlParser(); var spqparser = new SparqlParser();
if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {//Multiple Conditions UR=Periodo if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {//Multiple Conditions
multipleCondSpQuery = spqparser.parse(sentencetargetquery); multipleCondSpQuery = spqparser.parse(sentencetargetquery);
bindConcatStatement = JSON.parse(sentencetarget_functionbind); bindConcatStatement = JSON.parse(sentencetarget_functionbind);
occBindConcatStatement = JSON.parse(sentencetarget_occbind); occBindConcatStatement = JSON.parse(sentencetarget_occbind);
@ -433,8 +433,9 @@ function buildSPQuery(guiquery) {
var test = guiquery['EsprLogica'].join(" "); var test = guiquery['EsprLogica'].join(" ");
test = test.replaceAll("( ", "(") test = test.replaceAll("( ", "(")
test = test.replaceAll(" )", ")") test = test.replaceAll(" )", ")")
clauses = parser.parse(test); var clauses = parser.parse(test);
jsonclauses = JSON.parse(clauses) //here get clauses
var jsonclauses = JSON.parse(clauses)
for (const ck of Object.keys(jsonclauses)) { for (const ck of Object.keys(jsonclauses)) {
parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where) parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where)
@ -453,6 +454,25 @@ function buildSPQuery(guiquery) {
} }
} }
//preprocess multiple conditions query
function processMultipleCond(rawquery){
for (var pc of rawquery['EsprLogica']){
if (pc.startsWith('Clausola')){
//console.log(rawquery[pc])
if ((rawquery[pc]['typeSyntax0'].trim() != 'all' || rawquery[pc]['functionSyntax'].trim() != 'all') &&
rawquery[pc]['typeGramm0'].trim() == 'all') {//solo filtro sintattico
rawquery[pc]["TipoClausola"]="Sintattico"
}
if ((rawquery[pc]['typeSyntax0'].trim() == 'all' && rawquery[pc]['functionSyntax'].trim() == 'all') &&
rawquery[pc]['typeGramm0'].trim() != 'all') {//solo filtro grammaticale
rawquery[pc]["TipoClausola"]="Grammaticale"
}
}
}
return rawquery
}
//BUILD THE QUERY! //BUILD THE QUERY!
@ -467,8 +487,8 @@ function buildSQ(stquery) {
console.log(stquery) console.log(stquery)
if (stquery['QueryAvanzata'] == 1 && stquery['EsprLogica'] != null && stquery['EsprLogica'].length > 1) { if (stquery['QueryAvanzata'] == 1 && stquery['EsprLogica'] != null && stquery['EsprLogica'].length > 1) {
//parsedquery = parser.parse(ontoSparqlQueryMultCond) var processedquery=processMultipleCond(stquery)
buildSPQuery(stquery) buildSPQuery(processedquery)
return multipleCondSpQuery; return multipleCondSpQuery;
} }
var clausolaS='Clausola0' var clausolaS='Clausola0'
@ -478,8 +498,8 @@ function buildSQ(stquery) {
filtroContesto = getFiltroContestoJson(JSON.parse(stquery[clause[0]]['contesto'])) filtroContesto = getFiltroContestoJson(JSON.parse(stquery[clause[0]]['contesto']))
if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+') || if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != 'all') ||
stquery[clause]['functionSyntax'].trim() != '.+') && stquery[clause]['functionSyntax'].trim() != 'all') &&
stquery[clause]['typeGramm0'].trim() == 'all') {//solo filtro sintattico stquery[clause]['typeGramm0'].trim() == 'all') {//solo filtro sintattico
parsedquery = parser.parse(ontoSparqlQuerySynt); parsedquery = parser.parse(ontoSparqlQuerySynt);
var tempsyntquery = buildSintacticClause(stquery[clause], parsedquery, 2) var tempsyntquery = buildSintacticClause(stquery[clause], parsedquery, 2)
@ -490,7 +510,7 @@ function buildSQ(stquery) {
} }
return tempsyntquery return tempsyntquery
} }
if ((stquery[clause]['typeSyntax0'].trim() == '.+' && stquery[clause]['functionSyntax'].trim() == '.+') && if ((stquery[clause]['typeSyntax0'].trim() == 'all' && stquery[clause]['functionSyntax'].trim() == 'all') &&
stquery[clause]['typeGramm0'].trim() != 'all') {//solo filtro grammaticale stquery[clause]['typeGramm0'].trim() != 'all') {//solo filtro grammaticale
myquery = buildClause(stquery[clause], parsedquery, 2) myquery = buildClause(stquery[clause], parsedquery, 2)
if (filtroContesto.length > 0) { if (filtroContesto.length > 0) {
@ -509,8 +529,8 @@ function buildSQ(stquery) {
} }
if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+') || if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+' && stquery[clause]['typeSyntax0'].trim() != 'all') ||
(stquery[clause]['functionSyntax'].trim() != '' && stquery[clause]['functionSyntax'].trim() != '.+')) && (stquery[clause]['functionSyntax'].trim() != '' && stquery[clause]['functionSyntax'].trim() != 'all')) &&
stquery[clause]['typeGramm0'].trim() != 'all') {//entrambi i filtri stquery[clause]['typeGramm0'].trim() != 'all') {//entrambi i filtri
console.log('entrambi i filtri') console.log('entrambi i filtri')
//preparo la query sparql //preparo la query sparql
@ -758,12 +778,12 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
var typeS = clause['typeSyntax0'] var typeS = clause['typeSyntax0']
console.log(functS + ' ' + typeS) console.log(functS + ' ' + typeS)
var myf = '' var myf = ''
if (functS != null && functS != ".+") { if (functS != null && functS != ".+" && functS != "all") {
myf = buildsyntClause(funzione_clausola[functS]) myf = buildsyntClause(funzione_clausola[functS])
if (myf != '') if (myf != '')
tmpgroup.patterns.at(-1).triples.push(myf) tmpgroup.patterns.at(-1).triples.push(myf)
} }
if (typeS != null && typeS != ".+") { if (typeS != null && typeS != ".+" && typeS != "all") {
var alltipi = Object.assign(macrotipi_sint, tipi_sint); var alltipi = Object.assign(macrotipi_sint, tipi_sint);
let mymt = alltipi[typeS] let mymt = alltipi[typeS]