filtri contesto, in progress

This commit is contained in:
cesare 2023-02-15 12:00:51 +01:00
parent 7f920b036b
commit f2addc279a
4 changed files with 76 additions and 50 deletions

View File

@ -29,17 +29,19 @@
font-size: 12px; font-size: 12px;
font-weight: normal; font-weight: normal;
font-style: italic; font-style: italic;
font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, font-family: "Bracciolini", "Spectral", -apple-system, BlinkMacSystemFont, Helvetica Neue,
Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell,
Fira Sans, Droid Sans, Fira Sans, Droid Sans, sans-serif;
sans-serif;
} }
#displaycanto span:hover { #displaycanto span:hover {
color: red; color: red;
} }
.canto { .canto {
-webkit-user-select: none;
user-select: none;
} }

View File

@ -345,6 +345,9 @@ $(" ."+formaClass).hover(function(idx, element) {
elencoVersi.appendTo(elencoRisutati); elencoVersi.appendTo(elencoRisutati);
} }
//add listeners
addFormListeners()
$("#vistaFrasi").attr('style', 'display: d-flex;'); $("#vistaFrasi").attr('style', 'display: d-flex;');
}); });
@ -429,6 +432,32 @@ $(" ."+formaClass).hover(function(idx, element) {
//Utility functions //Utility functions
function addFormListeners(){
$(" ." + formaClass).each(function(idx, element) {
var ele = $(element);
ele.tooltip({
content: (function() { return formatTTContent(ele.attr('title'), ele.attr('class').split(' ')[1]); }),
classes: { "ui-tooltip": 'Nik_dropdown-content' },
close: function(event, ui) { $(".ui-helper-hidden-accessible").remove(); },
create: function(ev, ui) { $(this).data("ui-tooltip").liveRegion.remove(); },
hide: false,
show: false
});
ele.hover(function(idx, element) {
sentenceId = $(this).attr('class').split(' ')[0].split('_')
var tmplisid = sentenceId[0] + '_' + sentenceId[1] + '_' + sentenceId[3]
lsentid = $(this).attr('class').split(' ')[0]
lisid = tmplisid
});
});
}
function getCantica(numeroCantica){ function getCantica(numeroCantica){
switch (numeroCantica){ switch (numeroCantica){
@ -747,7 +776,7 @@ $(" ."+formaClass).hover(function(idx, element) {
titolocanto.append(cantica + ", " + canto) titolocanto.append(cantica + ", " + canto)
divcanto.attr('class', 'canto') divcanto.attr('class', 'canto')
divcanto.css("display", "none") divcanto.css("display", "none")
//divcanto.attr('style', 'display:none')
divcanto.attr('id', (cantica + canto).replace(" ", "_")) divcanto.attr('id', (cantica + canto).replace(" ", "_"))
titolocanto.appendTo(divcanto) titolocanto.appendTo(divcanto)
divcanto.appendTo('#displaycanto') divcanto.appendTo('#displaycanto')

View File

@ -4,32 +4,7 @@
import {Runtime, Library, Inspector} from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/runtime.js"; 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 commarc from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/index.js";
//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";
//const synttypes=["princ", "subord I","subord II","subord III","coord", "coord I", "coord II","subord IV","subord V","parent",
// "coord III", "pcoord", "coord 0", "subord VI", "coord IV", "coord V", "pcoord I","subord VII"]
//var clausecolors=d3.scaleOrdinal(d3.schemeSet1).domain(synttypes)
/*const maptypes={"Ma": "princ", "SubI": "subord I", "SubII": "subord II", "SubIII": "subord III", "Co": "coord",
"CoI": "coord I", "CoII": "coord II", "SubIV": "subord IV", "SubV": "subord V", "ParentethicalClause": "parent",
"CoIII": "coord III", "ParentheticalCo":"pcoord", "PseudoCo": "oord 0", "SubVI": "subord VI" , "CoIV": "coord IV",
"CoV": "coord V", "ParentheticalCoI": "pcoord I", "SubVII": "subord VII"}
*/
//const structpalette=d3.quantize(d3.interpolateHcl("#4d4193", "#60c96e"), 18)
/*const maptypestopalette={"Ma": 0, "SubI": 1, "SubII": 3, "SubIII": 4, "Co": 5,
"CoI": 9, "CoII": 10, "SubIV": 5, "SubV": 6, "ParentethicalClause": 17,
"CoIII": 11, "ParentheticalCo":14, "PseudoCo": 16, "SubVI": 7 , "CoIV": 12,
"CoV": 13, "ParentheticalCoI": 15, "SubVII": 8}
var colorssp = d3.scaleQuantize()
.domain([0,17])
.range(["#3288bd", "#66c2a5", "#e41a1c", "#4daf4a", "#984ea3", "#d53e4f", "#f46d43", "#ABDDA4",
"#E6F598", "#FFFFBF", "#FEE08B", "#FDAE61", "#F46D43",
"#D53E4F", "#9E0142", "#e377c2", "#7f7f7f", "#bcbd22"]);
*/
const runtime1 = new Runtime(new Library(name => { const runtime1 = new Runtime(new Library(name => {
console.log('name' +name) console.log('name' +name)
switch (name) { switch (name) {
@ -38,8 +13,6 @@ const runtime1 = new Runtime(new Library(name => {
} }
})); }));
document.addEventListener("dblclick", function(e){ document.addEventListener("dblclick", function(e){
const target = e.target.closest("."+formaClass); const target = e.target.closest("."+formaClass);
@ -62,23 +35,28 @@ document.addEventListener("dblclick", function(e){
sentence[i].classList.remove('font-weight-normal'); sentence[i].classList.remove('font-weight-normal');
} }
getDimensionsDiv()
if (tmpsent==lsentid) if (tmpsent==lsentid){
getDimensionsDiv()
return return
}
} }
var main=runtime1.module(commarc, name => { var main=runtime1.module(commarc, name => {
if (name === "sentenceStructArcs") if (name === "sentenceStructArcs") {
return new Inspector(document.querySelector("#displayinfo")); return new Inspector(document.querySelector("#displayinfo"));
}
}); });
main.redefine('width', 648);
main.redefine('height', 500);
//main.redefine("links", d3.csv("https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/files/parsint_mod_completo_pre_new_4.csv", d3.autoType)); //main.redefine("links", d3.csv("https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/files/parsint_mod_completo_pre_new_4.csv", d3.autoType));
if (lisid!=''){ if (lisid!=''){
console.log('here graph '+lisid+' '+lsentid) console.log('here graph '+lisid+' '+lsentid)
main.redefine('width', 540);
main.redefine("lisid", lisid); main.redefine("lisid", lisid);
var collection = document.getElementsByClassName(lsentid); var collection = document.getElementsByClassName(lsentid);
for (let i = 0; i < collection.length; i++) { for (let i = 0; i < collection.length; i++) {
@ -99,6 +77,7 @@ document.addEventListener("dblclick", function(e){
//collection[i].style.removeProperty('color'); //collection[i].style.removeProperty('color');
} }
getDimensionsDiv()
} }
else else
return return

View File

@ -322,7 +322,7 @@ function getFormaContext(formaid) {
contextitem['cantica'] = cantica; contextitem['cantica'] = cantica;
contextitem['posizione'] = tmpform[2]; contextitem['posizione'] = tmpform[2];
contextitem['catg'] = tmpform[4]; contextitem['catg'] = tmpform[4];
contextitem['periodo'] = cantica + '_' + tmpform[1] + '_' + tmpform[5]; contextitem['periodo'] = cantica + '_' + tmpform[1] + '_s_' + tmpform[5];
contextitem['funzperiodo'] = tmpform[6]; contextitem['funzperiodo'] = tmpform[6];
context.push(contextitem); context.push(contextitem);
} }
@ -332,7 +332,7 @@ function getFormaContext(formaid) {
} }
//restituisce la query per ottenere tutti i versi di una cantica: NON USATA: RIMUOVERE //restituisce la query per ottenere tutti i versi di una cantica: NON USATA: RIMUOVERE
/*
function versiCantica(cantica) { function versiCantica(cantica) {
var SparqlParser = sparqljs.Parser; var SparqlParser = sparqljs.Parser;
var parser = new SparqlParser(); var parser = new SparqlParser();
@ -341,7 +341,7 @@ function versiCantica(cantica) {
return (parsedqVersiCantica) return (parsedqVersiCantica)
} }
*/
// the basic initial query is parsed RIMUOVERE // the basic initial query is parsed RIMUOVERE
function gimmespq() { function gimmespq() {
@ -496,8 +496,10 @@ function buildSQ(stquery) {
if (stquery['Clausola0']['opzioni_testo'] == 'prefisso') { if (stquery['Clausola0']['opzioni_testo'] == 'prefisso') {
strval = "^" + searchtext.trim(); strval = "^" + searchtext.trim();
} }
//COMPLETARE con regexp
var filtroContesto=getFiltroContesto(JSON.parse(stquery['Clausola0']['contesto']));
parsedquery.where[0].expression.args[1].value = strval; parsedquery.where[0].expression.args[1].value = strval;
if (stquery['Clausola0']['lemma_forma'] == 'lemma') if (stquery['Clausola0']['lemma_forma'] == 'lemma')
parsedquery.where[0].expression.args[0].value = "lm"; parsedquery.where[0].expression.args[0].value = "lm";
@ -510,6 +512,22 @@ function buildSQ(stquery) {
return (parsedquery) return (parsedquery)
}
//Filtro Contesto
function getFiltroContesto(datiContesto){
var cantica=0;
for (contestoCantica of datiContesto){
cantica++;
for (const [index, element] of contestoCantica.entries()) {
if(element==1)
console.log('Cantica '+cantica+', Canto '+(parseInt(index)+1));
}
}
} }
function buildStatementClause(clause, parsedquery, whereind, theplace) { function buildStatementClause(clause, parsedquery, whereind, theplace) {
@ -629,8 +647,6 @@ function buildClause(clause, parsedquery, whereind) {
if (clause['typeGramm0'] != null && clause['typeGramm0'] != "all") if (clause['typeGramm0'] != null && clause['typeGramm0'] != "all")
if (whereind > -1) if (whereind > -1)
//parsedquery.where[whereind].triples.push(JSON.parse(data21)[clause['typeGramm0']]); //parsedquery.where[whereind].triples.push(JSON.parse(data21)[clause['typeGramm0']]);
@ -1188,13 +1204,13 @@ var syntgroup = ` {
var funzione_clausola = var funzione_clausola =
{ {
"princ": "hasClauseFunction:MainClause", "princ": "hasClauseFunction:MainClause",
"subord i": "hasClauseFunction:SubordinateClause", "subord i": "hasClauseFunction:SubordinateClauseI",
"subord ii": "", "subord ii": "hasClauseFunction:SubordinateClauseII",
"subord iii": "", "subord iii": "hasClauseFunction:SubordinateClauseIII",
"subord iv": "", "subord iv": "hasClauseFunction:SubordinateClauseIV",
"subord v": "", "subord v": "hasClauseFunction:SubordinateClauseV",
"subord vi": "", "subord vi": "hasClauseFunction:SubordinateClauseVI",
"subord vii": "", "subord vii": "hasClauseFunction:SubordinateClauseVII",
"coord i": "hasClauseFunction:CoordinateClause", "coord i": "hasClauseFunction:CoordinateClause",
"coord ii": "", "coord ii": "",
"coord iii": "", "coord iii": "",