This commit is contained in:
nicola 2025-03-11 19:44:12 +01:00
commit fbd21a26bb
1 changed files with 76 additions and 5 deletions

View File

@ -150,6 +150,67 @@ var orlprefix = 'https://dantenetwork.it/ontology/orl/current/'
var syntitprefix = 'https://dantenetwork.it/ontology/syntit/current/'
function getVersoContext(versoid, numversi = 3) {
var context = []
var listaforme = formeprima;
var cantica = versoid[0]
var offset=0
var canto= parseInt(versoid[2])
var num=parseInt(versoid[3])
if (cantica == 'Purgatorio') {
offset = 33374
listaforme = formeseconda;
console.log(listaforme.length)
}
if (cantica == 'Paradiso3') {
offset = 66588
listaforme = formeterza;
}
var maxpos = listaforme.length - 1
var pos = 0
var startindex = Math.max(0, (offset - 30))
//cerco la posizione iniziale del verso precedente
var startver= Math.max(0, num-1)
for (i = startindex; i < listaforme.length; i++) {
var tmpos = listaforme[i].split('_')[1]
if (parseInt(tmpos) == parseInt(canto)) {
var vtmp=listaforme[i].split('_')[3]
if (parseInt(vtmp)==startver){
pos = i;
break;
}
}
}
var endpos=pos
for (j = pos; j < listaforme.length; j++) {
var tmposj = listaforme[j].split('_')[1]
if (parseInt(tmposj) == parseInt(canto)) {
var vtmpj=listaforme[j].split('_')[3]
if (parseInt(vtmpj)==startver+3){
break;
}
endpos=j
}
}
for (var ji = pos; ji < endpos + 1; ji++) {
var tmpform = listaforme[ji].split('_');
var contextitem = {}
contextitem['testo'] = tmpform[0];
contextitem['verso'] = tmpform[3];
contextitem['canto'] = tmpform[1];
contextitem['cantica'] = cantica - 1;
contextitem['posizione'] = tmpform[2];
contextitem['catg'] = tmpform[4];
contextitem['periodo'] = cantica + '_' + tmpform[1] + '_s_' + tmpform[5];
contextitem['funzperiodo'] = tmpform[6];
context.push(contextitem);
}
return context;
}
function getFraseContext(fraseids, numversi = 3) {
var context = []
@ -169,7 +230,7 @@ function getFraseContext(fraseids, numversi = 3) {
offset = parseInt(fraseid.split('-')[2]) - 66588
listaforme = formeterza;
}
maxpos = listaforme.length - 1
var maxpos = listaforme.length - 1
var pos = 0
var startindex = Math.max(0, (offset - 30))
@ -857,9 +918,19 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token, op
parsedquery['variables'].push(JSON.parse(tmppos))
var andfilter = clausepos_gr_filter.replaceAll("pos_", "pos" + token)
//TEST
if (document.querySelector('#Posizione_fr') != null &&
document.querySelector('#Posizione_fr').value.trim() != '') {
var posrestr = document.querySelector('#Posizione_fr').value
/*if (document.querySelector('#Posizione_fr') != null &&
document.querySelector('#Posizione_fr').value.trim() != '') */
if (clause['Posizioni']!=null && clause['Posizioni']!='1,37'){
var pospar= clause['Posizioni'].split(',')
if (pospar[0]==pospar[1]){
andfilter = andfilter.replace('<=', '=')
andfilter = andfilter.replace('clfr', 'clfr+' + (parseInt(pospar[1])-1))
}
else{
andfilter = andfilter.replace('clfr', 'clfr+' + (parseInt(pospar[0])))
andfilter = andfilter.replace('clto', 'clfr+' + (parseInt(pospar[1])))
}
/*var posrestr = document.querySelector('#Posizione_fr').value
var pospar = []
try {
pospar = parserFiltroPosizione.parse(posrestr.trim())
@ -881,7 +952,7 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token, op
catch (err) {
console.log(err)
}
*/
}
parsedquery['where'].push(JSON.parse(andfilter))