implementazione query

This commit is contained in:
cesare 2025-02-20 14:02:54 +01:00
parent 0dbde2b4a9
commit a2796b54fa
3 changed files with 23 additions and 19 deletions

View File

@ -1980,7 +1980,7 @@ $(document).ready(function() {
}
//cambiare!
for (var ip=1; ip<10; ip++){
for (var ip=1; ip<30; ip++){
if (binding.has('pos'+ip)){
var tp=binding.get('pos'+ip).value;
if (!result.has(tp))

View File

@ -411,12 +411,12 @@ const sentencetarget_morphgroup_short = `{"type": "group",
{"subject": {"termType": "Variable","value": "fa"},
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/OccursInRegion"},
"object": {"termType": "Variable", "value": "reg"}},
{"subject": {"termType": "Variable","value": "cloccte"},
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148_has_component"},
"object": {"termType": "Variable","value": "fa"}},
{"subject": {"termType": "Variable","value": "cloccte"},
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"},
"object": {"termType": "Variable","value": "clg"}},
{"subject": {"termType": "Variable","value": "cloccte"},
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148_has_component"},
"object": {"termType": "Variable","value": "fa"}},
{"subject": {"termType": "Variable","value": "reg"},
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionFrom"},
"object": {"termType": "Variable","value": "pos"}},

View File

@ -378,7 +378,8 @@ var unionop = `{"union": {"type": "union", "patterns":[]}, "bgp": {"type": "bgp"
var idtoken = 0;
var idtokenor = 0;
var orfilters=[]
function parseJsonClause(op, tokens, nowhere) {
//alert(op)
var idp = -1
@ -390,6 +391,14 @@ function parseJsonClause(op, tokens, nowhere) {
if (op.trim() == 'OR') {
nowhere.splice(0, 0, JSON.parse(unionop)['union'])
idtokenor=idtoken+20
var tmpcoal=clausetarget_coalesce.replaceAll("pos","pos"+idtokenor)
clausePosCoalesceStatement = JSON.parse(tmpcoal);
tmpcoal =`{
"termType": "Variable",
"value": "pos`+ idtokenor + `"
}`
multipleCondSpQuery['variables'].push(JSON.parse(tmpcoal))
nowhere.splice(1, 0, clausePosCoalesceStatement)
idp = 0
}
@ -425,11 +434,10 @@ function buildSPQuery(guiquery) {
bindConcatStatement = JSON.parse(sentencetarget_functionbind);
occBindConcatStatement = JSON.parse(sentencetarget_occbind);
posBindConcatStatement = JSON.parse(sentencetarget_posbind);
clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
//clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
if (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
multipleCondSpQuery = spqparser.parse(clausetargetquery);
//clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
}
if (theguiQ['unitaRicerca'] == 'periodo') {//Multiple Conditions
@ -449,20 +457,13 @@ function buildSPQuery(guiquery) {
//here get clauses
var jsonclauses = JSON.parse(clauses)
idtoken = 0
idtokenor=0
orfilters=[]
for (const ck of Object.keys(jsonclauses)) {
parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where)
/*if (ck.trim()=='OR' && (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso')) {
multipleCondSpQuery.where.push(clausePosCoalesceStatement)
}*/
}
/*if (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
multipleCondSpQuery.where.push(clausePosCoalesceStatement)
}*/
if (theguiQ['unitaRicerca'] == 'periodo') {
multipleCondSpQuery.where.push(bindConcatStatement)
multipleCondSpQuery.where.push(occBindConcatStatement)
@ -787,9 +788,12 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token, op
}`
if (op == 'OR') {
clausePosCoalesceStatement['expression']['args'].push(JSON.parse(tmppos))
var orfilter=clausepos_filter.replaceAll("pos_", "pos")
if (!parsedquery['where'].includes(JSON.parse(orfilter)))
var orfilter=clausepos_filter.replaceAll("pos_", "pos"+idtokenor)
if (orfilters.length==0 || !orfilters.includes(orfilter)){
parsedquery['where'].push(JSON.parse(orfilter))
orfilters.push(orfilter)
}
}
else{
parsedquery['variables'].push(JSON.parse(tmppos))