From 036d1f5f28c9416e6d62cec49076e5d1d176f60d Mon Sep 17 00:00:00 2001 From: cesare Date: Wed, 13 Dec 2023 17:04:58 +0100 Subject: [PATCH] selezione contesto (in progress) --- js/utils.js | 67 ++++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 50 deletions(-) diff --git a/js/utils.js b/js/utils.js index d1ad20a..28b09e5 100644 --- a/js/utils.js +++ b/js/utils.js @@ -531,9 +531,9 @@ function getFiltroContestoJson(datiContesto) { if (Object.keys(canticheids).length > 0){ - console.log(JSON.stringify(canticheids)) + //console.log(JSON.stringify(canticheids)) var test=buildFilterContextJson (canticheids) - console.log(test) + return (test) } else @@ -733,50 +733,6 @@ function getStringFilter(filter, opzione) { function buildFilterContextJson( contextcantiche) { var resfilters=[] - var tcontextgroup = ` { - "type": "group", - "patterns": [ - { - "type": "bgp", - "triples": [ - {"subject": {"termType": "Variable","value": "clocc"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/orl/current/occurrenceOf"}, - "object": {"termType": "Variable","value": "cl"}}, - {"subject": {"termType": "Variable","value": "clocc"}, - "predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148_has_component"}, - "object": {"termType": "Variable","value": "fa"}}, - {"subject": {"termType": "Variable","value": "clocc"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occursInRegion"}, - "object": {"termType": "Variable","value": "frag"}}, - {"subject": {"termType": "Variable","value": "sentence"}, - "predicate": {"termType": "NamedNode","value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, - "object": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/Sentence"}}, - {"subject": {"termType": "Variable","value": "sentence"}, - "predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148i_is_component_of"}, - "object": {"termType": "Variable","value": "canto"}}, - {"subject": {"termType": "Variable","value": "sentence"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasSyntacticalComponent"}, - "object": {"termType": "Variable","value": "cl"}}, - {"subject": {"termType": "Variable","value": "cl"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseType"}, - "object": {"termType": "Variable","value": "clatype"}}, - {"subject": {"termType": "Variable","value": "cl"}, - "predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P190_has_symbolic_content"}, - "object": {"termType": "Variable","value": "cltext"}}, - {"subject": {"termType": "Variable","value": "cl"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseFunction"}, - "object": {"termType": "Variable","value": "clafunction"}}, - {"subject": {"termType": "Variable","value": "frag"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionFrom"}, - "object": {"termType": "Variable","value": "clfr"}}, - {"subject": {"termType": "Variable","value": "frag"}, - "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionTo"}, - "object": {"termType": "Variable","value": "clto"}} - ] - } - ] - } - ` var contextgroup = ` { "type": "group", "patterns": [ @@ -876,12 +832,23 @@ function buildFilterContextJson( contextcantiche) { filters['expression']['args'].push(contextfilter) //resfilters.push(filters) cgroup.patterns.splice(0,0,filters) + cantichefilters['expression']['args'].push(cantichecontextfilter) + + cgroup.patterns.splice(0,0, cantichefilters) + resfilters.push(cgroup) } + + } + var uniontmp=`{"type": "union", "patterns":[]}` + jsunion=JSON.parse(uniontmp) + if (resfilters.length>1){ + var tmpres=[] + for (filter in resfilters){ + jsunion.patterns.push(resfilters[filter]) + } + tmpres.push(jsunion) + return (tmpres) } - cantichefilters['expression']['args'].push(cantichecontextfilter) - //resfilters.push(cantichefilters) - cgroup.patterns.splice(0,0, cantichefilters) - resfilters.push(cgroup) return resfilters