query, in progress

This commit is contained in:
cesare 2025-02-19 17:50:55 +01:00
parent 9c138ccdb6
commit 0dbde2b4a9
5 changed files with 271 additions and 209 deletions

View File

@ -1,9 +1,9 @@
/**
*
*/
import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getFormaCntxt, getListaIdCommenti, queryRiferimentimul} from './dataMgr_5.1.js';
import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getFormaCntxt, getListaIdCommenti, queryRiferimentimul } from './dataMgr_5.1.js';
import { getJsonQuery, emptyStructCard } from './script_5.1.js';
import {resetGraphStr} from './syntgraph_5.1.js'
import { resetGraphStr } from './syntgraph_5.1.js'
export var resetResult;
@ -36,7 +36,7 @@ $(document).ready(function() {
const dialogaltri = 'diaAltri'
var listaClausoleRisultatoContesti = []
var listaRisultatiCommenti=[]
var listaRisultatiCommenti = []
const sparqlGenerator = sparqljs.Generator;
const myEngine = new Comunica.QueryEngine();
@ -213,7 +213,7 @@ $(document).ready(function() {
var setVersicontestoExp = new Set()
for (var forma of versiContestoExp) {
if (!setVersicontestoExp.has(forma.verso)) {
divVersoExp = createDivVersoLI(forma.cantica+1, forma.verso, forma.canto)
divVersoExp = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
$(reit).append(divVersoExp)
setVersicontestoExp.add(forma.verso)
}
@ -355,11 +355,11 @@ $(document).ready(function() {
res.sort(function(a, b) { return a - b });
return (res)
}
if (listaClausoleRisultatoContesti.length && !listarisultati.length ) {
var lim=endcont
if (listaClausoleRisultatoContesti.length<=endcont)
lim=listaClausoleRisultatoContesti.length-1
for (let i=startcont; i<=lim; i++){
if (listaClausoleRisultatoContesti.length && !listarisultati.length) {
var lim = endcont
if (listaClausoleRisultatoContesti.length <= endcont)
lim = listaClausoleRisultatoContesti.length - 1
for (let i = startcont; i <= lim; i++) {
res.push(listaClausoleRisultatoContesti[i])
}
//res.sort(function(a, b) { puno = a[0].split('-')[3]; pdue = b[0].split('-')[3]; return parseInt(puno) - parseInt(pdue) });
@ -389,17 +389,17 @@ $(document).ready(function() {
continue;
}
var versiContesto = ''
var ctxpivot=0
var ctxpivot = 0
if (!Array.isArray(risultato)) {
risultato = parseInt(risultato)
versiContesto = getFormaContext(risultato, contextLength);
ctxpivot=risultato
ctxpivot = risultato
}
else{
else {
versiContesto = getFraseContext(risultato, contextLength);
if(versiContesto.length){
var tmind=Math.floor(versiContesto.length/2);
ctxpivot=versiContesto[tmind]['posizione']
if (versiContesto.length) {
var tmind = Math.floor(versiContesto.length / 2);
ctxpivot = versiContesto[tmind]['posizione']
}
}
@ -542,8 +542,8 @@ $(document).ready(function() {
//$("#" + $(this).attr('name').replace(" ", "_")).css("display", "block");
$("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display: d-flex;')
var telive=getListaRis()
for (var tel of telive){
var telive = getListaRis()
for (var tel of telive) {
$(tel).addClass("mark ")
}
@ -853,24 +853,24 @@ $(document).ready(function() {
async function initCitazioni() {
//"#InfernoCanto_1"
var idcantica='1'
var idcantica = '1'
var mcanto = cantoDisplayed.replace("#", '')
var cantica = ''
if (mcanto.startsWith('Inf'))
cantica = 'Inferno'
if (mcanto.startsWith('Pur')){
if (mcanto.startsWith('Pur')) {
cantica = 'Purgatorio'
idcantica='2'
idcantica = '2'
}
if (mcanto.startsWith('Par')) {
if (mcanto.startsWith('Par')) {
cantica = 'Paradiso'
idcantica='3'
idcantica = '3'
}
var canto = mcanto.split('_')[1]
var idCommento = "Commento_" + idcantica + "_" + canto + "_";
var idverso=cantica+'_Canto_'+canto+'_'
var idminimap=cantica+'Canto_'+canto
var idverso = cantica + '_Canto_' + canto + '_'
var idminimap = cantica + 'Canto_' + canto
/*console.log(myid)*/
if (canto.length == 1)
canto = '0' + canto
@ -878,25 +878,25 @@ $(document).ready(function() {
/*
*/
var mresult =await getVersiConCitazioni(cantica, canto)
var mresult = await getVersiConCitazioni(cantica, canto)
commentsSQL= Object.groupBy(mresult, ({ VersoCitazione }) => VersoCitazione);
commentsSQL = Object.groupBy(mresult, ({ VersoCitazione }) => VersoCitazione);
var tmpkeys=[]
var tmpkeys = []
for (const ke in commentsSQL){
for (const ke in commentsSQL) {
//console.log(ke.split('-')[0])
var t=ke.split('-')[0]
var t = ke.split('-')[0]
if (tmpkeys.indexOf(t) == -1)
tmpkeys.push(t)
else
continue
var pio=$( "#"+idCommento+t)
if(pio.length)
var pio = $("#" + idCommento + t)
if (pio.length)
break;
var elverso=$( "#"+idverso+t)//$("li[value='"+t+"']")
var elverso = $("#" + idverso + t)//$("li[value='"+t+"']")
//console.log(elverso)
createCommentSpan(idCommento+t, elverso, commentsSQL[ke].length)
createCommentSpan(idCommento + t, elverso, commentsSQL[ke].length)
}
drawMinimap("#" + idminimap, false)
@ -937,7 +937,7 @@ $(document).ready(function() {
$("#noteCard0")[0].remove();
}
var id = cid.substr(9);
id=parcid.at(-1)
id = parcid.at(-1)
var collapseNote;
var gruppoVersi;
var versText = "";
@ -947,11 +947,11 @@ $(document).ready(function() {
var currentGroup;
allGrouplKeys.sort().some(function(k) {
if (k == id || k.startsWith(id+'-')){ //~k.indexOf(id + '-')) {
if (k == id || k.startsWith(id + '-')) { //~k.indexOf(id + '-')) {
//console.log('gruppo commenti '+k)
console.log(commentsSQL[k].length)
//gruppoVersi = k.split("_").slice(-1)[0]
gruppoVersi=k
gruppoVersi = k
if (gruppoVersi.includes("-")) {
versText = ", Versi " + gruppoVersi;
} else {
@ -959,9 +959,9 @@ $(document).ready(function() {
}
currentGroup = createNoteGroup(cantica, getRoman(parcid[2]), versText, k, commentsSQL[k].length)
commentsSQL[k].forEach(function(value, i) {
currentGroup.append(createNoteEntry(value, k, i))
});
commentsSQL[k].forEach(function(value, i) {
currentGroup.append(createNoteEntry(value, k, i))
});
commentArea.append(currentGroup);
}
$('#tab-list #vis0-tab').tab('show')
@ -993,13 +993,13 @@ $(document).ready(function() {
}
function createNoteEntry(comments, id, pos) {
const tmplistaidcomm=getListaIdCommenti()
var idref=comments.Id
if(tmplistaidcomm.length && tmplistaidcomm.includes(idref)){
var noteCard = $('<div class="card card-body border-success well well-sm mx-1 mb-1 mt-0 p-0" id="noteCard' + id + '_' + pos +'"'+ ' name= "'+idref+'">');
const tmplistaidcomm = getListaIdCommenti()
var idref = comments.Id
if (tmplistaidcomm.length && tmplistaidcomm.includes(idref)) {
var noteCard = $('<div class="card card-body border-success well well-sm mx-1 mb-1 mt-0 p-0" id="noteCard' + id + '_' + pos + '"' + ' name= "' + idref + '">');
}
else
var noteCard = $('<div class="card card-body well well-sm mx-1 mb-1 mt-0 p-0 border-lida08" id="noteCard' + id + '_' + pos +'"'+ ' name= "'+idref+'">');
var noteCard = $('<div class="card card-body well well-sm mx-1 mb-1 mt-0 p-0 border-lida08" id="noteCard' + id + '_' + pos + '"' + ' name= "' + idref + '">');
var collapseCardBody = $('<div class="card-body px-0 py-1 mx-3 my-0 border-top rounded" >');
var divCampiSingoli = $('<div class="d-flex align-content-start flex-wrap text-muted">');
@ -1190,7 +1190,7 @@ $(document).ready(function() {
function createModuleCommentatore(collapse, commento, num, id, pos) {
let tmpcomm = commento
let tmpcomm = commento
let jsonCommento = JSON.parse(tmpcomm.replaceAll("'", '"').replaceAll("+", '"'));
/*var minLength = (($('#displaynote').width() / ($('#Test').width() / 32)) * 2 * 1.63);*/
var divContent = $('<div class="d-flex align-content-start flex-wrap text-muted">');
@ -1199,8 +1199,8 @@ $(document).ready(function() {
var lenmod = 0
for (var el in jsonCommento) {
var tmpcc=JSON.parse(jsonCommento[el])
console.log(' el '+tmpcc)
var tmpcc = JSON.parse(jsonCommento[el])
console.log(' el ' + tmpcc)
var urlCommento = tmpcc["Commento"];
var esitoCommento = tmpcc.Rapporto;
@ -1284,8 +1284,8 @@ $(document).ready(function() {
var id = cid.split('_').at(-1)
for (const [keyt, value] of Object.entries(commentsSQL)) {
if (keyt == id || keyt.startsWith(id+'-')) {
for (const [keyt, value] of Object.entries(commentsSQL)) {
if (keyt == id || keyt.startsWith(id + '-')) {
return true
}
}
@ -1301,9 +1301,9 @@ $(document).ready(function() {
function numberOfCommentsJson(cid) {
var cntc = 0
var id=cid.split('_').at(-1)
for (const keyt in commentsSQL){
if (keyt==id) {
var id = cid.split('_').at(-1)
for (const keyt in commentsSQL) {
if (keyt == id) {
cntc = commentsSQL[keyt].length
break
}
@ -1469,14 +1469,14 @@ $(document).ready(function() {
//manageMM (cantoDisplayed)
//var currPage = 0;
//var latestPhraseId = "";
var telive=getListaRis()
var telive = getListaRis()
for (var ve of telive) {
//let idve = ve
$(ve).removeClass("mark ")
minim.contents().find(ve).removeClass("mark ")
}
const tmplistaidcomm=getListaIdCommenti()
for (var idco of tmplistaidcomm){
const tmplistaidcomm = getListaIdCommenti()
for (var idco of tmplistaidcomm) {
//$('[name="' + cantica + 'Canto ' + k + '"]')
$('[name="' + idco + '"]').removeClass('border-success ')
}
@ -1507,14 +1507,14 @@ $(document).ready(function() {
unitaRicerca = 'forma'
else
unitaRicerca = jsonQuery['unitaRicerca']
if (unitaRicerca=='riferimento'){
var esprLR=jsonQuery.EsprLogicaRif
if(esprLR.length && esprLR.length==1){
listaRisultatiCommenti=queryRiferimenti(jsonQuery[esprLR[0].trim()], cantoDisplayed)
if (unitaRicerca == 'riferimento') {
var esprLR = jsonQuery.EsprLogicaRif
if (esprLR.length && esprLR.length == 1) {
listaRisultatiCommenti = queryRiferimenti(jsonQuery[esprLR[0].trim()], cantoDisplayed)
return
}
else{
listaRisultatiCommenti=queryRiferimentimul(jsonQuery, cantoDisplayed)
else {
listaRisultatiCommenti = queryRiferimentimul(jsonQuery, cantoDisplayed)
}
return
}
@ -1906,15 +1906,12 @@ $(document).ready(function() {
//alert(query)
$("#loader").fadeIn(300);
//$("#searchcomm2").prop("disabled", true);
//$("#searchcomm2").html('<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span> Searching...');
try {
var seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
}
catch (err) {
$("#loader").fadeOut(300);
//$("#searchcomm2").prop("disabled", false);
//$("#searchcomm2").html('<span class="" role="status" aria-hidden="true"></span> Search');
console.log(err.message);
};
@ -1927,7 +1924,7 @@ $(document).ready(function() {
var cantica = 'Nessuna'
var canto = 'Canto 0'
//var numverso=0
var pos=0
var pos = 0
seachbBindingsStream.on('data', (binding) => {
//cantica
@ -1981,6 +1978,16 @@ $(document).ready(function() {
resultsInCantica.push(cantica);
resultsInCanto.push(cantica + canto)
}
//cambiare!
for (var ip=1; ip<10; ip++){
if (binding.has('pos'+ip)){
var tp=binding.get('pos'+ip).value;
if (!result.has(tp))
result.add(tp)
}
}
//cambiare!
if (unitaRicerca != 'frase' && pos == -1) {
unitaRicerca = 'frase'
}
@ -2027,7 +2034,7 @@ $(document).ready(function() {
//if (!resSent.has(fraseItems[0] + '-' + fraseItems[3])) {
let tmpocc = fraseItems.slice(-1)
if (resClauses.filter(clocc => clocc == tmpocc[0]).length == 0 || tmpocc[0]=='') {
if (resClauses.filter(clocc => clocc == tmpocc[0]).length == 0 || tmpocc[0] == '') {
resClauses.push(tmpocc[0]);
//resSent.add(fraseItems[0] + '-' + fraseItems[3]+'-'+fraseItems[1] + '-' + fraseItems[2]);
resSentence.add(fraseItems[1] + '-' + fraseItems[2]);
@ -2135,7 +2142,7 @@ $(document).ready(function() {
}
tempr.forEach(y => listaClausoleRisultatoContesti.push(listaClausoleRisultato.filter(x => (x.split('-')[0] == y) && x.split('-').length > 1)))
}
}
//aggiunge badge con totale risultati accanto alle cantiche
@ -2155,8 +2162,8 @@ $(document).ready(function() {
showBadgeInCanto(resultsInCanto)
console.log('badge end...')
//calcolo numero dei contesti
countResultContexts()
//calcolo numero dei contesti
countResultContexts()
$("#loader").fadeOut(300);
// mostra lista risultati
//$.manageResultList(0, showOffset);
@ -2165,8 +2172,8 @@ $(document).ready(function() {
});
//var queryExecuted = true;
//$(cantoDisplayed).attr('style', 'display: d-flex;');
/* $("#cantica0").trigger("click");
$("#vistaFrasi").css("display", "none");*/
/* $("#cantica0").trigger("click");
$("#vistaFrasi").css("display", "none");*/
}
catch (err) {

View File

@ -109,8 +109,8 @@ WHERE {
}`
//Query per advanced search con obiettivo = 'Frase'
const clausetargetquery = `
//Query per advanced search con obiettivo = 'Frase'
const clausetargetquery = `
PREFIX ecrm: <http://erlangen-crm.org/current/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX olires: <https://dantenetwork.it/ontology/olires/current/>
@ -127,8 +127,8 @@ WHERE {
ecrm:P148i_is_component_of ?canto.
?cl syntit:hasClauseType ?clatype;
syntit:hasClauseFunction ?clafun.
?seocc olires:occurrenceOf ?sentence;
olires:occursInRegion ?frag.
#?seocc olires:occurrenceOf ?sentence;
# olires:occursInRegion ?frag.
?claocc olires:occurrenceOf ?cl;
olires:occursInRegion ?fragcl.
?fragcl olires:fragmentRegionFrom ?clfr;
@ -137,15 +137,15 @@ WHERE {
?canto ecrm:P102_has_title ?t_canto;
olires:hasNumber ?num.
?cantica ecrm:P102_has_title ?t_cantica;
olires:hasStructuralComponent ?canto.
BIND(CONCAT(STR(?clafun), ';') AS ?clafunction)
BIND(STR(?clatype) AS ?clt)
FILTER (?clto > ?pos && ?clfr<?pos) .
olires:hasStructuralComponent ?canto.
BIND(CONCAT(STR(?clafun), ';') AS ?clafunction)
BIND(STR(?clatype) AS ?clt)
#FILTER (?clto > ?pos && ?clfr<?pos) .
}`
//bindConcatStatement
const clausetarget_functionbind=
`{
//bindConcatStatement
const clausetarget_functionbind =
`{
"type": "bind",
"variable": {
"termType": "Variable",
@ -157,9 +157,9 @@ WHERE {
"args": []
}
}`
//clauseTypeBindConcatStatement
const clausetarget_typebind=
`{
//clauseTypeBindStatement
const clausetarget_typebind =
`{
"type": "bind",
"variable": {
"termType": "Variable",
@ -167,7 +167,7 @@ WHERE {
},
"expression": {
"type": "operation",
"operator": "concat",
"operator": "",
"args": []
}
}`
@ -178,8 +178,8 @@ WHERE {
*/
//clausePosCoalesceStatement
const clausetarget_coalesce=
`{
const clausetarget_coalesce =
`{
"type": "bind",
"variable": {
"termType": "Variable",
@ -192,6 +192,46 @@ WHERE {
}
}`
const clausepos_filter=`
{
"type": "filter",
"expression": {
"type": "operation",
"operator": "&&",
"args": [
{
"type": "operation",
"operator": ">",
"args": [
{
"termType": "Variable",
"value": "clto"
},
{
"termType": "Variable",
"value": "pos_"
}
]
},
{
"type": "operation",
"operator": "<",
"args": [
{
"termType": "Variable",
"value": "clfr"
},
{
"termType": "Variable",
"value": "pos_"
}
]
}
]
}
}
`
//Query per advanced search con obiettivo = 'Periodo'
const sentencetargetquery = `
PREFIX ecrm: <http://erlangen-crm.org/current/>
@ -219,13 +259,13 @@ SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?sentence ?clfr ?clto ?claf
olires:hasNumber ?num.
?cantica ecrm:P102_has_title ?t_cantica;
olires:hasStructuralComponent ?canto.
#BIND(concat(str(?clatype1),";", str(?clatype2)) AS ?clatype)
#BIND((str(?clatype1),";", str(?clatype2)) AS ?clatype)
#BIND(COALESCE(?posgen,-1) AS ?pos)
}
`
const sentencetargetstatement_posCoalesce=JSON.parse(`{
const sentencetargetstatement_posCoalesce = JSON.parse(`{
"type": "bind",
"variable": {
"termType": "Variable",
@ -253,8 +293,8 @@ const sentencetargetstatement_posCoalesce=JSON.parse(`{
}`)
const sentencetarget_functionbind=
`
const sentencetarget_functionbind =
`
{
"type": "bind",
"variable": {
@ -269,8 +309,8 @@ const sentencetarget_functionbind=
}
`
const sentencetarget_occbind=
`
const sentencetarget_occbind =
`
{
"type": "bind",
"variable": {
@ -285,8 +325,8 @@ const sentencetarget_occbind=
}
`
const sentencetarget_posbind=
`
const sentencetarget_posbind =
`
{
"type": "bind",
"variable": {
@ -362,7 +402,7 @@ const sentencetarget_morphgroup = `{"type": "group",
}
`
const sentencetarget_morphgroup_short = `{"type": "group",
const sentencetarget_morphgroup_short = `{"type": "group",
"patterns": [{"type": "bgp",
"triples": [
{"subject": {"termType": "Variable","value": "fa"},
@ -389,30 +429,30 @@ const sentencetarget_morphgroup = `{"type": "group",
}
`
const sentencetarget_posVariable=`{
const sentencetarget_posVariable = `{
"termType": "Variable",
"value": "pos"
}`
const lemma_writtenrepresentation = `{"subject": {"termType": "Variable", "value":"cf"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#writtenRep"}, "object": {"termType": "Variable", "value": "lm"}}`
const lemma_canonicalform = `{"subject": {"termType": "Variable", "value":"lent"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#canonicalForm"}, "object": {"termType": "Variable", "value": "cf"}}`
const lemma_lexicalform = `{"subject": {"termType": "Variable", "value":"lent"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#lexicalForm"},
const lemma_writtenrepresentation = `{"subject": {"termType": "Variable", "value":"cf"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#writtenRep"}, "object": {"termType": "Variable", "value": "lm"}}`
const lemma_canonicalform = `{"subject": {"termType": "Variable", "value":"lent"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#canonicalForm"}, "object": {"termType": "Variable", "value": "cf"}}`
const lemma_lexicalform = `{"subject": {"termType": "Variable", "value":"lent"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#lexicalForm"},
"object": {"termType": "Variable", "value": "form"}}`
const occurrenceof_form=`{"subject": {"termType": "Variable","value": "fa"},
const occurrenceof_form = `{"subject": {"termType": "Variable","value": "fa"},
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"},
"object": {"termType": "Variable","value": "form"}}`
const clauseocc_hascomponent_formocc=`{"subject": {"termType": "Variable","value": "cloccu"},
const clauseocc_hascomponent_formocc = `{"subject": {"termType": "Variable","value": "cloccu"},
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148_has_component"},
"object": {"termType": "Variable","value": "fa"}}`
const occurrenceof_clause=`{"subject": {"termType": "Variable","value": "cloccu"},
const occurrenceof_clause = `{"subject": {"termType": "Variable","value": "cloccu"},
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"},
"object": {"termType": "Variable","value": "cl"}}`
//DEFAULT QUERY PER SPARQL EDITOR
const defaultEditorQuery=`# ESEMPIO: i periodi della Commedia con una frase con tipo sintattico 'Subordinata Causale'
const defaultEditorQuery = `# ESEMPIO: i periodi della Commedia con una frase con tipo sintattico 'Subordinata Causale'
PREFIX ecrm: <http://erlangen-crm.org/current/>
PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/>
@ -431,4 +471,3 @@ WHERE {
} order by ?Cantica ?Canto`

View File

@ -156,7 +156,7 @@ function getFraseContext(fraseids, numversi = 3) {
break;
}
}
console.log (fraseid +" - " + parseInt(fraseid.split('-')[2])+ ' - '+pos)
console.log(fraseid + " - " + parseInt(fraseid.split('-')[2]) + ' - ' + pos)
var pos2 = pos
@ -367,8 +367,8 @@ function getStatements() {
var theguiQ = ''
var multipleCondSpQuery = ''
var bindConcatStatement = ''
var clauseTypeBindConcatStatement=''
var clausePosCoalesceStatement=''
var clauseTypeBindConcatStatement = ''
var clausePosCoalesceStatement = ''
var occBindConcatStatement = ''
var posBindConcatStatement = ''
@ -377,25 +377,25 @@ var filters = []
var unionop = `{"union": {"type": "union", "patterns":[]}, "bgp": {"type": "bgp", "triples":[]}, "group": {"type": "group", "patterns":[]}}`
var idtoken = 0;
function parseJsonClause(op, tokens, nowhere) {
//alert(op)
var idp = -1
if (nowhere[0].type == 'filter' && nowhere[0].expression.args[0].value == 'Rappresentazione') {
/*if (nowhere[0].type != null && nowhere[0].type == 'filter' && nowhere[0].expression.args[0].value == 'Rappresentazione') {
//nowhere.splice(0, 1)
nowhere.splice(0, 2)
}
}*/
if (op.trim() == 'OR') {
//nowhere.splice(1, 0, JSON.parse(unionop)['union'])
nowhere.splice(0, 0, JSON.parse(unionop)['union'])
nowhere.splice(1, 0, clausePosCoalesceStatement)
idp = 0
}
if (op.trim() == 'AND') {
//nowhere.splice(1, 0, JSON.parse(unionop)['group'])
nowhere.splice(0, 0, JSON.parse(unionop)['group'])
//idp = 1
idp = 0
}
@ -403,12 +403,12 @@ function parseJsonClause(op, tokens, nowhere) {
te_op = tokens[mtoken]
if ('TERM' in te_op) {
cond = theguiQ[te_op['TERM']]
multipleCondSpQuery = buildStatementClause(cond, multipleCondSpQuery, -1, nowhere[idp].patterns, mtoken)
idtoken += 1;
multipleCondSpQuery = buildStatementClause(cond, multipleCondSpQuery, -1, nowhere[idp].patterns, idtoken, op.trim())
}
else
parseJsonClause(Object.keys(te_op)[0], te_op[Object.keys(te_op)[0]], nowhere.at(-1).patterns)
parseJsonClause(Object.keys(te_op)[0], te_op[Object.keys(te_op)[0]], nowhere[0].patterns)
}
@ -422,17 +422,21 @@ function buildSPQuery(guiquery) {
var SparqlParser = sparqljs.Parser;
var spqparser = new SparqlParser();
multipleCondSpQuery = spqparser.parse(ontoSparqlQueryMultCond);
bindConcatStatement = JSON.parse(sentencetarget_functionbind);
occBindConcatStatement = JSON.parse(sentencetarget_occbind);
posBindConcatStatement = JSON.parse(sentencetarget_posbind);
clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
if (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
multipleCondSpQuery = spqparser.parse(clausetargetquery);
clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
multipleCondSpQuery = spqparser.parse(clausetargetquery);
//clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
}
if (theguiQ['unitaRicerca'] == 'periodo') {//Multiple Conditions
multipleCondSpQuery = spqparser.parse(sentencetargetquery);
bindConcatStatement = JSON.parse(sentencetarget_functionbind);
/*bindConcatStatement = JSON.parse(sentencetarget_functionbind);
occBindConcatStatement = JSON.parse(sentencetarget_occbind);
posBindConcatStatement = JSON.parse(sentencetarget_posbind);
posBindConcatStatement = JSON.parse(sentencetarget_posbind);*/
}
@ -444,21 +448,21 @@ function buildSPQuery(guiquery) {
var clauses = parser.parse(test);
//here get clauses
var jsonclauses = JSON.parse(clauses)
idtoken = 0
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') {
/*if (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
multipleCondSpQuery.where.push(clausePosCoalesceStatement)
/*if (posBindConcatStatement['expression']['args'].length) {
multipleCondSpQuery.where.push(posBindConcatStatement)
multipleCondSpQuery.variables.push(JSON.parse(sentencetarget_posVariable))
//multipleCondSpQuery.where.push(sentencetargetstatement_posCoalesce)
}*/
}
}*/
if (theguiQ['unitaRicerca'] == 'periodo') {
multipleCondSpQuery.where.push(bindConcatStatement)
multipleCondSpQuery.where.push(occBindConcatStatement)
@ -474,17 +478,17 @@ function buildSPQuery(guiquery) {
}
//preprocess multiple conditions query
function processMultipleCond(rawquery){
for (var pc of rawquery['EsprLogica']){
if (pc.startsWith('Clausola')){
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"
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"
rawquery[pc]['typeGramm0'].trim() != 'all') {//solo filtro grammaticale
rawquery[pc]["TipoClausola"] = "Grammaticale"
}
}
@ -505,11 +509,11 @@ function buildSQ(stquery) {
console.log(stquery)
if (stquery['QueryAvanzata'] == 1 && stquery['EsprLogica'] != null && stquery['EsprLogica'].length > 1) {
var processedquery=processMultipleCond(stquery)
var processedquery = processMultipleCond(stquery)
buildSPQuery(processedquery)
return multipleCondSpQuery;
}
var clausolaS='Clausola0'
var clausolaS = 'Clausola0'
if (stquery['QueryAvanzata'] == 1 && stquery['EsprLogica'] != null && stquery['EsprLogica'] != '' && stquery['EsprLogica'].length == 1) {
clause = stquery['EsprLogica']
@ -588,7 +592,7 @@ function buildSQ(stquery) {
}
if (stquery[clause]['queryText'].trim() != "")
clausolaS=clause
clausolaS = clause
}
//Simple query
@ -672,7 +676,7 @@ function getFiltroContestoJson(datiContesto) {
return []
}
function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
function buildStatementClause(clause, parsedquery, whereind, theplace, token, op) {
//
var tmpgroup = ''
if (clause['TipoClausola'] == "Sintattico") {
@ -762,8 +766,9 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
"value": "pos`+ token + `"
}
]
}`
if (theguiQ['unitaRicerca'] == 'periodo'){
}`
if (theguiQ['unitaRicerca'] == 'periodo') {
posBindConcatStatement['expression']['args'].push(JSON.parse(tmppos))
tmppos = `{"termType": "Literal",
"value": ";",
@ -775,13 +780,24 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
}`
posBindConcatStatement['expression']['args'].push(JSON.parse(tmppos))
}
else
{
tmppos=`{
"termType": "Variable",
"value": "pos`+ token + `"
}`
clausePosCoalesceStatement['expression']['args'].push(JSON.parse(tmppos))
else {
tmppos = `{
"termType": "Variable",
"value": "pos`+ token + `"
}`
if (op == 'OR') {
clausePosCoalesceStatement['expression']['args'].push(JSON.parse(tmppos))
var orfilter=clausepos_filter.replaceAll("pos_", "pos")
if (!parsedquery['where'].includes(JSON.parse(orfilter)))
parsedquery['where'].push(JSON.parse(orfilter))
}
else{
parsedquery['variables'].push(JSON.parse(tmppos))
var andfilter=clausepos_filter.replaceAll("pos_", "pos"+ token)
parsedquery['where'].push(JSON.parse(andfilter))
}
}
tmpgroup = JSON.parse(tmpg)

View File

@ -76,7 +76,7 @@
value: defaultEditorQuery
},
requestConfig : {
endpoint : "https://hdnlab1.isti.cnr.it/fuseki/commedia/query"
endpoint : "https://lida.dantenetwork.it/fuseki/commedia/query"
},
copyEndpointOnNewTab : false,
resizeable : true,

View File

@ -937,91 +937,91 @@ WHERE {
<h5>Esempi di query sulla struttura</h5>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_1)'>
1 <a href="#" class="link-info" onClick='writeQuery(query_1)'>
Versetti in cui compare una forma.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_2)'>Versetti
2 <a href="#" class="link-info" onClick='writeQuery(query_2)'>Versetti
in cui compaiono parole che iniziano con una stringa.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_11)'>Le
3 <a href="#" class="link-info" onClick='writeQuery(query_11)'>Le
parole più frequenti in un libro.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_3)'>Versetti
4 <a href="#" class="link-info" onClick='writeQuery(query_3)'>Versetti
che si ripetono più volte.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_15)'>Le
5 <a href="#" class="link-info" onClick='writeQuery(query_15)'>Le
parole che compaiono in due libri, con il numero di occorrenze.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_12)'>Le
6 <a href="#" class="link-info" onClick='writeQuery(query_12)'>Le
parole di un libro, che non compaiono in un altro libro.</a>
</p>
<p>
<h5>Esempi di query sul 'livello linguistico'</h5>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_4)'>Cerco
7 <a href="#" class="link-info" onClick='writeQuery(query_4)'>Cerco
in un libro le forme associate ad un lemma.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_5)'>Cerco
8 <a href="#" class="link-info" onClick='writeQuery(query_5)'>Cerco
in tutta l'opera le forme associate ad un lemma.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_8)'>Cerco
9 <a href="#" class="link-info" onClick='writeQuery(query_8)'>Cerco
i verbi (lila:verb) presenti in un libro.</a>
</p>
<p>
<a href="#" class="link-info" onClick='writeQuery(query_17)'>I verbi più frequenti in un libro.</a>
10 <a href="#" class="link-info" onClick='writeQuery(query_17)'>I verbi più frequenti in un libro.</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_6)'>Cerco
11 <a href="#" class="link-danger" onClick='writeQuery(query_6)'>Cerco
i versetti di un libro in cui una parola in una specifica
posizione abbia categoria grammaticale 'lila:verb' (query
distribuita sul dataset di LiLa).</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_14)'>Cerco
12 <a href="#" class="link-danger" onClick='writeQuery(query_14)'>Cerco
i versetti di un libro in cui compaiano due parole consecutive
che hanno rispettivamente categoria grammaticale 'lila:verb' e
'lila:noun'</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_19)'>
13 <a href="#" class="link-danger" onClick='writeQuery(query_19)'>
Le occorrenze delle categorie verbali (lila:POS) delle prime 4 parole dei versetti del libro 'Genesis'.
</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_18)'>
14 <a href="#" class="link-danger" onClick='writeQuery(query_18)'>
TEST! Le occorrenze delle categorie verbali (lila:POS) nelle sequenze di 4 parole nei versetti del libro 'Genesi'.
</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_13)'>Cerco
15 <a href="#" class="link-danger" onClick='writeQuery(query_13)'>Cerco
le forme derivate da un lemma secondo le regole definite
dall'ontologia "Word Formation Latin" (WFL)</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_7)'>Termini
16 <a href="#" class="link-danger" onClick='writeQuery(query_7)'>Termini
con la stessa radice basati sulla proprieta lila:hasBase del
lemma cercato.</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_16)'>Cerca
17 <a href="#" class="link-danger" onClick='writeQuery(query_16)'>Cerca
le forme associate ai lemmi appartenenti ad un SynSet della
risorsa Latin WordNet pubblicata su LiLa</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_9)'>Cerco
18 <a href="#" class="link-danger" onClick='writeQuery(query_9)'>Cerco
i verbi (lila:Verb) presenti in un libro e per ciascun lemma
visualizzo la definizione nel dizionario Lewis &amp; Short.</a>
</p>
<p>
<a href="#" class="link-danger" onClick='writeQuery(query_10)'>Cerco
19 <a href="#" class="link-danger" onClick='writeQuery(query_10)'>Cerco
in un capitolo di un libro le forme che hanno una particolare
stringa nella definizione del dizionario Lewis & Short.</a>
</p>