5.1: espressioni logiche con riferimenti + corretto bug minimap
This commit is contained in:
parent
1eebd40af6
commit
054543f6fd
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,350 @@
|
|||
import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/+esm';
|
||||
|
||||
|
||||
//import * as arrow from 'https://cdn.skypack.dev/apache-arrow@9'
|
||||
|
||||
|
||||
var rif_commentatori = [];
|
||||
var rif_autori = [];
|
||||
var rif_areetematiche = [];
|
||||
var rif_fonti = [];
|
||||
var listaidversi = []
|
||||
var listaidcommenti=[]
|
||||
const cantobadgeclassBis = 'badge badge-outline-warning badge-pill'
|
||||
|
||||
const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
|
||||
|
||||
// Select a bundle based on browser checks
|
||||
const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
|
||||
|
||||
const worker_url = URL.createObjectURL(
|
||||
new Blob([`importScripts("${bundle.mainWorker}");`], { type: 'text/javascript' })
|
||||
);
|
||||
|
||||
// Instantiate the asynchronus version of DuckDB-wasm
|
||||
const worker = new Worker(worker_url);
|
||||
const logger = new duckdb.ConsoleLogger();
|
||||
const db = new duckdb.AsyncDuckDB(logger, worker);
|
||||
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
|
||||
URL.revokeObjectURL(worker_url);
|
||||
|
||||
console.log('datamgr init done')
|
||||
|
||||
|
||||
//await db.registerFileURL('remote.parquet', 'http://localhost:8000/js/data/riferimenti_3.parquet', DuckDBDataProtocol.HTTP, false);
|
||||
|
||||
/*const res = await fetch('http://localhost:8000/js/data/riferimenti_3.parquet');
|
||||
|
||||
await db.registerFileBuffer('buffer.parquet', new Uint8Array(await res.arrayBuffer()));*/
|
||||
|
||||
const conn = await db.connect();
|
||||
|
||||
await conn.query(`
|
||||
CREATE TABLE riferimenti AS
|
||||
SELECT * FROM "https://lida.dantenetwork.it/js/data/riferimenti_3.parquet";
|
||||
CREATE TABLE commedia AS
|
||||
SELECT * FROM "https://lida.dantenetwork.it/js/data/com.parquet";
|
||||
|
||||
`);
|
||||
|
||||
var table = await conn.query(`
|
||||
select distinct Aut from riferimenti order by Aut COLLATE NOCASE;
|
||||
`);
|
||||
const result = table.toArray().map((row) => row.toJSON());
|
||||
rif_autori = result.map((x) => x['Aut']);
|
||||
//console.log(rif_autori)
|
||||
|
||||
|
||||
var table = await conn.query(`
|
||||
select distinct Com from riferimenti;
|
||||
`);
|
||||
const result2 = table.toArray().map((row) => row.toJSON());
|
||||
rif_commentatori = result2.map((x) => x['Com']);
|
||||
|
||||
|
||||
|
||||
var table = await conn.query(`
|
||||
select distinct CA from riferimenti order by CA;
|
||||
`);
|
||||
const result3 = table.toArray().map((row) => row.toJSON());
|
||||
|
||||
rif_areetematiche = result3.map((x) => x['CA']);
|
||||
|
||||
|
||||
var table1 = await conn.query(`
|
||||
select distinct TiFo from riferimenti order by TiFo COLLATE NOCASE;
|
||||
`);
|
||||
const result4 = table1.toArray().map((row) => row.toJSON());
|
||||
//console.log(result4)
|
||||
rif_fonti = result4.map((x) => x['TiFo']);
|
||||
|
||||
//console.log(rif_fonti)
|
||||
var tableP = await conn.query(`
|
||||
select * from commedia limit 10;
|
||||
`);
|
||||
const result5 = tableP.toArray().map((row) => row.toJSON());
|
||||
console.log(result5)
|
||||
|
||||
await conn.close();
|
||||
|
||||
console.log('done')
|
||||
|
||||
opzioniRiferimenti()
|
||||
|
||||
export function getListaRis() {
|
||||
return listaidversi;
|
||||
}
|
||||
export function getListaIdCommenti() {
|
||||
return listaidcommenti;
|
||||
}
|
||||
export function cleanListaRis() {
|
||||
listaidversi = [];
|
||||
listaidcommenti=[]
|
||||
}
|
||||
export function getFontiS() {
|
||||
|
||||
return rif_fonti
|
||||
}
|
||||
|
||||
export function getAreeTematicheS() {
|
||||
|
||||
return rif_areetematiche
|
||||
}
|
||||
|
||||
export function getAutoriFontiCitazioniS() {
|
||||
|
||||
return rif_autori
|
||||
}
|
||||
|
||||
export function getCommentatoriS() {
|
||||
|
||||
return rif_commentatori
|
||||
}
|
||||
|
||||
export async function getVersiConCitazioni(canticapar = '', cantopar = '') {
|
||||
|
||||
//let citcantiche = ['Inferno', 'Purgatorio', 'Paradiso']
|
||||
if (canticapar == '') {
|
||||
return
|
||||
}
|
||||
const tconn = await db.connect();
|
||||
var table = await tconn.query(`
|
||||
select Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione,
|
||||
F as FonteCitazione, LF as LuogoFonteCitazione, NF as NotaFonteCitazione,
|
||||
TF as TestoFonteCitazione, UF as URLFonteCitazione, NaRi as NaturaRiferimento,
|
||||
RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto,
|
||||
Aut as NomeAutoreCitazione, TiFo as TitoloFonteCitazione, Verso as VersoCitazione, CA as AreaTematica,
|
||||
TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie,
|
||||
CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento as Id
|
||||
from riferimenti
|
||||
where Cantica='${canticapar}' and Canto='${cantopar}' order by verso;
|
||||
`);
|
||||
|
||||
var result4 = table.toArray().map((row) => row.toJSON());
|
||||
|
||||
|
||||
await tconn.close();
|
||||
return result4
|
||||
|
||||
}
|
||||
export async function queryRiferimenti(filtro, cid) {
|
||||
if (filtro == null) {
|
||||
return
|
||||
}
|
||||
console.log(filtro)
|
||||
var contenuti_riferimento = {
|
||||
'personaggio': " and CPER !='' and CPER !='no'",
|
||||
'episodio': " and CEP !='' and CEP !='no'",
|
||||
'motivo': " and CMO !='' and CMO !='no'",
|
||||
'immagine': " and CIM !='' and CIM !='no'",
|
||||
'teoria': " and CTE !='' and CTE !='no'",
|
||||
'stilema': " and CST !='' and CST !='no'",
|
||||
'topografia': " and CTO !='' and CTO !='no'"
|
||||
}
|
||||
const tconn = await db.connect();
|
||||
var tmpfiltro=''
|
||||
var querytl = 'select IdRiferimento, Cantica, Canto, Verso from riferimenti'
|
||||
var queryfi = ' where '
|
||||
if (filtro.Commentatore != null && filtro.Commentatore.trim() != 'all'){
|
||||
tmpfiltro=filtro.Commentatore.trim()
|
||||
tmpfiltro=tmpfiltro.replace("\'", "_")
|
||||
queryfi += "Com like'" + tmpfiltro + "'"
|
||||
}
|
||||
|
||||
else
|
||||
queryfi += "Com like '%'"
|
||||
if (filtro.Autore_Fonte != null && filtro.Autore_Fonte.trim() != 'all'){
|
||||
|
||||
tmpfiltro=filtro.Autore_Fonte
|
||||
tmpfiltro=tmpfiltro.replace("\'", "_")
|
||||
//console.log(tmpfiltro)
|
||||
queryfi += " and Aut like '" + tmpfiltro.trim()+ "'"
|
||||
|
||||
}
|
||||
|
||||
if (filtro.Fonte != null && filtro.Fonte.trim() != 'all')
|
||||
queryfi += " and TiFo='" + filtro.Fonte.trim() + "'"
|
||||
|
||||
if (filtro.Area_Tematica != null && filtro.Area_Tematica.trim() != 'all')
|
||||
queryfi += " and CA='" + filtro.Area_Tematica.trim() + "'"
|
||||
|
||||
if (filtro.Tipo_Riferimento != null && filtro.Tipo_Riferimento.trim() != 'all')
|
||||
queryfi += " and NaRi='" + filtro.Tipo_Riferimento.trim().toUpperCase() + "'"
|
||||
if (filtro.Contenuto_Riferimento != null && filtro.Contenuto_Riferimento != 'all')
|
||||
queryfi += contenuti_riferimento[filtro.Contenuto_Riferimento.trim()]
|
||||
|
||||
if (filtro.Rapporto_Testo_Fonte != null && filtro.Rapporto_Testo_Fonte != 'all')
|
||||
queryfi += " and UPPER(RSO)=UPPER('" + filtro.Rapporto_Testo_Fonte.trim() + "')"
|
||||
|
||||
if (filtro.Testo_Fonte != null && filtro.Testo_Fonte.trim() != '')
|
||||
queryfi += " and TF like '%" + filtro.Testo_Fonte.trim() + "%'"
|
||||
|
||||
if (filtro.Testo_Nota != null && filtro.Testo_Nota.trim() != '')
|
||||
queryfi += " and Ann like '%" + filtro.Testo_Nota.trim() + "%'"
|
||||
if (filtro.contesto != null) {
|
||||
var marray = JSON.parse(filtro.contesto);
|
||||
var infiltro=false
|
||||
var oplog=' and ('
|
||||
var tfi=filtroContesto(marray[0], 'Inferno', oplog)
|
||||
queryfi+=tfi
|
||||
if (tfi.trim()!='')
|
||||
infiltro=true
|
||||
oplog=' or '
|
||||
tfi=''
|
||||
tfi=filtroContesto(marray[1], 'Purgatorio', oplog)
|
||||
if (tfi!=''){
|
||||
infiltro=true
|
||||
queryfi += tfi
|
||||
oplog=' or '
|
||||
}
|
||||
tfi=''
|
||||
tfi=filtroContesto(marray[2], 'Paradiso', oplog)
|
||||
if (tfi!=''){
|
||||
infiltro=true
|
||||
queryfi += tfi
|
||||
}
|
||||
if (infiltro)
|
||||
queryfi +=")"
|
||||
}
|
||||
|
||||
var rs = await tconn.query(querytl + queryfi)
|
||||
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||
|
||||
await tconn.close();
|
||||
var resxcantica = Object.groupBy(result4, ({ Cantica }) => Cantica);
|
||||
|
||||
listaidversi = []
|
||||
var numcid = cid.split('_')[1]
|
||||
for (var cantica in resxcantica) {
|
||||
var $nctags = $(' .navig-canto')
|
||||
|
||||
console.log(resxcantica[cantica].length)
|
||||
var i = 1;
|
||||
if (cantica == 'Purgatorio')
|
||||
i = 2
|
||||
if (cantica == 'Paradiso')
|
||||
i = 3
|
||||
var spanbadgecantica = $('<span />');
|
||||
spanbadgecantica.attr('class', 'badge badge-warning badge-pill mx-2');
|
||||
spanbadgecantica.append(resxcantica[cantica].length)
|
||||
spanbadgecantica.appendTo($('#cantica' + i + '-badge'))
|
||||
|
||||
|
||||
var tmp = resxcantica[cantica]
|
||||
var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto);
|
||||
for (var canto in resxcanto) {
|
||||
var tmpv = resxcanto[canto]
|
||||
var spanbadge = $('<span />');
|
||||
spanbadge.attr('class', cantobadgeclassBis);
|
||||
spanbadge.append(resxcanto[canto].length)
|
||||
if (canto.startsWith('0')) {
|
||||
canto = canto.replace('0', '')
|
||||
}
|
||||
spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]'))
|
||||
for (const tmpvi of tmpv) {
|
||||
let myveid = '#' + cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0]
|
||||
//console.log(myveid)
|
||||
listaidversi.push(myveid)
|
||||
listaidcommenti.push(tmpvi.IdRiferimento)
|
||||
if (cid.includes(cantica) && numcid == canto)
|
||||
$(myveid).addClass("mark ")
|
||||
}
|
||||
|
||||
}
|
||||
drawMinimap(cid, true)
|
||||
|
||||
}
|
||||
/*console.log(resxcantica)*/
|
||||
return listaidversi
|
||||
|
||||
}
|
||||
|
||||
function opzioniRiferimenti() {
|
||||
$.each(rif_commentatori, function(i, p) {
|
||||
if (!!p && p.length > 2) {
|
||||
$('#CommentatorexR1Rx').append($('<option></option>')
|
||||
.val(p).html(p));
|
||||
};
|
||||
});
|
||||
$.each(rif_fonti, function(i, p) {
|
||||
if (!!p && p.length > 2) {
|
||||
$('#FontexR1Rx').append($('<option></option>')
|
||||
.val(p).html(p));
|
||||
};
|
||||
});
|
||||
$.each(rif_autori, function(i, p) {
|
||||
if (!!p && p.length > 2) {
|
||||
$('#Autore_FontexR1Rx').append($('<option></option>')
|
||||
.val(p).html(p));
|
||||
};
|
||||
});
|
||||
$.each(rif_areetematiche, function(i, p) {
|
||||
if (!!p && p.length > 2) {
|
||||
$('#Area_TematicaxR1Rx').append($('<option></option>')
|
||||
.val(p).html(p));
|
||||
};
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function filtroContesto(marray, cantica, op) {
|
||||
var filtrost = ''
|
||||
if (marray.every((val, i, arr) => val === 1)) {
|
||||
return op+ " Cantica='"+cantica+"'"
|
||||
}
|
||||
if (marray.some((val, i, arr) => val === 1)) {
|
||||
var tearr = marray.reduce(function(tearr, n, i) { if (n === 1) tearr.push(i); return tearr; }, []);
|
||||
for (const ic in tearr) {
|
||||
var canto = (tearr[ic]+1).toString()
|
||||
if ((tearr[ic]+1) < 10)
|
||||
canto = '0' + canto
|
||||
if (ic == 0)
|
||||
filtrost += op+" (Cantica='"+cantica+"' and (Canto='" + canto + "'"
|
||||
else
|
||||
filtrost += " or Canto='" + canto + "'"
|
||||
|
||||
}
|
||||
if (tearr.length)
|
||||
filtrost += "))"
|
||||
console.log(filtrost)
|
||||
}
|
||||
return filtrost
|
||||
}
|
||||
|
||||
//Contesto
|
||||
|
||||
export async function getFormaCntxt(formaid, numversi = 3) {
|
||||
const tconn = await db.connect();
|
||||
var querycnt = "select * from commedia where index>=((select index from commedia where Position='"+formaid+"')-25) order by index limit 50"
|
||||
console.log(" "+formaid)
|
||||
var rs = await tconn.query(querycnt)
|
||||
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||
|
||||
|
||||
console.log(result4)
|
||||
console.log('-----------------------------------------')
|
||||
|
||||
|
||||
await tconn.close();
|
||||
|
||||
}
|
|
@ -140,7 +140,7 @@ function showMinimap(onlyContent) {
|
|||
}
|
||||
|
||||
let viewerHeight = (miniCantoHeight*realScale*heightRatio/correctionFactor)-2; // -2 = bordi
|
||||
let viewerWidth = Math.min(viewerHeight/resizableRatio, maxWidth-3)+2; // -3 bordi
|
||||
let viewerWidth = Math.min(viewerHeight/resizableRatio, maxWidth-1)+2; // -3 bordi
|
||||
|
||||
var displayminimapHeight = (miniCantoHeight*realScale)+6;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
/*import {Runtime, Library, Inspector} from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/runtime.js";
|
||||
import commarc from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/index.js";*/
|
||||
import {Runtime, Library, Inspector} from "https://lida.dantenetwork.it/node_modules/commarcdiag/runtime.js";
|
||||
import commarc from "https://lida.dantenetwork.it/node_modules/commarcdiag/index.js";
|
||||
import {formaClass, lisid, lsentid, vistaPeriodi, listaPeriodiRisultato, listaClausoleRisultato, cantoDisplayed} from "./browseMgr_5.1.js"
|
||||
import { fillStructCard, emptyStructCard } from "./script_5.1.js";
|
||||
|
||||
const iframe = document.getElementsByClassName("minimap__content");
|
||||
const runtime1 = new Runtime(new Library(name => {
|
||||
console.log('name' +name)
|
||||
switch (name) {
|
||||
case "d3@^5.8": return d3;
|
||||
case "d3@^6.0": return d3;
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
document.addEventListener("dblclick", function(e){
|
||||
const target = e.target.closest("."+formaClass);
|
||||
|
||||
if(target){
|
||||
|
||||
|
||||
if(resetGraphStr())
|
||||
return
|
||||
|
||||
var hcontainer="#structCard0"
|
||||
|
||||
var main=runtime1.module(commarc, name => {
|
||||
|
||||
//if (name === "sentenceStructArcs_new") {
|
||||
if (name === "sentenceArcsStructs_new") {
|
||||
const structel = document.getElementsByClassName(lsentid);
|
||||
console.log(structel[0].parentNode.getAttribute('value'))
|
||||
var stid=lsentid.split('_')
|
||||
var structid=stid[0]+'_'+stid[1]+'_'+structel[0].parentNode.getAttribute('value')
|
||||
console.log(structid)
|
||||
fillStructCard(structid);
|
||||
return new Inspector(document.querySelector(hcontainer));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (lisid!=''){
|
||||
//var mywidth=document.getElementById('displaycanto').offsetWidth
|
||||
|
||||
console.log('here graph '+lisid+' '+lsentid)
|
||||
|
||||
|
||||
main.redefine('width', 625);
|
||||
main.redefine("lisid", lisid);
|
||||
const structel = document.getElementsByClassName(lsentid);
|
||||
|
||||
var stid=lsentid.split('_')
|
||||
var structid=stid[0]+'_'+stid[1]+'_'+structel[0].parentNode.getAttribute('value')
|
||||
|
||||
fillStructCard(structid)
|
||||
|
||||
var collection = document.getElementsByClassName(lsentid);
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
//collection[i].classList.add('font-weight-normal');
|
||||
collection[i].classList.add('font-italic');
|
||||
if (!vistaPeriodi){
|
||||
var synttp=collection[i].className.split(" ")[1]
|
||||
collection[i].style.color = colorssp(mapsynttypestopalette[synttp]);
|
||||
}
|
||||
|
||||
//collection[i].style.removeProperty('color');
|
||||
}
|
||||
$('#tab-list #vis1-tab').tab('show')
|
||||
updateMinimap(lsentid)
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
return
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*function resetMinimap(sentid){
|
||||
//var iframe = document.getElementsByClassName("minimap__content");
|
||||
|
||||
var iframeDocument = iframe[0].contentDocument || iframe[0].contentWindow.document;
|
||||
if (!iframeDocument) {
|
||||
throw "iframe couldn't be found in DOM.";
|
||||
}
|
||||
var iframeSentence = iframeDocument.getElementsByClassName(sentid);
|
||||
for (let i = 0; i < iframeSentence.length; i++) {
|
||||
iframeSentence[i].classList.remove('font-italic');
|
||||
if (!vistaPeriodi)
|
||||
iframeSentence[i].style.removeProperty('color');
|
||||
|
||||
iframeSentence[i].classList.remove('font-weight-normal');
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
function updateMinimap(sentid){
|
||||
//var iframe = document.getElementsByClassName("minimap__content");
|
||||
|
||||
var iframeDocument = iframe[0].contentDocument || iframe[0].contentWindow.document;
|
||||
if (!iframeDocument) {
|
||||
throw "iframe couldn't be found in DOM.";
|
||||
}
|
||||
var iframeSentence = iframeDocument.getElementsByClassName(sentid);
|
||||
for (let i = 0; i < iframeSentence.length; i++) {
|
||||
iframeSentence[i].classList.add('font-italic');
|
||||
|
||||
if (!vistaPeriodi){
|
||||
var synttp=iframeSentence[i].className.split(" ")[1]
|
||||
iframeSentence[i].style.color = colorssp(mapsynttypestopalette[synttp]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function resetGraphStr(){
|
||||
|
||||
var periodograph = document.getElementById("periodograph");
|
||||
if (periodograph != null) {
|
||||
let showngr = document.getElementById("periodograph").getAttribute('name').split("_")
|
||||
var tmpsent = showngr[0] + "_" + showngr[1] + "_s_" + showngr[2]
|
||||
periodograph.parentNode.removeChild(periodograph);
|
||||
|
||||
//var sentence = document.getElementsByClassName(lsentid);
|
||||
var sentence = document.getElementsByClassName(tmpsent);
|
||||
|
||||
for (let i = 0; i < sentence.length; i++) {
|
||||
//var matches = listaClausoleRisultato.filter(s => s.includes(sentence[i].classList[0]));
|
||||
sentence[i].classList.remove('font-italic');
|
||||
if (!vistaPeriodi && !listaPeriodiRisultato.includes(tmpsent)
|
||||
&& listaClausoleRisultato.filter(cl => cl.split('-')[0]==tmpsent).length==0)
|
||||
sentence[i].style.removeProperty('color');
|
||||
|
||||
sentence[i].classList.remove('font-weight-normal');
|
||||
|
||||
}
|
||||
|
||||
//reset Minimap
|
||||
var iframeDocument = myiframe[0].contentDocument || myiframe[0].contentWindow.document;
|
||||
if (!iframeDocument) {
|
||||
throw "iframe couldn't be found in DOM.";
|
||||
}
|
||||
var iframeSentence = iframeDocument.getElementsByClassName(tmpsent);
|
||||
for (let i = 0; i < iframeSentence.length; i++) {
|
||||
iframeSentence[i].classList.remove('font-italic');
|
||||
if (!vistaPeriodi)
|
||||
iframeSentence[i].style.removeProperty('color');
|
||||
|
||||
iframeSentence[i].classList.remove('font-weight-normal');
|
||||
}
|
||||
//EMPTY CARD
|
||||
emptyStructCard()
|
||||
|
||||
if (tmpsent == lsentid) {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue