bug nel grafo sintattico corretto
This commit is contained in:
parent
74893a4484
commit
146902f5cf
|
@ -18,7 +18,7 @@ FileAttachment("parsint_mod_completo_pre_new_4-2.csv").csv({typed: true})
|
|||
)}
|
||||
|
||||
function _links2(FileAttachment){return(
|
||||
FileAttachment("parsint_mod_completo_pergrafi_5 (5).csv").csv({typed: true})
|
||||
FileAttachment("parsint_mod_completo_pergrafi_5 (6).csv").csv({typed: true})
|
||||
)}
|
||||
|
||||
function _6(md){return(
|
||||
|
@ -29,13 +29,13 @@ function _types(links){return(
|
|||
Array.from(new Set(links.map(d => d.type)))
|
||||
)}
|
||||
|
||||
function _getFrasi(links2){return(
|
||||
function _getFrasi(links){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) {
|
||||
links.map(function(item) {
|
||||
var mysrc=item.source
|
||||
var mytgt=item.target
|
||||
var frase=item.frase
|
||||
|
@ -62,6 +62,62 @@ function getFrasi(nfrase){
|
|||
|
||||
}
|
||||
|
||||
})
|
||||
links.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 _getFrasi2(links2){return(
|
||||
function getFrasi2(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='';
|
||||
mytgt=mytgt.replace(' or vidi e',' or vidi - e').replace('ferma rupe ,', 'ferma rupe -,')
|
||||
if (!usednodes.includes(mysrc.replace(/\s/g, '')) && nfrase.includes(frase)){
|
||||
console.log('in src '+ mysrc+' ---- '+mytgt)
|
||||
mnode.push({
|
||||
"id" : mysrc,
|
||||
"type" : item.type,
|
||||
"rif" : item.frase,
|
||||
"visible": item.visibile.trim(),
|
||||
"s_type" : item.tipo
|
||||
});
|
||||
usednodes.push(mysrc.replace(/\s/g, ''))
|
||||
}
|
||||
if (!usednodes.includes(mytgt.replace(/\s/g, '').replace(/\n/g,'')) && nfrase.includes(frase)){
|
||||
console.log('in tgt '+ mytgt.replace(/\s/g, ''))
|
||||
//console.log('usednodes '+ usednodes)
|
||||
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
|
||||
|
@ -107,10 +163,14 @@ function _col(getColor,clauseType){return(
|
|||
getColor(clauseType)
|
||||
)}
|
||||
|
||||
function _data_frasi(getFrasi,listafrasi){return(
|
||||
function _data_frasi_1(getFrasi,listafrasi){return(
|
||||
getFrasi(listafrasi)
|
||||
)}
|
||||
|
||||
function _data_frasi(getFrasi2,listafrasi){return(
|
||||
getFrasi2(listafrasi)
|
||||
)}
|
||||
|
||||
function _sentenceTypes(data_frasi){return(
|
||||
data_frasi.nodes.slice(1).map(function(d){return d.s_type})
|
||||
)}
|
||||
|
@ -506,7 +566,7 @@ function _clauseFunctions(){return(
|
|||
}
|
||||
)}
|
||||
|
||||
function _23(md){return(
|
||||
function _25(md){return(
|
||||
md`#### Creating SVG`
|
||||
)}
|
||||
|
||||
|
@ -526,7 +586,7 @@ function _width(){return(
|
|||
760
|
||||
)}
|
||||
|
||||
function _28(md){return(
|
||||
function _30(md){return(
|
||||
md`#### Create y scale function`
|
||||
)}
|
||||
|
||||
|
@ -580,12 +640,12 @@ function _maptypestopalette(){return(
|
|||
"coord V": 13, "pcoord I": 15, "subord VII": 8}
|
||||
)}
|
||||
|
||||
function _38(md){return(
|
||||
function _40(md){return(
|
||||
md`## Struttura del periodo`
|
||||
)}
|
||||
|
||||
function _lisid(){return(
|
||||
'1_19_33'
|
||||
'3_13_1'
|
||||
)}
|
||||
|
||||
function* _periodoscritto(html,periodo)
|
||||
|
@ -611,7 +671,7 @@ function* _periodoscritto(html,periodo)
|
|||
}
|
||||
|
||||
|
||||
function _42(swatches,sentenceFunctionsColor){return(
|
||||
function _44(swatches,sentenceFunctionsColor){return(
|
||||
swatches({
|
||||
color: sentenceFunctionsColor
|
||||
})
|
||||
|
@ -783,7 +843,21 @@ function _sentenceStructArcs_new(d3,DOM,width,margin,sentenceheight,lisid,wrap_t
|
|||
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")
|
||||
|
@ -794,6 +868,16 @@ function _sentenceStructArcs_new(d3,DOM,width,margin,sentenceheight,lisid,wrap_t
|
|||
//.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)
|
||||
|
||||
|
||||
function ypostxt(label){
|
||||
|
@ -959,7 +1043,7 @@ function _sentenceStructArcs_new(d3,DOM,width,margin,sentenceheight,lisid,wrap_t
|
|||
}
|
||||
|
||||
|
||||
function _46(md){return(
|
||||
function _48(md){return(
|
||||
md`### Utility`
|
||||
)}
|
||||
|
||||
|
@ -1063,8 +1147,8 @@ export default function define(runtime, observer) {
|
|||
const main = runtime.module();
|
||||
function toString() { return this.url; }
|
||||
const fileAttachments = new Map([
|
||||
["parsint_mod_completo_pergrafi_5 (5).csv", {url: new URL("./files/cd4d27cfd8fe6443ce2f4a749a30843ac23b298c3c3562a27c40495eed8e592a9759601690e17d7b9f10089dbd8f4afab1d35a8f231f42eb8eed47925d47e1c9.csv", import.meta.url), mimeType: "text/csv", toString}],
|
||||
["parsint_mod_completo_pre_new_4-2.csv", {url: new URL("./files/84a55acbf5319de5bc4bbe252a8fe3a7597656062d555a773767aca26cb1509ab8edf33275b0653575d3784d04c73fe610e3d5f66db6de5e72506642c558d4ad.csv", import.meta.url), mimeType: "text/csv", toString}]
|
||||
["parsint_mod_completo_pre_new_4-2.csv", {url: new URL("./files/84a55acbf5319de5bc4bbe252a8fe3a7597656062d555a773767aca26cb1509ab8edf33275b0653575d3784d04c73fe610e3d5f66db6de5e72506642c558d4ad.csv", import.meta.url), mimeType: "text/csv", toString}],
|
||||
["parsint_mod_completo_pergrafi_5 (6).csv", {url: new URL("./files/cd4d27cfd8fe6443ce2f4a749a30843ac23b298c3c3562a27c40495eed8e592a9759601690e17d7b9f10089dbd8f4afab1d35a8f231f42eb8eed47925d47e1c9.csv", import.meta.url), mimeType: "text/csv", toString}]
|
||||
]);
|
||||
main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
|
||||
main.variable(observer()).define(["md"], _1);
|
||||
|
@ -1074,13 +1158,15 @@ export default function define(runtime, observer) {
|
|||
main.variable(observer("links2")).define("links2", ["FileAttachment"], _links2);
|
||||
main.variable(observer()).define(["md"], _6);
|
||||
main.variable(observer("types")).define("types", ["links"], _types);
|
||||
main.variable(observer("getFrasi")).define("getFrasi", ["links2"], _getFrasi);
|
||||
main.variable(observer("getFrasi")).define("getFrasi", ["links"], _getFrasi);
|
||||
main.variable(observer("getFrasi2")).define("getFrasi2", ["links2"], _getFrasi2);
|
||||
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("data_frasi_1")).define("data_frasi_1", ["getFrasi","listafrasi"], _data_frasi_1);
|
||||
main.variable(observer("data_frasi")).define("data_frasi", ["getFrasi2","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);
|
||||
|
@ -1089,12 +1175,12 @@ export default function define(runtime, observer) {
|
|||
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()).define(["md"], _25);
|
||||
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()).define(["md"], _30);
|
||||
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);
|
||||
|
@ -1104,16 +1190,16 @@ export default function define(runtime, observer) {
|
|||
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()).define(["md"], _40);
|
||||
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()).define(["swatches","sentenceFunctionsColor"], _44);
|
||||
main.variable(observer("periodo")).define("periodo", ["data_frasi"], _periodo);
|
||||
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","wrap_text_array","yScale","data_frasi","clauseFunctions","getTypes","idToNode","colorssp","maptypestopalette","sentenceFunctionsColor2","darken","wrap_text_nchar"], _sentenceStructArcs_new);
|
||||
main.variable(observer()).define(["md"], _46);
|
||||
main.variable(observer()).define(["md"], _48);
|
||||
main.variable(observer("darken")).define("darken", ["d3"], _darken);
|
||||
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);
|
|
@ -1,6 +1,6 @@
|
|||
# Commedia: Arc Diagram per marcatura sintattica
|
||||
# Commedia: Arc Diagram per marcatura sintattica (current)
|
||||
|
||||
https://observablehq.com/@cesare/commarcdiag@1333
|
||||
https://observablehq.com/d/673687d66622d33f@1401
|
||||
|
||||
View this notebook in your browser by running a web server in this folder. For
|
||||
example:
|
||||
|
@ -14,14 +14,14 @@ import this module directly into your application. To npm install:
|
|||
|
||||
~~~sh
|
||||
npm install @observablehq/runtime@5
|
||||
npm install https://api.observablehq.com/@cesare/commarcdiag@1333.tgz?v=3
|
||||
npm install https://api.observablehq.com/d/673687d66622d33f@1401.tgz?v=3
|
||||
~~~
|
||||
|
||||
Then, import your notebook and the runtime as:
|
||||
|
||||
~~~js
|
||||
import {Runtime, Inspector} from "@observablehq/runtime";
|
||||
import define from "@cesare/commarcdiag";
|
||||
import define from "673687d66622d33f";
|
||||
~~~
|
||||
|
||||
To log the value of the cell named “foo”:
|
||||
|
|
|
@ -1 +1 @@
|
|||
export {default} from "./673687d66622d33f@1354.js";
|
||||
export {default} from "./673687d66622d33f@1401.js";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "673687d66622d33f",
|
||||
"main": "673687d66622d33f@1354.js",
|
||||
"version": "1354.0.0",
|
||||
"main": "673687d66622d33f@1401.js",
|
||||
"version": "1401.0.0",
|
||||
"homepage": "https://observablehq.com/d/673687d66622d33f",
|
||||
"author": {
|
||||
"name": "cesare concordia",
|
||||
|
|
Loading…
Reference in New Issue