1504 lines
67 KiB
JavaScript
1504 lines
67 KiB
JavaScript
import define1 from "./a33468b95d0b15b0@808.js";
|
|
|
|
function _1(md){return(
|
|
md`# Commedia: Arc Diagram per marcatura sintattica
|
|
Visualizzazione delle annotazione sintattiche della Commedia come grafi.`
|
|
)}
|
|
|
|
function _d3(require){return(
|
|
require("d3@^6.0")
|
|
)}
|
|
|
|
function _3(md){return(
|
|
md`### Import Data`
|
|
)}
|
|
|
|
function _links2(FileAttachment){return(
|
|
FileAttachment("parsint_mod_completo_pergrafi_5 (7).csv").csv({typed: true})
|
|
)}
|
|
|
|
function _6(md){return(
|
|
md`### Create Dataset`
|
|
)}
|
|
|
|
function _types(links2){return(
|
|
Array.from(new Set(links2.map(d => d.type)))
|
|
)}
|
|
|
|
function _getFrasi(links2){return(
|
|
function getFrasi(nfrase){
|
|
const mnode= []
|
|
const mlinks=[]
|
|
const usednodes=[]
|
|
//const ns=Array.from(new Set(links.flatMap(l => [l.source, l.target])), id => ({id}))
|
|
links2.map(function(item) {
|
|
var mysrc=item.source
|
|
var mytgt=item.target
|
|
var frase=item.frase
|
|
var myval='';
|
|
if (!usednodes.includes(mysrc.replace(/\s/g, '')) && nfrase.includes(frase)){
|
|
console.log ('In sources, id : '+mysrc.replace(/\s/g, '')+' target: '+mytgt)
|
|
var myvis=item.visibile.trim();
|
|
//if(myvis.indexOf('_v')==-1)
|
|
// myvis=mysrc
|
|
mnode.push({
|
|
"id" : mysrc,
|
|
"type" : item.type,
|
|
"rif" : item.frase,
|
|
//"visible": item.visibile.trim(),
|
|
"visible": myvis,
|
|
"s_type" : item.tipo
|
|
});
|
|
usednodes.push(mysrc.replace(/\s/g, '').replaceAll("-",''))
|
|
}
|
|
if (!usednodes.includes(mytgt.replace(/\s/g, '')) && nfrase.includes(frase)){
|
|
console.log ('In target, id : '+mysrc+' target: '+mytgt.replace(/\s/g, ''))
|
|
mnode.push({
|
|
"id" : mytgt,
|
|
"type" : item.type,
|
|
"rif" : item.frase,
|
|
"visible": item.visibile.trim(),
|
|
"s_type" : item.tipo
|
|
});
|
|
usednodes.push(mytgt.replace(/\s/g, ''))
|
|
|
|
}
|
|
|
|
})
|
|
links2.map(function(item) {
|
|
var mysrc=item.source
|
|
var mytgt=item.target
|
|
var frase=item.frase
|
|
if (nfrase.includes(frase)){
|
|
mlinks.push({
|
|
"source" : mysrc,
|
|
"target" : mytgt,
|
|
"type" : item.type
|
|
});
|
|
}
|
|
})
|
|
|
|
var data_frase=({nodes: mnode, links: mlinks})
|
|
return data_frase;
|
|
}
|
|
)}
|
|
|
|
function _getSid(){return(
|
|
function getSid(ids){
|
|
ids= ids.replace(/\s/g,'')
|
|
var setids= ids.split(",")
|
|
return setids
|
|
}
|
|
)}
|
|
|
|
function _listafrasi(getSid,lisid){return(
|
|
getSid(lisid)
|
|
)}
|
|
|
|
function _getColor(sentenceFunctionsColor2){return(
|
|
function getColor(st){
|
|
return sentenceFunctionsColor2(st)
|
|
}
|
|
)}
|
|
|
|
function _clauseType(){return(
|
|
'subord I'
|
|
)}
|
|
|
|
function _col(getColor,clauseType){return(
|
|
getColor(clauseType)
|
|
)}
|
|
|
|
function _data_frasi(getFrasi,listafrasi){return(
|
|
getFrasi(listafrasi)
|
|
)}
|
|
|
|
function _sentenceTypes(data_frasi){return(
|
|
data_frasi.nodes.slice(1).map(function(d){return d.s_type})
|
|
)}
|
|
|
|
function _sentenceNodeNames(data_frasi){return(
|
|
data_frasi.nodes.slice(1).map(function(d){return d.visible})
|
|
)}
|
|
|
|
function _idToNode(data_frasi)
|
|
{
|
|
let dict = {};
|
|
data_frasi.nodes.slice(0).forEach(function(n) {
|
|
dict[n.id] = n;
|
|
});
|
|
return dict;
|
|
}
|
|
|
|
|
|
function _idToTargetNodes(data_frasi)
|
|
{
|
|
let dict = {};
|
|
data_frasi.nodes.slice(1).forEach(function (n) {
|
|
dict[n.id] = [];
|
|
data_frasi.links.slice(1).forEach(function (l) {
|
|
if (l.source === n.id) {
|
|
dict[n.id].push(l.target);
|
|
}
|
|
});
|
|
});
|
|
return dict;
|
|
}
|
|
|
|
|
|
function _syntactic_macrotypes(){return(
|
|
{
|
|
"avv": "Avversativa",
|
|
"caus": "Causale",
|
|
"compar": "Comparativa",
|
|
"conces": "Concessiva",
|
|
"consec": "Consecutiva",
|
|
"dich": "Dichiarativa",
|
|
"eccettu": "Eccettuativa",
|
|
"epesege": "Epesegetica",
|
|
"escl": "Esclamativa",
|
|
"esclu": "Esclusiva",
|
|
"finale": "Finale",
|
|
"inter": "Interrogativa",
|
|
"ipotet": "Ipotetica",
|
|
"iussi": "Iussiva",
|
|
"limitat": "Limitativa",
|
|
"maniera": "Di Maniera",
|
|
"modale": "Modale",
|
|
"obliqua": "Obliqua",
|
|
"oggettiva": "Oggettiva",
|
|
"otta": "Ottativa",
|
|
"pare mod": "ParenteticaModalizzante",
|
|
"pare sub": "ParenteticaCon ValoreDiSubordinata",
|
|
"pred": "Predicativa",
|
|
"pseudo": "Pseudocoordinata",
|
|
"rel": "Relativa",
|
|
"sog": "Soggettiva",
|
|
"strum": "Strumentale",
|
|
"sub": "SubordinataConFunzioneDiRipresa",
|
|
"temp": "Temporale",
|
|
}
|
|
)}
|
|
|
|
function _syntactic_types(){return(
|
|
{"avv caus": "Coordinata Avversativa Causale",
|
|
"avv comp ug": "Coordinata Avversativa Comparativa Di Uguaglianza",
|
|
"avv cons antec": "Coordinata Avversativa ConsecutivaCon Antecedente",
|
|
"avv dich": "Coordinata Avversativa Dichiarativa",
|
|
"avv fin": "Coordinata AvversativaFinale",
|
|
"avv int x": "Coordinata Avversativa Interrogativa Di TipoX",
|
|
"avv int x ret": "Coordinata Avversativa Interrogativa Di TipoX Retorica",
|
|
"avv ipo caus": "Coordinata Avversativa Ipotetica Con Valore Causale",
|
|
"avv iuss dir": "Coordinata AvversativaIussivaDiretta",
|
|
"avv iuss indir": "Coordinata AvversativaIussivaIndiretta",
|
|
"avv modaliz ott intr": "Coordinata Avversativa Modalizzante Ottativa Con Introduttore",
|
|
"avv ogg": "Coordinata Avversativa Oggettiva",
|
|
"avv ogg perc": "Coordinata Avversativa Oggettiva",
|
|
"avv rel app": "Coordinata Avversativa Relativa Appositiva",
|
|
"avv rel app comp ug": "Coordinata Avversativa Relativa Appositiva In Construtto Comparativo",
|
|
"avv rel app cons antec": "Coordinata Avversativa Relativa Appositiva Con Valore Consecutivo",
|
|
"avv rel giust": "Coordinata Avversativa Relativa Giustapposta",
|
|
"avv rel ind": "Coordinata Avversativa Relativa Indipendente",
|
|
"avv rel ind temp": "Coordinata Avversativa Relativa Indipendente Temporale",
|
|
"avv rel restr": "Coordinata Avversativa Relativa Restrittiva",
|
|
"avv rel restr comp ug": "Coordinata Avversativa Relativa Restrittiva In Costrutto Comparativo",
|
|
"avv sogg": "Coordinata Avversativa Soggettiva",
|
|
"avv temp": "Coordinata Avversativa Temporale",
|
|
"comp disug": "Comparativa Di Disuguaglianza",
|
|
"comp disug ipo": "Comparativa Di Disuguaglianza Con Valore Ipotetico",
|
|
"comp fin": "Comparativa Con Valore Finale",
|
|
"comp ipo": "Comparativa Con Valore Ipotetico",
|
|
"comp lim": "Comparativa Con Valore Limitativo",
|
|
"comp mod": "Comparativa Con Valore Modale",
|
|
"comp temp": "Comparativa Con Valore Temporale",
|
|
"comp ug": "Comparativa Di Uguaglianza",
|
|
"comp ug rel ind temp": "Comparativa Di Uguaglianza Con Valore Di Relativa Indipendente Temporale",
|
|
"conc acond": "Concessiva Acondizionale",
|
|
"conc cond": "Concessiva Condizionale",
|
|
"conc fatt": "Concessiva Fattuale",
|
|
"cong asind comp ug": "Coordinata Asindetica Comparativa Di Uguaglianza",
|
|
"cong asind cons antec": "Coordinata Asindetica Consecutiva Con Antecedente",
|
|
"cong asind dich": "Coordinata Asindetica Dichiarativa",
|
|
"cong asind epes": "Coordinata Asindetica Epesegetica",
|
|
"cong asind esclam": "Coordinata Asindetica Esclamativa",
|
|
"cong asind fin": "Coordinata Asindetica Finale",
|
|
"cong asind int altern": "Coordinata Asindetica Interrogativa Alternativa",
|
|
"cong asind int altern ret": "Coordinata Asindetica Interrogativa Alternativa Retorica",
|
|
"cong asind int disg": "Coordinata Asindetica Interrogativa Disgiuntiva",
|
|
"cong asind int x": "Coordinata Asindetica Interrogativa Di TipoX",
|
|
"cong asind int x ret": "Coordinata Asindetica Interrogativa Di TipoX Retorica",
|
|
"cong asind ipo": "Coordinata Asindetica Ipotetica",
|
|
"cong asind iuss dir": "Coordinata Asindetica IussivaDiretta",
|
|
"cong asind iuss indir": "Coordinata Asindetica IussivaIndiretta",
|
|
"cong asind man": "Coordinata Asindetica Di Maniera",
|
|
"cong asind ogg": "Coordinata Asindetica Oggettiva",
|
|
"cong asind ogg perc": "Coordinata Asindetica Oggettiva",
|
|
"cong asind ott intr": "Coordinata Asindetica Ottativa Con Introduttore",
|
|
"cong asind ott libera": "Coordinata Asindetica OttativaLibera",
|
|
"cong asind rel app": "Coordinata Asindetica Relativa Appositiva",
|
|
"cong asind rel app comp disug": "Coordinata Asindetica Relativa Appositiva In Construtto Comparativo",
|
|
"cong asind rel app giust": "Coordinata Asindetica Relativa Giustapposta",
|
|
"cong asind rel ind": "Coordinata Asindetica Relativa Indipendente",
|
|
"cong asind rel ind temp caus": "Coordinata Asindetica Relativa IndipendenteCon Valore Temporale Causale",
|
|
"cong asind rel restr": "Coordinata Asindetica Relativa Restrittiva",
|
|
"cong asind rel restr comp ug": "Coordinata Asindetica Relativa Restrittiva In Construtto Comparativo",
|
|
"cong asind sogg soll": "Coordinata Asindetica SoggettivaASollevamento",
|
|
"cong asind subord": "Coordinata Asindetica Subordinata",
|
|
"cong asind temp": "Coordinata Asindetica Temporale",
|
|
"cong caus": "Coordinata Congiuntiva Causale",
|
|
"cong comp disug": "Coordinata Congiuntiva Comparativa Di Disuguaglianza",
|
|
"cong comp ipo": "Coordinata Congiuntiva Comparativa Con Valore Ipotetico",
|
|
"cong comp lim": "Coordinata Congiuntiva Comparativa Con Valore Limitativo",
|
|
"cong comp mod": "Coordinata Congiuntiva Comparativa Con Valore Modale",
|
|
"cong comp ug": "Coordinata Congiuntiva Comparativa Di Uguaglianza",
|
|
"cong conc cond": "Coordinata Congiuntiva Concessiva Condizionale",
|
|
"cong conc fatt": "Coordinata Congiuntiva Concessiva Fattuale",
|
|
"cong concl cons antec": "Coordinata Conclusiva Consecutiva Con Antecedente",
|
|
"cong concl dich": "Coordinata Conclusiva Dichiarativa",
|
|
"cong concl dich ill": "Coordinata Conclusiva Dichiarativa Illocutiva",
|
|
"cong concl iuss dir": "Coordinata Conclusiva Iussiva Diretta",
|
|
"cong concl iuss dir perifr": "Coordinata Conclusiva Iussiva Diretta Perifrastica",
|
|
"cong concl iuss indir": "Coordinata Conclusiva Iussiva Indiretta",
|
|
"cong cons antec": "Coordinata Congiuntiva Consecutiva Con Antecedente",
|
|
"cong cons antec epes": "Coordinata Congiuntiva Consecutiva Con Antecedente Episegetica",
|
|
"cong cons antec fin": "Coordinata Congiuntiva Consecutiva Con Antecedente Con Valore Finale",
|
|
"cong cons caus": "Coordinata Consecutiva Causale",
|
|
"cong cons dich": "Coordinata Consecutiva Dichiarativa",
|
|
"cong cons ell": "Coordinata Congiuntiva Consecutiva Ellittica",
|
|
"cong cons libera": "Coordinata Congiuntiva Consecutiva Libera",
|
|
"cong cons libera fin": "Coordinata Congiuntiva Consecutiva Libera Con Valore Finale",
|
|
"cong cons post": "Coordinata Congiuntiva Consecutiva Posposta",
|
|
"cong corr dich": "CoordinataCorRelativa Dichiarativa",
|
|
"cong corr fin": "CoordinataCorRelativa Finale",
|
|
"cong corr lim": "CoordinataCorRelativa Limitativa",
|
|
"cong corr sogg infinitoprep": "CoordinataCorRelativa Soggettiva A Infinito Preposizionale",
|
|
"cong dich": "Coordinata Congiuntiva Dichiarativa",
|
|
"cong dich ill": "Coordinata Congiuntiva Dichiarativa Illocutiva",
|
|
"cong eccett": "Coordinata Congiuntiva Eccettuativa",
|
|
"cong epes": "Coordinata Congiuntiva Epesegetica",
|
|
"cong esclam": "Coordinata Congiuntiva Esclamativa",
|
|
"cong esclus": "Coordinata Congiuntiva Esclusiva",
|
|
"cong espl dich": "CoordinataEsplicativa Dichiarativa",
|
|
"cong espl obl": "Coordinata Esplicativa Obliqua",
|
|
"cong espl ogg": "Coordinata Esplicativa Oggettiva",
|
|
"cong espl rel app antec": "Coordinata Esplicativa Relativa Appositiva Con Antecedente",
|
|
"cong espl rel ind mod": "Coordinata Esplicativa Relativa Indipendente Con Valore Modale",
|
|
"cong fin": "Coordinata Congiuntiva Finale",
|
|
"cong int altern": "Coordinata Congiuntiva Interrogativa Alternativa",
|
|
"cong int x": "Coordinata Congiuntiva InterrogativaDi TipoX",
|
|
"cong int x ret": "Coordinata Congiuntiva InterrogativaDi TipoX Retorica",
|
|
"cong ipo": "Coordinata Congiuntiva Ipotetica",
|
|
"cong ipo caus": "Coordinata Congiuntiva IpoteticaCon Valore Causale",
|
|
"cong ipo sogg": "Coordinata Congiuntiva Ipotetica Soggettiva",
|
|
"cong iuss dir": "Coordinata Congiuntiva Iussiva Diretta",
|
|
"cong iuss indir": "Coordinata Congiuntiva Iussiva Indiretta",
|
|
"cong lim": "Coordinata Congiuntiva Limitativa",
|
|
"cong man": "Coordinata Congiuntiva Di Maniera",
|
|
"cong modaliz ott intr": "Coordinata Congiuntiva Modalizzante Ottativa Con Introduttore",
|
|
"cong obl": "Coordinata Congiuntiva Obliqua",
|
|
"cong ogg": "Coordinata Congiuntiva Oggettiva",
|
|
"cong ogg perc": "Coordinata Congiuntiva Oggettiva",
|
|
"cong ott libera": "Coordinata Congiuntiva Ottativa Libera",
|
|
"cong rel app": "Coordinata Congiuntiva Relativa Appositiva",
|
|
"cong rel app comp disug": "Coordinata Congiuntiva Relativa Appositiva In Costrutto Comparativo Di Disuguaglianza",
|
|
"cong rel app comp ug": "Coordinata Congiuntiva Relativa Appositiva In Costrutto Comparativo Di Uguaglianza",
|
|
"cong rel app cons": "Coordinata Congiuntiva Relativa Appositiva Con Valore Consecutivo",
|
|
"cong rel app epes": "Coordinata Congiuntiva Relativa Appositiva Con Valore Di Episegetica",
|
|
"cong rel app fin": "Coordinata Congiuntiva Relativa Appositiva Con Valore Finale",
|
|
"cong rel app giust": "Coordinata Congiuntiva Relativa Giustapposta",
|
|
"cong rel app giust caus": "Coordinata Congiuntiva Relativa Giustapposta Con Valore Causale",
|
|
"cong rel app temp": "Coordinata Congiuntiva Relativa Appositiva Con Valore Temporale",
|
|
"cong rel impl": "Coordinata Congiuntiva Relativa Implicita",
|
|
"cong rel impl lim": "Coordinata Congiuntiva Relativa ImplicitaCon Valore Limitativo",
|
|
"cong rel ind": "Coordinata Congiuntiva Relativa Indipendente",
|
|
"cong rel ind acond": "Coordinata Congiuntiva Relativa Indipendente Acondizionale",
|
|
"cong rel ind ipo": "Coordinata Congiuntiva Relativa IndipendenteCon Valore Ipotetico",
|
|
"cong rel ind mod": "Coordinata Congiuntiva Relativa IndipendenteCon Valore Modale",
|
|
"cong rel ind mod comp ug": "Coordinata Congiuntiva Relativa Indipendente In Costrutto ComparativoModale",
|
|
"cong rel ind temp": "Coordinata Congiuntiva Relativa Indipendente Temporale",
|
|
"cong rel pseudo": "Coordinata Congiuntiva Pseudo Relativa ",
|
|
"cong rel restr": "Coordinata Congiuntiva Relativa Restrittiva",
|
|
"cong rel restr caus": "Coordinata Congiuntiva Relativa RestrittivaCon Valore Causale",
|
|
"cong rel restr comp": "Coordinata Congiuntiva Relativa RestrittivaIn Costrutto Comparativo",
|
|
"cong rel restr comp ug": "Coordinata Congiuntiva Relativa RestrittivaIn Costrutto Comparativo Di Uguaglianza",
|
|
"cong rel restr cons": "Coordinata Congiuntiva Relativa RestrittivaCon Valore Consecutivo",
|
|
"cong rel restr temp": "Coordinata Congiuntiva Relativa RestrittivaTemporale",
|
|
"cong rip": "Coordinata CongiuntivaConFunzioneDiRipresa",
|
|
"cong sogg": "Coordinata Congiuntiva Soggettiva",
|
|
"cong spec": "Coordinata Congiuntiva Specificativa",
|
|
"cong strum": "Coordinata Congiuntiva Strumentale",
|
|
"cong subord": "Coordinata Congiuntiva Subordinata",
|
|
"cong temp": "Coordinata Congiuntiva Temporale",
|
|
"cong temp caus": "Coordinata Congiuntiva TemporaleCon Valore Causale",
|
|
"cons antec": "Consecutiva Con Antecedente",
|
|
"cons antec epes": "Consecutiva Con Antecedente Epesegetica",
|
|
"cons antec fin": "Consecutiva Con Antecedente Con Valore Finale",
|
|
"cons antec temp": "Consecutiva Con Antecedente Con ValoreTemporale",
|
|
"cons ell": "Consecutiva Ellittica",
|
|
"cons libera": "Consecutiva Libera",
|
|
"cons libera fin": "Consecutiva Libera Con Valore Finale",
|
|
"cons post": "Consecutiva Posposta",
|
|
"dich": "Dichiarativa",
|
|
"dich ill": "Dichiarativa Illocutiva",
|
|
"disg comp disug temp": "Coordinata Disgiuntiva Comparativa Di Disuguaglianza Con Valore Temporale",
|
|
"disg conc acond": "Coordinata Disgiuntiva Concessiva Acondizionale",
|
|
"disg conc cond": "Coordinata Disgiuntiva Concessiva Condizionale",
|
|
"disg cons libera": "Coordinata Disgiuntiva Consecutiva Libera",
|
|
"disg corr dich": "Coordinata Disgiuntiva CorRelativa Dichiarativa",
|
|
"disg dich": "Coordinata Disgiuntiva Dichiarativa",
|
|
"disg epes": "Coordinata Disgiuntiva Epesegetica",
|
|
"disg esclus": "Coordinata Disgiuntiva Esclusiva",
|
|
"disg int altern": "Coordinata Disgiuntiva Interrogativa Alternativa",
|
|
"disg int disg": "Coordinata Disgiuntiva Interrogativa Disgiuntiva",
|
|
"disg int x": "Coordinata Disgiuntiva Interrogativa Di TipoX",
|
|
"disg ipo": "Coordinata Disgiuntiva Ipotetica",
|
|
"disg lim": "Coordinata Disgiuntiva Limitativa",
|
|
"disg man": "Coordinata Disgiuntiva Di Maniera",
|
|
"disg obl": "Coordinata Disgiuntiva Obliqua",
|
|
"disg ogg": "Coordinata Disgiuntiva Oggettiva",
|
|
"disg rel ind": "Coordinata Disgiuntiva Relativa Indipendente",
|
|
"disg rel ind acond": "Coordinata Disgiuntiva Relativa Indipendente Acondizionale",
|
|
"disg rel ind temp": "Coordinata Disgiuntiva Relativa Indipendente Temporale",
|
|
"disg rel restr": "Coordinata Disgiuntiva Restrittiva",
|
|
"disg rel restr cons": "Coordinata Disgiuntiva Restrittiva Con Valore Consecutivo",
|
|
"disg sogg": "Coordinata Disgiuntiva Soggettiva",
|
|
"disg temp": "Coordinata Disgiuntiva Temporale",
|
|
"eccett": "Eccettuativa",
|
|
"eccett comp ug": "EccettuativaCon Valore Di Comparativa Di Uguaglianza",
|
|
"epes": "Epesegetica",
|
|
"esclam": "Esclamativa",
|
|
"esclus": "Esclusiva",
|
|
"faltern": "FalsaAlternativa",
|
|
"fcong": "FalsaCongiuntiva",
|
|
"fin": "Finale",
|
|
"fin ipo": "FinaleCon Valore Ipotetico",
|
|
"fin rel giust": "Concorrenza Del Relativo In Frase Finale",
|
|
"int altern": "Interrogativa Alternativa",
|
|
"int altern ret": "Interrogativa Alternativa Retorica",
|
|
"int disg": "Interrogativa Disgiuntiva",
|
|
"int disg ret": "Interrogativa Disgiuntiva Retorica",
|
|
"int x": "Interrogativa Di TipoX",
|
|
"int x ret": "Interrogativa Di TipoX Retorica",
|
|
"ipo": "Ipotetica",
|
|
"ipo biaff": "Ipotetica Biaffermativa",
|
|
"ipo caus": "Ipotetica Con Valore Causale",
|
|
"ipo eccett": "Ipotetica Con Valore Eccettuativo",
|
|
"ipo obl": "Ipotetica Obliqua",
|
|
"ipo rel giust": "Ipotetica Relativa Giustapposta",
|
|
"ipo sogg": "Ipotetica Soggettiva",
|
|
"iuss aug": "Iussiva Augurativa",
|
|
"iuss dir": "Iussiva Diretta",
|
|
"iuss dir perifr": "Iussiva Diretta Perifrastica",
|
|
"iuss indir": "Iussiva Indiretta",
|
|
"lim": "Limitativa",
|
|
"lim caus": "Limitativa Con Valore Causale",
|
|
"lim caus eccett": "Limitativa Con Valore Causale Eccettuativo",
|
|
"lim eccett": "Limitativa Con Valore Eccettuativo",
|
|
"man": "Di Maniera",
|
|
"man gerundioprep": "Di Maniera A Gerundio Preposizionale",
|
|
"man rel giust": "Concorrenza Del Relativo In Frase Di Maniera",
|
|
"mod": "Modale",
|
|
"modaliz": "Modalizzante",
|
|
"modaliz ott intr": "Modalizzante Ottativa Con Introduttore",
|
|
"modalizz ott libera": "Modalizzante OttativaLibera",
|
|
"obl": "Obliqua",
|
|
"ogg": "Oggettiva",
|
|
"ogg aci": "Oggettiva",
|
|
"ogg perc": "Oggettiva",
|
|
"ott intr": "Ottativa Con Introduttore",
|
|
"ott libera": "OttativaLibera",
|
|
"pred": "Predicativa",
|
|
"rel app antec": "Relativa Appositiva Con Antecedente",
|
|
"rel app antec caus": "Relativa Appositiva Con Antecedente Con Valore Causale",
|
|
"rel app antec comp disug": "Relativa Appositiva Con AntecedenteIn Costrutto Comparativo Di Disuguaglianza",
|
|
"rel app antec comp ug": "Relativa Appositiva Con Antecedente In Costrutto Comparativo Di Uguaglianza",
|
|
"rel app antec comp ug": "Relativa Con Antecedente In Costrutto Comparativo Di Uguaglianza",
|
|
"rel app antec cons": "Relativa Appositiva Con Antecedente Con Valore Consecutivo",
|
|
"rel app antec eccett": "Relativa Appositiva Con Antecedente In Costrutto Eccettuativo",
|
|
"rel app antec fin": "Relativa Appositiva Con Antecedente Con Valore Finale",
|
|
"rel app antec fin cons": "Relativa Appositiva Con Antecedente Con Valore Consecutivo Finale",
|
|
"rel app antec giust": "Relativa Appositiva Con Antecedente Giustapposta",
|
|
"rel app antec giust cons": "Relativa Appositiva Giustapposta Con Valore Consecutivo",
|
|
"rel app antec giust ipo": "Relativa Appositiva Giustapposta Con Valore Ipotetico",
|
|
"rel app antec giust man": "Relativa Appositiva Giustapposta Con Valore Di Maniera",
|
|
"rel app antec strum": "Relativa Appositiva Con Antecedente Con Valore Strumentale",
|
|
"rel giust": "Relativa Giustapposta",
|
|
"rel impl": "Relativa Implicita",
|
|
"rel impl cons": "Relativa Implicita Con Valore Consecutivo",
|
|
"rel impl deon": "Relativa Implicita Deontica",
|
|
"rel impl fin": "Relativa Implicita Con Valore Finale",
|
|
"rel impl lim": "Relativa Implicita Con Valore Limitativo",
|
|
"rel ind": "Relativa Indipendente",
|
|
"rel ind acond": "Relativa Indipendente Acondizionale",
|
|
"rel ind caus": "Relativa Indipendente In Costrutto Causale",
|
|
"rel ind comp": "Relativa Indipendente In Costrutto Comparativo",
|
|
"rel ind ipo": "Relativa Indipendente Con Valore Ipotetico",
|
|
"rel ind mod": "Relativa Indipendente Con Valor eModale",
|
|
"rel ind mod comp ug": "Relativa Indipendente In Costrutto Comparativo Modale",
|
|
"rel ind temp": "Relativa Indipendente Con Valore Temporale",
|
|
"rel ind temp acond": "Relativa Indipendente Con Valore Temporale Acondizionale",
|
|
"rel ind temp caus": "Relativa Indipendente Con Valore Temporale Causale",
|
|
"rel ind temp comp ug": "Relativa Indipendente In Costrutto Comparativo Di Uguaglianza",
|
|
"rel pseudo": "Pseudo Relativa",
|
|
"rel pseudo fin": "Pseudo Relativa Con Valore Finale",
|
|
"rel pseudo scissa": "Pseudo Relativa Scissa",
|
|
"rel pseudo scissa temp": "Pseudo Relativa ScissaC on ValoreTemporale",
|
|
"rel restr antec": "Relativa Restrittiva Con Antecedente",
|
|
"rel restr antec caus": "Relativa Restrittiva Con Antecedente Con Valore Causale",
|
|
"rel restr antec comp disug": "Relativa Restrittiva Con Antecedente In Costrutto Comparativo Di Disuguaglianza",
|
|
"rel restr antec comp mod": "Relativa Restrittiva Con Antecedente In Costrutto Comparativo Modale",
|
|
"rel restr antec comp ug": "Relativa Restrittiva Con Antecedente In Costrutto Comparativo Di Uguaglianza",
|
|
"rel restr antec conc cond": "Relativa Restrittiva Con Antecedente Con Valore Di Concessiva Condizionale",
|
|
"rel restr antec conc fatt": "Relativa Restrittiva Con Antecedente Con Valore Di Concessiva Fattuale",
|
|
"rel restr antec cons": "Relativa Restrittiva Con Antecedente Con Valore Consecutivo",
|
|
"rel restr antec eccett": "Relativa Restrittiva Con Antecedente In Costrutto Eccettuativo",
|
|
"rel restr antec fin": "Relativa Restrittiva Con Antecedente Con Valore Finale",
|
|
"rel restr antec ipo": "Relativa Restrittiva Con Antecedente Con Valore Ipotetico",
|
|
"rel restr antec lim": "Relativa Restrittiva Con Antecedente In Costrutto Limitativo",
|
|
"rel restr antec temp": "Relativa Restrittiva Con Antecedente Con Valore Temporale",
|
|
"rip": "Funzione Di Ripresa",
|
|
"sogg": "Soggettiva",
|
|
"sogg aci": "Soggettiva",
|
|
"sogg id": "Soggettiva",
|
|
"sogg infinitoprep": "Soggettiva",
|
|
"sogg scissa": "Soggettiva Scissa",
|
|
"sogg soll": "Soggettiva A Sollevamento",
|
|
"spec": "Specificativa",
|
|
"spec aci": "Specificativa",
|
|
"spec infinitoprep": "Specificativa",
|
|
"strum": "Strumentale",
|
|
"subord": "Subordinata",
|
|
"temp": "Temporale",
|
|
"temp comp ug": "TemporaleCon Valore Comparativo",
|
|
"temp ipo": "TemporaleCon Valore Ipotetico",
|
|
}
|
|
)}
|
|
|
|
function _getTypes(syntactic_macrotypes,syntactic_types){return(
|
|
function name(mtype) {
|
|
if(syntactic_macrotypes[mtype])
|
|
return syntactic_macrotypes[mtype]
|
|
if(syntactic_types[mtype])
|
|
return syntactic_types[mtype]
|
|
return mtype
|
|
}
|
|
)}
|
|
|
|
function _clauseFunctions(){return(
|
|
{
|
|
"princ": "Principale",
|
|
"coord": "Coordinata",
|
|
"coord I": "Coordinata I grado",
|
|
"coord II": "Coordinata II grado",
|
|
"coord III": "Coordinata III grado",
|
|
"coord IV": "Coordinata IV grado",
|
|
"coord V": "Coordinata V grado",
|
|
"subord": "Subordinata",
|
|
"subord I": "Subordinata I grado",
|
|
"subord II": "Subordinata II grado",
|
|
"subord III": "Subordinata III grado",
|
|
"subord IV": "Subordinata IV grado",
|
|
"subord V": "Subordinata V grado",
|
|
"subord VI": "Subordinata VI grado",
|
|
"subord VII": "Subordinata VII grado",
|
|
"parent": "Parentetica",
|
|
"pcoord": "Coordinata alla parentetica",
|
|
"pcoord I": "Coordinata alla parentetica I grado",
|
|
"coord 0": "Pseudo-coordinata"
|
|
}
|
|
)}
|
|
|
|
function _23(md){return(
|
|
md`#### Creating SVG`
|
|
)}
|
|
|
|
function _margin(){return(
|
|
{top: 20, bottom: 30, left: 5, right: 30}
|
|
)}
|
|
|
|
function _height(margin){return(
|
|
360 - margin.top - margin.bottom
|
|
)}
|
|
|
|
function _sentenceheight(sentenceNodeNames){return(
|
|
(sentenceNodeNames.length+1) * 33
|
|
)}
|
|
|
|
function _width(){return(
|
|
760
|
|
)}
|
|
|
|
function _28(md){return(
|
|
md`#### Create y scale function`
|
|
)}
|
|
|
|
function _yScale(d3,sentenceNodeNames,sentenceheight){return(
|
|
d3.scalePoint()
|
|
.domain(sentenceNodeNames)
|
|
.range([0,sentenceheight])
|
|
)}
|
|
|
|
function _syntfunction(data_frasi){return(
|
|
new Set(data_frasi["links"].slice(1), d => d.type)
|
|
)}
|
|
|
|
function _sentenceFunctionsColor(d3,types)
|
|
{return d3.scaleOrdinal(d3.schemePastel1).domain(types.values());}
|
|
|
|
|
|
function _sentenceFunctionsColor2(d3,types)
|
|
{return d3.scaleOrdinal(d3.schemeSet1).domain(types.values());}
|
|
|
|
|
|
function _synttype(data_frasi){return(
|
|
new Set(data_frasi["nodes"].slice(1), d=> d.s_type)
|
|
)}
|
|
|
|
function _sentenceSynttypeColor(d3,synttype)
|
|
{return d3.scaleOrdinal(d3.schemePastel1).domain(synttype.values());
|
|
}
|
|
|
|
|
|
function _colorssp(d3){return(
|
|
d3.scaleQuantize()
|
|
.domain([0,17])
|
|
.range(["#1f78b4", "#a6cee3", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00",
|
|
"#cab2d6", "#6a3d9a", "#ffff99", "#b15928", "#F46D43",
|
|
"#D53E4F", "#9E0142", "#e377c2", "#7f7f7f", "#bcbd22"])
|
|
)}
|
|
|
|
function _colorssp1(d3){return(
|
|
d3.scaleQuantize()
|
|
.domain([0,17])
|
|
.range(["#3288bd", "#66c2a5", "#e41a1c", "#4daf4a", "#984ea3", "#d53e4f", "#f46d43", "#ABDDA4",
|
|
"#E6F598", "#FFFFBF", "#FEE08B", "#FDAE61", "#F46D43",
|
|
"#D53E4F", "#9E0142", "#e377c2", "#7f7f7f", "#bcbd22"])
|
|
)}
|
|
|
|
function _maptypestopalette(){return(
|
|
{"princ": 0, "subord I": 1, "subord II": 3, "subord III": 4, "coord": 5,
|
|
"coord I": 9, "coord II": 10, "subord IV": 5, "subord V": 6, "parent": 17,
|
|
"coord III": 11, "pcoord":14, "coord 0": 16, "subord VI": 7 , "coord IV": 12,
|
|
"coord V": 13, "pcoord I": 15, "subord VII": 8}
|
|
)}
|
|
|
|
function _38(md){return(
|
|
md`## Struttura del periodo`
|
|
)}
|
|
|
|
function _lisid(){return(
|
|
'1_1_3'
|
|
)}
|
|
|
|
function* _periodoscritto(html,periodo)
|
|
{
|
|
// for Observable Cell
|
|
const wrapper = html`<div style="text-align: center;"></div>`;
|
|
const container = html`<div></div>`
|
|
|
|
|
|
|
|
const descriptionDiv = document.createElement('div');
|
|
|
|
descriptionDiv.setAttribute("style", "font-size:1em; text-align:justify; font-style: oblique; text-anchor:start width: 100px;")
|
|
if (periodo==null)
|
|
descriptionDiv.innerHTML ='';
|
|
else
|
|
descriptionDiv.innerHTML =periodo;
|
|
|
|
container.setAttribute("style", "font-size:1.0em; text-align:justify;")
|
|
wrapper.appendChild(descriptionDiv);
|
|
wrapper.appendChild(container);
|
|
yield wrapper;
|
|
}
|
|
|
|
|
|
function _42(swatches,sentenceFunctionsColor){return(
|
|
swatches({
|
|
color: sentenceFunctionsColor
|
|
})
|
|
)}
|
|
|
|
function _periodo(data_frasi){return(
|
|
data_frasi.nodes[0].visible
|
|
)}
|
|
|
|
function _sentenceStructArcs2(d3,DOM,width,margin,height,data_frasi,yScale,sentenceFunctionsColor,idToNode,sentenceFunctionsColor2,wrap_text_nchar)
|
|
{
|
|
const radius = 5
|
|
const container = d3.select(DOM.svg(width+margin.left+margin.right,
|
|
height+margin.top+margin.bottom))
|
|
const arcGroup = container
|
|
.append("g")
|
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
|
|
|
|
// create the nodes
|
|
const nodes = arcGroup.selectAll("nodes")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("circle")
|
|
.attr("cx", margin.left+400)
|
|
.attr("cy", d => yScale(d.visible))
|
|
.attr("r", radius)
|
|
.attr("fill", d=> sentenceFunctionsColor(d.type))
|
|
.attr("id", d => d.visible)
|
|
|
|
// create the node labels
|
|
const nodeLabels = arcGroup.selectAll("nodeLabels")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
.attr("x", margin.left+170)
|
|
.attr("y", d => yScale(d.visible)+5)
|
|
.attr("fill", "black")
|
|
.style("font-size", "10")
|
|
.style("font-style", "italic")
|
|
.style("text-anchor", "start")
|
|
.text(d => d.visible)
|
|
|
|
|
|
// the synctatic function
|
|
const syntfun = arcGroup.selectAll("syntfun")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
.attr("x", margin.left-10)
|
|
.attr("y", d => yScale(d.visible)+5)
|
|
.attr("fill", "black")
|
|
.style("font-size", "10")
|
|
.style("text-anchor", "start")
|
|
.text(d=> d.type+", "+d.s_type)
|
|
|
|
// This code builds up the SVG path element; see nodesAndArcs for details
|
|
function buildArc(d) {
|
|
|
|
let start = yScale(idToNode[d.source].visible);
|
|
let end = yScale(idToNode[d.target].visible);
|
|
//console.log(start+' '+end)
|
|
if (start==null)
|
|
return
|
|
const arcPath = ['M', margin.left+405, start, 'A', Math.abs(start - end)/2, ',', Math.abs(start-end)/2, 0,0,",",
|
|
start < end ? 1: 0, margin.left+405, end].join(' ');
|
|
return arcPath;
|
|
}
|
|
|
|
// create the arcs
|
|
const arcs = arcGroup.selectAll("arcs")
|
|
.data(data_frasi.links.slice(1))
|
|
.enter().append("path")
|
|
.attr("d", d => buildArc(d))
|
|
.style("fill", "none")
|
|
.style('stroke-width', 0.5)
|
|
.attr("stroke", 'lightgray');//d => sentenceFunctionsColor(d.type));
|
|
|
|
// mouseover animations
|
|
nodes.on('mouseover', function(d) {
|
|
// Highlight selected node
|
|
d3.select(this).style("fill", d=>sentenceFunctionsColor2(d.type));
|
|
|
|
var targetids=[]
|
|
// Highlight arcs
|
|
arcs
|
|
.style('stroke', function (arcd) {
|
|
if (arcd.source === d.id) { targetids.push(arcd.target)}; if (arcd.target === d.id) { targetids.push(arcd.source)};
|
|
return arcd.source === d.id || arcd.target === d.id ? d=> sentenceFunctionsColor2(d.type) : 'lightgray';})//d=> sentenceFunctionsColor(d.type);})
|
|
.style('stroke-width', function (arcd) {
|
|
return arcd.source === d.id || arcd.target === d.id ? 2 : 0.5;})
|
|
|
|
// Show syntactic types
|
|
syntfun
|
|
.style('fill', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? 'steelblue' : 'black' ;})
|
|
.style('font-weight', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? 'bold' : 'normal' ;});
|
|
|
|
// Highlight node labels
|
|
nodeLabels
|
|
.style("fill", function (nodeLabeld){
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'black' : 'black';})
|
|
.style('font-weight', function (nodeLabeld) {
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'bold' : 'normal';})
|
|
});
|
|
|
|
// remove highlighting when user mouse moves out of node by restoring default colors and thickness
|
|
nodes.on('mouseout', function (d) {
|
|
nodes.style("fill", d=> sentenceFunctionsColor(d.type));
|
|
arcs.style('stroke', 'lightgray')//d=>sentenceFunctionsColor(d.type));
|
|
arcs.style('stroke-width', 0.5);
|
|
syntfun.style('fill','black');
|
|
syntfun.style('font-weight','normal');
|
|
nodeLabels.style('fill','black');
|
|
nodeLabels.style('font-weight','normal');
|
|
});
|
|
|
|
container.selectAll("text")
|
|
.each(function(d, i) { wrap_text_nchar(d3.select(this), 40) });
|
|
return container.node();
|
|
}
|
|
|
|
|
|
function _sentenceStructArcs(d3,DOM,width,margin,sentenceheight,lisid,data_frasi,yScale,colorssp,maptypestopalette,wrap_text_array,clauseFunctions,getTypes,idToNode,sentenceFunctionsColor2,wrap_text_nchar)
|
|
{
|
|
|
|
|
|
const radius = 6
|
|
const nodehpos=460
|
|
const labelhpos=nodehpos-300
|
|
const maxlabelwidth=40
|
|
const container = d3.select(DOM.svg(width+margin.left+margin.right,
|
|
sentenceheight+margin.top+margin.bottom))
|
|
|
|
container.append("style").text(`
|
|
.synt__info{
|
|
font-size: 12px;
|
|
font-weight: normal;
|
|
font-style: italic;
|
|
font-family: -apple-system, BlinkMacSystemFont, “Helvetica Neue”,
|
|
“Segoe UI”, “Roboto”, “Oxygen”, “Ubuntu”, “Cantarell”,
|
|
“Fira Sans”, “Droid Sans”,
|
|
sans-serif;
|
|
}
|
|
`)
|
|
|
|
const arcGroup = container
|
|
.attr ("id", "periodograph")
|
|
.attr("width",null)
|
|
.attr("height",null)
|
|
.attr("name", lisid)
|
|
.append("g")
|
|
.style('pointer-events', 'all')
|
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
|
|
|
|
// create the nodes
|
|
const nodes = arcGroup.selectAll("nodes")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("circle")
|
|
.attr("cx", margin.left+nodehpos)
|
|
.attr("cy", d => yScale(d.visible))
|
|
.attr("r", radius)
|
|
//.attr("fill", d=> sentenceFunctionsColor(d.type))
|
|
.attr("fill", d => colorssp(maptypestopalette[d.type]))
|
|
.attr("id", d => d.visible)
|
|
|
|
// create the node labels
|
|
const nodeLabels = arcGroup.selectAll("nodeLabels")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
.attr("x", margin.left+labelhpos)
|
|
.attr("y", d => yScale(d.visible))
|
|
.attr("dominant-baseline", "middle")
|
|
//.attr("y", d=>ypostxt(d.visible))
|
|
.attr("class","synt__info")
|
|
//.style("font-style", "italic")
|
|
.style("text-anchor", "start")
|
|
.text(d => d.visible)
|
|
|
|
function ypostxt(label){
|
|
//delta = (_fontsize * textarea.split("\n").length) / 2;
|
|
const label_array = wrap_text_array(label, maxlabelwidth);
|
|
return yScale(label)+ -(8 * label_array.length)/2
|
|
//return label_array.length<3? yScale(label)+3: yScale(label)-(5*(label_array.length-1))
|
|
}
|
|
|
|
// the synctatic function and types
|
|
const syntfun = arcGroup.selectAll("syntfun")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
.attr("x", margin.left-10)
|
|
.attr("y", d => yScale(d.visible))//+syntfunctype(clauseFunctions[d.type]+", "+getTypes(d.s_type)))
|
|
.attr("dominant-baseline", "middle")
|
|
.attr("class","f6 text-muted text-nowrap font-weight-normal")
|
|
.style("font-size", "10")
|
|
.style("text-anchor", "start")
|
|
.style("letter-spacing", 0)
|
|
.text(d=> clauseFunctions[d.type]+", "+getTypes(d.s_type))
|
|
|
|
function syntfunctype(funty){
|
|
const funty_array = wrap_text_array(funty, maxlabelwidth);
|
|
return (funty_array.length<3? 0: -10)
|
|
}
|
|
// This code builds up the SVG path element; see nodesAndArcs for details
|
|
function buildArc(d) {
|
|
|
|
let start = yScale(idToNode[d.source].visible);
|
|
let end = yScale(idToNode[d.target].visible);
|
|
//console.log(start+' '+end)
|
|
if (start==null)
|
|
return
|
|
const arcPath = ['M', margin.left+nodehpos+6, start, 'A', Math.abs(start - end)/2, ',', Math.abs(start-end)/2, 0,0,",",
|
|
start < end ? 1: 0, margin.left+nodehpos+6, end].join(' ');
|
|
return arcPath;
|
|
}
|
|
|
|
// create the arcs
|
|
const arcs = arcGroup.selectAll("arcs")
|
|
.data(data_frasi.links.slice(1))
|
|
.enter().append("path")
|
|
.attr("d", d => buildArc(d))
|
|
.style("fill", "none")
|
|
.style('stroke-width', 0.5)
|
|
.attr("stroke", 'lightgray');//d => sentenceFunctionsColor(d.type));
|
|
|
|
// mouseover animations
|
|
nodes.on('mouseover', function(event, d) {
|
|
// Highlight selected node
|
|
d3.select(this).style("fill", d=>colorssp(maptypestopalette[d.type]));//sentenceFunctionsColor2(d.type));
|
|
|
|
var targetids=[]
|
|
// Highlight arcs
|
|
arcs
|
|
.style('stroke', function (arcd) {
|
|
if (arcd.source === d.id) { targetids.push(arcd.target)}; if (arcd.target === d.id) { targetids.push(arcd.source)};
|
|
return arcd.source === d.id || arcd.target === d.id ? d=> sentenceFunctionsColor2(d.type) : 'lightgray';})//d=> sentenceFunctionsColor(d.type);})
|
|
.style('stroke-width', function (arcd) {
|
|
return arcd.source === d.id || arcd.target === d.id ? 2 : 0.5;})
|
|
|
|
// Highlight syntactic types
|
|
syntfun
|
|
.style('fill', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? 'steelblue' : 'black' ;})
|
|
.style('font-weight', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? 'bold' : 'normal' ;});
|
|
|
|
// Highlight node labels
|
|
nodeLabels
|
|
.style("fill", function (nodeLabeld){
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'black' : 'black';})
|
|
.style('font-weight', function (nodeLabeld) {
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'bold' : 'normal';})
|
|
});
|
|
|
|
// remove highlighting when user mouse moves out of node by restoring default colors and thickness
|
|
nodes.on('mouseout', function (event, d) {
|
|
nodes.style("fill", d=> colorssp(maptypestopalette[d.type]));//sentenceFunctionsColor(d.type));
|
|
arcs.style('stroke', 'lightgray')//d=>sentenceFunctionsColor(d.type));
|
|
arcs.style('stroke-width', 0.5);
|
|
syntfun.style('fill','black');
|
|
syntfun.style('font-weight','normal');
|
|
//nodeLabels.style('fill','black');
|
|
nodeLabels.style('font-weight','normal');
|
|
nodeLabels.attr("class","synt__info")
|
|
});
|
|
|
|
container.selectAll("text")
|
|
.each(function(d, i) { wrap_text_nchar(d3.select(this), 50) });
|
|
return container.node();
|
|
}
|
|
|
|
|
|
function _sentenceStructArcs_new(d3,DOM,width,margin,sentenceheight,lisid,data_frasi,yScale,colorssp,maptypestopalette,wrap_text_array,clauseFunctions,getTypes,idToNode,sentenceFunctionsColor2,darken,wrap_text_nchar)
|
|
{
|
|
|
|
|
|
const radius = 4
|
|
const nodehpos=460
|
|
const labelhpos=nodehpos-295
|
|
const maxlabelwidth=40
|
|
const container = d3.select(DOM.svg(width+margin.left+margin.right,
|
|
sentenceheight+margin.top+margin.bottom))
|
|
|
|
container.append("style").text(`
|
|
.synt__info{
|
|
font-size: 13px;
|
|
font-weight: normal;
|
|
font-style: italic;
|
|
font-family: Palatino;
|
|
|
|
}
|
|
.synt__categ{
|
|
font-size: 10px;
|
|
font-weight: normal;
|
|
font-family: Palatino;
|
|
}
|
|
|
|
`)
|
|
|
|
const arcGroup = container
|
|
.attr ("id", "periodograph")
|
|
.attr("width",null)
|
|
.attr("height",null)
|
|
.attr("name", lisid)
|
|
.append("g")
|
|
//.style('pointer-events', 'all')
|
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
|
|
|
|
// create the nodes
|
|
const nodes = arcGroup.selectAll("nodes")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("circle")
|
|
.attr("cx", margin.left+nodehpos)
|
|
.attr("cy", d => yScale(d.visible))
|
|
.attr("r", radius)
|
|
//.attr("fill", d=> sentenceFunctionsColor(d.type))
|
|
.attr("fill", d => colorssp(maptypestopalette[d.type]))
|
|
.attr("id", d => d.visible)
|
|
|
|
// // create the node labels
|
|
// const nodeLabels = arcGroup.selectAll("nodeLabels")
|
|
// .data(data_frasi.nodes.slice(1))
|
|
// .enter().append("text")
|
|
// .attr("x", margin.left+labelhpos)
|
|
// //.attr("y", d => yScale(d.visible))
|
|
// .attr("dominant-baseline", "middle")
|
|
// .attr("y", d=>yScale(d.visible)+syntfunctype(d.visible))
|
|
// .attr("class","synt__info")
|
|
// //.style("font-style", "italic")
|
|
// .style("text-anchor", "start")
|
|
// .text(d => d.visible)
|
|
|
|
function ypostxt(label){
|
|
//delta = (_fontsize * textarea.split("\n").length) / 2;
|
|
const label_array = wrap_text_array(label, maxlabelwidth);
|
|
return yScale(label)+ -(8 * label_array.length)/2
|
|
//return label_array.length<3? yScale(label)+3: yScale(label)-(5*(label_array.length-1))
|
|
}
|
|
|
|
// the synctatic function and types
|
|
const syntfun = arcGroup.selectAll("syntfun")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
.attr("x", margin.left-10)
|
|
.attr("y", d => yScale(d.visible)+syntfunctype(clauseFunctions[d.type]+", "+getTypes(d.s_type)))
|
|
//.attr("y", d=>ypostxt(d.visible))
|
|
.attr("dominant-baseline", "middle")
|
|
.attr("class","synt__categ")
|
|
.style("text-anchor", "start")
|
|
.style("letter-spacing", 0)
|
|
.text(d=> clauseFunctions[d.type]+", "+getTypes(d.s_type))
|
|
|
|
function syntfunctype(funty){
|
|
const funty_array = wrap_text_array(funty, maxlabelwidth);
|
|
return (funty_array.length<2? 0: -(2.5 * funty_array.length))
|
|
}
|
|
|
|
// This code builds up the SVG path element; see nodesAndArcs for details
|
|
function buildArc(d) {
|
|
|
|
let start = yScale(idToNode[d.source].visible);
|
|
let end = yScale(idToNode[d.target].visible);
|
|
let lor=true;
|
|
let nodeoffset=4
|
|
if (start==null)
|
|
return
|
|
const arcPath = ['M', margin.left+nodehpos+nodeoffset, start, 'A', (Math.abs(start - end)/2), ',', Math.abs(start-end)/2, 0,0,",",
|
|
lor ? 1: 0, margin.left+nodehpos+nodeoffset, end].join(' ');
|
|
|
|
return arcPath;
|
|
}
|
|
|
|
function buildReverseArc(d) {
|
|
|
|
let start = yScale(idToNode[d.source].visible);
|
|
let end = yScale(idToNode[d.target].visible);
|
|
let lor=true;
|
|
let nodeoffset=4
|
|
if (start < end && d.type.includes ('coord')){//.includes('coord')){
|
|
console.log('here')
|
|
lor=false;
|
|
nodeoffset=-4
|
|
}
|
|
else
|
|
return
|
|
if (start==null)
|
|
return
|
|
const arcPath = ['M', margin.left+nodehpos+nodeoffset, start, 'A', Math.abs(start - end)/2, ',', Math.abs(start-end)/2, 0,0,",",
|
|
lor ? 1: 0, margin.left+nodehpos+nodeoffset, end].join(' ');
|
|
//console.log(start+' - '+end+', '+d.type+'; '+arcPath)
|
|
return arcPath;
|
|
}
|
|
|
|
// create the arcs
|
|
var arcs = arcGroup.selectAll("arcs")
|
|
.data(data_frasi.links.slice(1))
|
|
.enter().append("path")
|
|
.attr("d", d => buildArc(d))
|
|
.style("fill", "none")
|
|
.style('stroke-width', 0.5)
|
|
.attr("stroke", 'lightgray');//d => sentenceFunctionsColor(d.type));
|
|
|
|
// create the arcs for Coordinate
|
|
|
|
var arcs_coord = arcGroup.selectAll("arcs")
|
|
.data(data_frasi.links.slice(1))
|
|
.enter().append("path")
|
|
.attr("d", d => buildReverseArc(d))
|
|
.style("fill", "none")
|
|
.style('stroke-width', 0.5)
|
|
.attr("stroke", 'lightgray');//d => sentenceFunctionsColor(d.type));
|
|
|
|
// create the node labels
|
|
const nodeLabels = arcGroup.selectAll("nodeLabels")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
.attr("x", margin.left+labelhpos)
|
|
//.attr("y", d => yScale(d.visible))
|
|
.attr("dominant-baseline", "middle")
|
|
.attr("y", d=>yScale(d.visible)+syntfunctype(d.visible))
|
|
.attr("class","synt__info")
|
|
//.style("font-style", "italic")
|
|
.style("text-anchor", "start")
|
|
.text(d => d.visible)
|
|
|
|
// mouseover animations
|
|
nodes.on('mouseover', function(event, d) {
|
|
// Highlight selected node
|
|
d3.select(this).style("fill", d=>colorssp(maptypestopalette[d.type]));//sentenceFunctionsColor2(d.type));
|
|
|
|
var targetids=[]
|
|
// Highlight arcs
|
|
arcs
|
|
.style('stroke', function (arcd) {
|
|
if (arcd.source === d.id) { targetids.push(arcd.target)}; if (arcd.target === d.id) { targetids.push(arcd.source)};
|
|
return arcd.source === d.id || arcd.target === d.id ? d=> sentenceFunctionsColor2(d.type) : 'lightgray';})//d=> sentenceFunctionsColor(d.type);})
|
|
.style('stroke-width', function (arcd) {
|
|
return arcd.source === d.id || arcd.target === d.id ? 2 : 0.5;})
|
|
|
|
//arcs_coord
|
|
arcs_coord
|
|
.style('stroke', function (arcd) {
|
|
if (arcd.source === d.id) { targetids.push(arcd.target)}; if (arcd.target === d.id) { targetids.push(arcd.source)};
|
|
return arcd.source === d.id || arcd.target === d.id ? d=> sentenceFunctionsColor2(d.type) : 'lightgray';})
|
|
.style('stroke-width', function (arcd) {
|
|
return arcd.source === d.id || arcd.target === d.id ? 2 : 0.5;})
|
|
|
|
// Highlight syntactic types
|
|
syntfun
|
|
.style('fill', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? darken('steelblue') : 'black' ;})
|
|
.style('font-weight', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? 'bold' : 'normal' ;});
|
|
|
|
// Highlight node labels
|
|
nodeLabels
|
|
.style("fill", function (nodeLabeld){
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'black' : 'black';})
|
|
.style('font-weight', function (nodeLabeld) {
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'bold' : 'normal';})
|
|
});
|
|
|
|
// remove highlighting when user mouse moves out of node by restoring default colors and thickness
|
|
nodes.on('mouseout', function (event, d) {
|
|
nodes.style("fill", d=> colorssp(maptypestopalette[d.type]));//sentenceFunctionsColor(d.type));
|
|
arcs.style('stroke', 'lightgray')
|
|
arcs.style('stroke-width', 0.5);
|
|
arcs_coord.style('stroke', 'lightgray')
|
|
arcs_coord.style('stroke-width', 0.5);
|
|
syntfun.style('fill','black');
|
|
syntfun.style('font-weight','normal');
|
|
//nodeLabels.style('fill','black');
|
|
nodeLabels.style('font-weight','normal');
|
|
nodeLabels.attr("class","synt__info")
|
|
});
|
|
|
|
container.selectAll("text")
|
|
.each(function(d, i) { wrap_text_nchar(d3.select(this), maxlabelwidth) });
|
|
return container.node();
|
|
}
|
|
|
|
|
|
function _sentenceArcsStructs_new(d3,DOM,width,margin,sentenceheight,lisid,data_frasi,yScale,colorssp,maptypestopalette,wrap_text_array,idToNode,clauseFunctions,getTypes,sentenceFunctionsColor2,darken,wrap_text_nchar)
|
|
{
|
|
|
|
|
|
const radius = 4
|
|
const sty=24
|
|
const titleposy=15
|
|
const titleposx=margin.lef-10 //100
|
|
const nodehpos=483
|
|
const labelhpos=nodehpos-178
|
|
const maxlabelwidth=40
|
|
const container = d3.select(DOM.svg(width+margin.left+margin.right,
|
|
sentenceheight+margin.top+margin.bottom+24))
|
|
|
|
|
|
container
|
|
.append("text")
|
|
.attr("x", titleposx)
|
|
.attr("y", titleposy)
|
|
.attr("text-anchor", "middle")
|
|
.attr("alignment-baseline", "middle")
|
|
//.attr("class","text-warning")
|
|
.attr("font-family", 'inherit')
|
|
.style("text-anchor", "start")
|
|
.text("Frasi");
|
|
|
|
container
|
|
.append("text")
|
|
.attr("x", margin.left+labelhpos)
|
|
.attr("y", titleposy)
|
|
.attr("text-anchor", "middle")
|
|
.attr("alignment-baseline", "middle")
|
|
//.attr("class","synt__label")
|
|
.attr("font-family", 'inherit')
|
|
.style("text-anchor", "start")
|
|
.text("Funzioni e tipi");
|
|
|
|
/*
|
|
container.append("style").text(`
|
|
.synt__info{
|
|
font-size: 16px;
|
|
font-weight: normal;
|
|
font-style: italic;
|
|
font-family: Book Antiqua,Palatino,Palatino Linotype,Palatino LT STD,Georgia,serif;
|
|
|
|
}
|
|
.synt__categ{
|
|
font-size: 12px;
|
|
font-weight: normal;
|
|
font-family: Book Antiqua,Palatino,Palatino Linotype,Palatino LT STD,Georgia,serif;
|
|
}
|
|
.synt__label{
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
font-family: Book Antiqua,Palatino,Palatino Linotype,Palatino LT STD,Georgia,serif;
|
|
}
|
|
|
|
`)
|
|
*/
|
|
|
|
const arcGroup = container
|
|
.attr ("id", "periodograph")
|
|
.attr("width",null)
|
|
.attr("height",null)
|
|
.attr("name", lisid)
|
|
.append("g")
|
|
//.style('pointer-events', 'all')
|
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
|
|
|
|
// create the nodes
|
|
const nodes = arcGroup.selectAll("nodes")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("circle")
|
|
.attr("cx", margin.left+nodehpos)
|
|
.attr("cy", d => sty+yScale(d.visible))
|
|
.attr("r", radius)
|
|
//.attr("fill", d=> sentenceFunctionsColor(d.type))
|
|
.attr("fill", d => colorssp(maptypestopalette[d.type]))
|
|
.attr("id", d => d.visible)
|
|
|
|
|
|
function ypostxt(label){
|
|
//delta = (_fontsize * textarea.split("\n").length) / 2;
|
|
const label_array = wrap_text_array(label, maxlabelwidth);
|
|
return yScale(label)+ -(8 * label_array.length)/2
|
|
//return label_array.length<3? yScale(label)+3: yScale(label)-(5*(label_array.length-1))
|
|
}
|
|
|
|
|
|
function syntfunctype(funty){
|
|
const funty_array = wrap_text_array(funty, maxlabelwidth);
|
|
return (funty_array.length<2? 0: -(2.5 * funty_array.length))
|
|
}
|
|
|
|
// This code builds up the SVG path element; see nodesAndArcs for details
|
|
function buildArc(d) {
|
|
|
|
let start = sty+yScale(idToNode[d.source].visible);
|
|
let end = sty+yScale(idToNode[d.target].visible);
|
|
let lor=true;
|
|
let nodeoffset=4
|
|
if (start==null)
|
|
return
|
|
const arcPath = ['M', margin.left+nodehpos+nodeoffset, start, 'A', (Math.abs(start - end)/2), ',', Math.abs(start-end)/2, 0,0,",",
|
|
lor ? 1: 0, margin.left+nodehpos+nodeoffset, end].join(' ');
|
|
|
|
return arcPath;
|
|
}
|
|
|
|
function buildReverseArc(d) {
|
|
|
|
let start = sty+yScale(idToNode[d.source].visible);
|
|
let end = sty+yScale(idToNode[d.target].visible);
|
|
let lor=true;
|
|
let nodeoffset=4
|
|
if (start < end && d.type.includes ('coord')){//.includes('coord')){
|
|
console.log('here')
|
|
lor=false;
|
|
nodeoffset=-4
|
|
}
|
|
else
|
|
return
|
|
if (start==null)
|
|
return
|
|
const arcPath = ['M', margin.left+nodehpos+nodeoffset, start, 'A', Math.abs(start - end)/2, ',', Math.abs(start-end)/2, 0,0,",",
|
|
lor ? 1: 0, margin.left+nodehpos+nodeoffset, end].join(' ');
|
|
//console.log(start+' - '+end+', '+d.type+'; '+arcPath)
|
|
return arcPath;
|
|
}
|
|
|
|
// create the arcs
|
|
var arcs = arcGroup.selectAll("arcs")
|
|
.data(data_frasi.links.slice(1))
|
|
.enter().append("path")
|
|
.attr("d", d => buildArc(d))
|
|
.style("fill", "none")
|
|
.style('stroke-width', 0.3)
|
|
.attr("stroke", 'lightgray');//d => sentenceFunctionsColor(d.type));
|
|
|
|
// create the arcs for Coordinate
|
|
|
|
var arcs_coord = arcGroup.selectAll("arcs")
|
|
.data(data_frasi.links.slice(1))
|
|
.enter().append("path")
|
|
.attr("d", d => buildReverseArc(d))
|
|
.style("fill", "none")
|
|
.style('stroke-width', 0.3)
|
|
.attr("stroke", 'lightgray');//d => sentenceFunctionsColor(d.type));
|
|
|
|
// create the node labels
|
|
const nodeLabels = arcGroup.selectAll("nodeLabels")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
//.attr("x", margin.left+labelhpos)
|
|
.attr("x", margin.left-10)
|
|
//.attr("y", d => yScale(d.visible))
|
|
.attr("dominant-baseline", "middle")
|
|
.attr("y", d=>sty+ yScale(d.visible)+syntfunctype(d.visible))
|
|
.attr("class","synt__info")
|
|
.style("text-anchor", "start")
|
|
.text(d => d.visible)
|
|
|
|
// the synctatic function and types
|
|
const syntfun = arcGroup.selectAll("syntfun")
|
|
.data(data_frasi.nodes.slice(1))
|
|
.enter().append("text")
|
|
//.attr("x", margin.left-10)
|
|
.attr("x", margin.left+labelhpos)
|
|
.attr("y", d => sty+ yScale(d.visible)+syntfunctype(clauseFunctions[d.type]+", "+getTypes(d.s_type)))
|
|
//.attr("y", d=>ypostxt(d.visible))
|
|
.attr("dominant-baseline", "middle")
|
|
.attr("class","synt__categ")
|
|
.style("text-anchor", "start")
|
|
.style("letter-spacing", 0)
|
|
.text(d=> clauseFunctions[d.type]+", "+getTypes(d.s_type))
|
|
|
|
// mouseover animations
|
|
nodes.on('mouseover', function(event, d) {
|
|
// Highlight selected node
|
|
d3.select(this).style("fill", d=>colorssp(maptypestopalette[d.type]));//sentenceFunctionsColor2(d.type));
|
|
|
|
var targetids=[]
|
|
// Highlight arcs
|
|
arcs
|
|
.style('stroke', function (arcd) {
|
|
if (arcd.source === d.id) { targetids.push(arcd.target)}; if (arcd.target === d.id) { targetids.push(arcd.source)};
|
|
return arcd.source === d.id || arcd.target === d.id ? d=> sentenceFunctionsColor2(d.type) : 'lightgray';})//d=> sentenceFunctionsColor(d.type);})
|
|
.style('stroke-width', function (arcd) {
|
|
return arcd.source === d.id || arcd.target === d.id ? 2 : 0.3;})
|
|
|
|
//arcs_coord
|
|
arcs_coord
|
|
.style('stroke', function (arcd) {
|
|
if (arcd.source === d.id) { targetids.push(arcd.target)}; if (arcd.target === d.id) { targetids.push(arcd.source)};
|
|
return arcd.source === d.id || arcd.target === d.id ? d=> sentenceFunctionsColor2(d.type) : 'lightgray';})
|
|
.style('stroke-width', function (arcd) {
|
|
return arcd.source === d.id || arcd.target === d.id ? 2 : 0.3;})
|
|
|
|
// Highlight syntactic types
|
|
syntfun
|
|
.style('fill', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? darken('steelblue') : 'black' ;})
|
|
.style('font-weight', function (syntfund) {
|
|
//return syntfund.visible+syntfund.s_type === d.visible+d.s_type ? 'steelblue' : 'black' ;});
|
|
return (syntfund.visible+syntfund.s_type === d.visible+d.s_type || targetids.includes(syntfund.id)) ? 'bold' : 'normal' ;});
|
|
|
|
// Highlight node labels
|
|
nodeLabels
|
|
.style("fill", function (nodeLabeld){
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'black' : 'black';})
|
|
.style('font-weight', function (nodeLabeld) {
|
|
return nodeLabeld.id == d.id || targetids.includes(nodeLabeld.id) ? 'bold' : 'normal';})
|
|
});
|
|
|
|
// remove highlighting when user mouse moves out of node by restoring default colors and thickness
|
|
nodes.on('mouseout', function (event, d) {
|
|
nodes.style("fill", d=> colorssp(maptypestopalette[d.type]));//sentenceFunctionsColor(d.type));
|
|
arcs.style('stroke', 'lightgray')
|
|
arcs.style('stroke-width', 0.5);
|
|
arcs_coord.style('stroke', 'lightgray')
|
|
arcs_coord.style('stroke-width', 0.5);
|
|
syntfun.style('fill','black');
|
|
syntfun.style('font-weight','normal');
|
|
//nodeLabels.style('fill','black');
|
|
nodeLabels.style('font-weight','normal');
|
|
nodeLabels.attr("class","synt__info")
|
|
});
|
|
|
|
container.selectAll("text")
|
|
.each(function(d, i) { wrap_text_nchar(d3.select(this), maxlabelwidth) });
|
|
|
|
return container.node();
|
|
}
|
|
|
|
|
|
function _48(md){return(
|
|
md`### Utility`
|
|
)}
|
|
|
|
function _darken(d3){return(
|
|
function darken(color, k = 1) {
|
|
const {l, c, h} = d3.lch(color);
|
|
return d3.lch(l - 18 * k, c, h);
|
|
}
|
|
)}
|
|
|
|
function _50(wrap_text_array){return(
|
|
wrap_text_array('Principale, Interrogativa Di TipoX Retorica', 40)
|
|
)}
|
|
|
|
function _wrap_text_nchar(wrap_text_array){return(
|
|
(text_element, max_width, line_height, unit = "em") => {
|
|
//console.log('te' +text_element)
|
|
// use a default line_height if not provided
|
|
if (!line_height) line_height = 1.0;
|
|
if (text_element.text().length>150)
|
|
line_height = 0.8
|
|
if (text_element.text().includes("ordinata") || text_element.text().includes("parentetica") ||
|
|
text_element.text().includes("principale") || text_element.text().includes("Principale")){
|
|
max_width=30
|
|
if (text_element.text().length>90)
|
|
line_height = 0.9
|
|
}
|
|
|
|
// wrap the text based on how many characters per line
|
|
const text_array = wrap_text_array(text_element.text(), max_width);
|
|
|
|
// append a tspan element for each line of text_array
|
|
text_element.text(null)
|
|
.selectAll("tspan")
|
|
.data(text_array).enter()
|
|
.append("tspan")
|
|
.attr("x", text_element.attr("x"))
|
|
.attr("y", text_element.attr("y"))
|
|
.attr("dy", (d, i) => `${(i * line_height)}${unit}`)
|
|
.text(d => d);
|
|
}
|
|
)}
|
|
|
|
function _wrap_text_array(){return(
|
|
(text, max_width) => {
|
|
// split the text around spaces (to get individual words)
|
|
const words = text.split(/\s+/).reverse();
|
|
|
|
// define vars to hold individual words, lines, and all lines
|
|
let word,
|
|
lines = [ ],
|
|
line = [ ];
|
|
|
|
// add words to a line until we exceed the max_width (in characters)
|
|
// when we reach width, add the line to lines and start a new line
|
|
while (word = words.pop()) {
|
|
line.push(word);
|
|
if (line.join(" ").length > max_width || word[0]=='(') {
|
|
line.pop()
|
|
lines.push(line.join(" "));
|
|
line = [word];
|
|
}
|
|
}
|
|
lines.push(line.join(" "));
|
|
|
|
return lines;
|
|
}
|
|
)}
|
|
|
|
function _wrap_node_text(){return(
|
|
(text, width) => {
|
|
// split the text around spaces (to get individual words)
|
|
|
|
|
|
if (text==null)
|
|
text==''
|
|
const words = text.split(/\s+/).reverse();
|
|
|
|
// define vars to hold individual words, lines, and all lines
|
|
let word,
|
|
lines = [ ],
|
|
line = [ ];
|
|
|
|
// add words to a line until we exceed the max_width (in characters)
|
|
// when we reach width, add the line to lines and start a new line
|
|
while (word = words.pop()) {
|
|
line.push(word);
|
|
|
|
if (line.join(" ").length > width) {
|
|
line.pop()
|
|
lines.push(line.join(" "));
|
|
lines.push('\n <br>');
|
|
line = [word.trim()];
|
|
|
|
}
|
|
}
|
|
lines.push(line.join(" "));
|
|
var htmllines=lines.join("")
|
|
console.log(htmllines)
|
|
return htmllines;
|
|
}
|
|
)}
|
|
|
|
export default function define(runtime, observer) {
|
|
const main = runtime.module();
|
|
function toString() { return this.url; }
|
|
const fileAttachments = new Map([
|
|
["parsint_mod_completo_pergrafi_5 (7).csv", {url: new URL("./files/d3e527e21de38da71603c008f6d102c1e83db4d0efc86161f62cb49eca203e9e31663308809277e7a353c024dee6d22620d060037ac0eb026219e57b8f7f1fd1.csv", import.meta.url), mimeType: "text/csv", toString}]
|
|
]);
|
|
main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
|
|
main.variable(observer()).define(["md"], _1);
|
|
main.variable(observer("d3")).define("d3", ["require"], _d3);
|
|
main.variable(observer()).define(["md"], _3);
|
|
main.variable(observer("links2")).define("links2", ["FileAttachment"], _links2);
|
|
main.variable(observer()).define(["md"], _6);
|
|
main.variable(observer("types")).define("types", ["links2"], _types);
|
|
main.variable(observer("getFrasi")).define("getFrasi", ["links2"], _getFrasi);
|
|
main.variable(observer("getSid")).define("getSid", _getSid);
|
|
main.variable(observer("listafrasi")).define("listafrasi", ["getSid","lisid"], _listafrasi);
|
|
main.variable(observer("getColor")).define("getColor", ["sentenceFunctionsColor2"], _getColor);
|
|
main.variable(observer("clauseType")).define("clauseType", _clauseType);
|
|
main.variable(observer("col")).define("col", ["getColor","clauseType"], _col);
|
|
main.variable(observer("data_frasi")).define("data_frasi", ["getFrasi","listafrasi"], _data_frasi);
|
|
main.variable(observer("sentenceTypes")).define("sentenceTypes", ["data_frasi"], _sentenceTypes);
|
|
main.variable(observer("sentenceNodeNames")).define("sentenceNodeNames", ["data_frasi"], _sentenceNodeNames);
|
|
main.variable(observer("idToNode")).define("idToNode", ["data_frasi"], _idToNode);
|
|
main.variable(observer("idToTargetNodes")).define("idToTargetNodes", ["data_frasi"], _idToTargetNodes);
|
|
main.variable(observer("syntactic_macrotypes")).define("syntactic_macrotypes", _syntactic_macrotypes);
|
|
main.variable(observer("syntactic_types")).define("syntactic_types", _syntactic_types);
|
|
main.variable(observer("getTypes")).define("getTypes", ["syntactic_macrotypes","syntactic_types"], _getTypes);
|
|
main.variable(observer("clauseFunctions")).define("clauseFunctions", _clauseFunctions);
|
|
main.variable(observer()).define(["md"], _23);
|
|
main.variable(observer("margin")).define("margin", _margin);
|
|
main.variable(observer("height")).define("height", ["margin"], _height);
|
|
main.variable(observer("sentenceheight")).define("sentenceheight", ["sentenceNodeNames"], _sentenceheight);
|
|
main.variable(observer("width")).define("width", _width);
|
|
main.variable(observer()).define(["md"], _28);
|
|
main.variable(observer("yScale")).define("yScale", ["d3","sentenceNodeNames","sentenceheight"], _yScale);
|
|
main.variable(observer("syntfunction")).define("syntfunction", ["data_frasi"], _syntfunction);
|
|
main.variable(observer("sentenceFunctionsColor")).define("sentenceFunctionsColor", ["d3","types"], _sentenceFunctionsColor);
|
|
main.variable(observer("sentenceFunctionsColor2")).define("sentenceFunctionsColor2", ["d3","types"], _sentenceFunctionsColor2);
|
|
main.variable(observer("synttype")).define("synttype", ["data_frasi"], _synttype);
|
|
main.variable(observer("sentenceSynttypeColor")).define("sentenceSynttypeColor", ["d3","synttype"], _sentenceSynttypeColor);
|
|
main.variable(observer("colorssp")).define("colorssp", ["d3"], _colorssp);
|
|
main.variable(observer("colorssp1")).define("colorssp1", ["d3"], _colorssp1);
|
|
main.variable(observer("maptypestopalette")).define("maptypestopalette", _maptypestopalette);
|
|
main.variable(observer()).define(["md"], _38);
|
|
main.variable(observer("lisid")).define("lisid", _lisid);
|
|
const child1 = runtime.module(define1);
|
|
main.import("swatches", child1);
|
|
main.variable(observer("periodoscritto")).define("periodoscritto", ["html","periodo"], _periodoscritto);
|
|
main.variable(observer()).define(["swatches","sentenceFunctionsColor"], _42);
|
|
main.variable(observer("periodo")).define("periodo", ["data_frasi"], _periodo);
|
|
main.variable(observer("sentenceStructArcs2")).define("sentenceStructArcs2", ["d3","DOM","width","margin","height","data_frasi","yScale","sentenceFunctionsColor","idToNode","sentenceFunctionsColor2","wrap_text_nchar"], _sentenceStructArcs2);
|
|
main.variable(observer("sentenceStructArcs")).define("sentenceStructArcs", ["d3","DOM","width","margin","sentenceheight","lisid","data_frasi","yScale","colorssp","maptypestopalette","wrap_text_array","clauseFunctions","getTypes","idToNode","sentenceFunctionsColor2","wrap_text_nchar"], _sentenceStructArcs);
|
|
main.variable(observer("sentenceStructArcs_new")).define("sentenceStructArcs_new", ["d3","DOM","width","margin","sentenceheight","lisid","data_frasi","yScale","colorssp","maptypestopalette","wrap_text_array","clauseFunctions","getTypes","idToNode","sentenceFunctionsColor2","darken","wrap_text_nchar"], _sentenceStructArcs_new);
|
|
main.variable(observer("sentenceArcsStructs_new")).define("sentenceArcsStructs_new", ["d3","DOM","width","margin","sentenceheight","lisid","data_frasi","yScale","colorssp","maptypestopalette","wrap_text_array","idToNode","clauseFunctions","getTypes","sentenceFunctionsColor2","darken","wrap_text_nchar"], _sentenceArcsStructs_new);
|
|
main.variable(observer()).define(["md"], _48);
|
|
main.variable(observer("darken")).define("darken", ["d3"], _darken);
|
|
main.variable(observer()).define(["wrap_text_array"], _50);
|
|
main.variable(observer("wrap_text_nchar")).define("wrap_text_nchar", ["wrap_text_array"], _wrap_text_nchar);
|
|
main.variable(observer("wrap_text_array")).define("wrap_text_array", _wrap_text_array);
|
|
main.variable(observer("wrap_node_text")).define("wrap_node_text", _wrap_node_text);
|
|
return main;
|
|
}
|