From 58bbc9f16e0e8b7295c9b727c7147dbeb52c1d7a Mon Sep 17 00:00:00 2001 From: Hai Tran Date: Thu, 2 Mar 2017 10:26:11 -0600 Subject: [PATCH 1/7] Initial staircase Nothing yet --- js/staircase.js | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ js/step.js | 7 +++++ 2 files changed, 86 insertions(+) create mode 100644 js/staircase.js create mode 100644 js/step.js diff --git a/js/staircase.js b/js/staircase.js new file mode 100644 index 0000000..310d346 --- /dev/null +++ b/js/staircase.js @@ -0,0 +1,79 @@ +class Staircase { + constructor() { + this.isOpen = false; + + // references to dom elements + this.drawing = document.getElementById('drawing'); + this.div = document.getElementById('graph') || + document.createElement('div'); + this.div.id = "graph"; + document.body.appendChild(this.div); + + // dimensions & properties + this.bounds = this.div.getBoundingClientRect(); + + // d3 dom references + this.svg = d3.select('#graph').append('svg') + .attr('width', this.bounds.width) + .attr('height', this.bounds.height); + this.g = this.svg.append('g') + .attr('transform','translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'); + this.links = this.g.append('g') + .attr('class','links'); + this.nodes = this.g.append('g') + .attr('class','nodes'); + + + // My poor attempt to do something. SOMETHING... + console.log(this); + this.g.append("circle") + .attr("cx", 30) + .attr("cy", 30) + .attr("r", 20); + + + } + + open() { + this.isOpen = true; + this.drawing.classList.add('split-left'); + this.div.classList.add('split-right'); + this.resize(); + } + + close() { + if (this.isOpen) { + this.isOpen = false; + this.drawing.classList.remove('split-left'); + this.div.classList.remove('split-right'); + } + } + + resize() { + this.bounds = this.div.getBoundingClientRect(); + this.svg + .attr('width', this.bounds.width) + .attr('height', this.bounds.height); + + this.g + .attr('transform','translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'); + + if (!this.nodes.selectAll('.node-group').empty()) { + this.updateGraph(); + } + console.log(this); + } + + graph(words) { + + } + + drawNodes() { + + } + + drawLinks() { + + } + +}//end class GraphLayout diff --git a/js/step.js b/js/step.js new file mode 100644 index 0000000..f410d46 --- /dev/null +++ b/js/step.js @@ -0,0 +1,7 @@ +// A part of the staircase. Each step is a square which contains either +// a word or an excerpt of a sentence/paragraph. +class Step { + constructor() { + //this.size + } +} \ No newline at end of file From 7d8c652f2311462a2d5e13c782fb63f09e4684ee Mon Sep 17 00:00:00 2001 From: Hai Tran Date: Fri, 10 Mar 2017 16:23:40 -0600 Subject: [PATCH 2/7] First progress Words & Labels are on. Still unable to make split-right scrollable --- index.html | 21 ++++- js/staircase.js | 245 ++++++++++++++++++++++++++++++++++++++++++++---- js/step.js | 7 -- 3 files changed, 245 insertions(+), 28 deletions(-) delete mode 100644 js/step.js diff --git a/index.html b/index.html index e8b5f63..4d6cfa7 100644 --- a/index.html +++ b/index.html @@ -42,8 +42,10 @@ } .split-left {width:66.5%; overflow:hidden;} -.split-right {transform:translateX(0) !important;} +.split-right {transform:translateX(0) !important; overflow: auto;} + .node { cursor: pointer; } + #graph { transition:transform 200ms ease; transform:translateX(100%); @@ -53,6 +55,7 @@ position:fixed; top:0; right:0; + overflow: auto; } @@ -78,6 +81,7 @@ + @@ -523,7 +527,8 @@ /* init graph layout object */ - var Panel = new GraphLayout(); + var Panel = new Staircase(); + //var Panel = new GraphLayout(); var prevWidth = svgWidth; function svgResize() { @@ -570,7 +575,17 @@ Panel.open(); svgResize(); } - Panel.graph(wordObjs.filter(word => word.isSelected)); + + //Panel.graph(wordObjs.filter(word => word.isSelected)); + + // Staircase + // When one or more words are selected, how to capture the change? + // Should I do like below -- draw a normal graph (with full list + // of words) then handle the selected words after that? + Panel.graph(wordObjs, linkObjs); + var selectedWords = wordObjs.filter(word => word.isSelected); + Panel.updateGraph(selectedWords); + break; default: break; diff --git a/js/staircase.js b/js/staircase.js index 310d346..f575687 100644 --- a/js/staircase.js +++ b/js/staircase.js @@ -10,27 +10,67 @@ class Staircase { document.body.appendChild(this.div); // dimensions & properties - this.bounds = this.div.getBoundingClientRect(); + //this.bounds = this.div.getBoundingClientRect(); + var boundingClientRect = this.div.getBoundingClientRect(); + + // Extend the viewport + this.bounds = { + top: boundingClientRect.top, + bottom: boundingClientRect.bottom, + left: boundingClientRect.left, + right: boundingClientRect.right, + width: boundingClientRect.width * 5, + height: boundingClientRect.height * 5 + }; // d3 dom references - this.svg = d3.select('#graph').append('svg') + this.svg = d3.select('#graph') + .append('svg') .attr('width', this.bounds.width) - .attr('height', this.bounds.height); - this.g = this.svg.append('g') - .attr('transform','translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'); + .attr('height', this.bounds.height) + .style("overflow", "scroll") + ; + + // zoom + var zoom = d3.zoom().scaleExtent([1, 5]) + //.translateExtent([[0, -100], [this.bounds.width + 90, this.bounds.height + 100]]) + ; + + this.g = this.svg.append('g') + .attr('transform', 'translate(' + 10 + ',' + 10 + ')') + .call(zoom) + ; + this.links = this.g.append('g') - .attr('class','links'); + .attr('class','links') + ; + this.nodes = this.g.append('g') - .attr('class','nodes'); + .attr('class','nodes') + ; + zoom.on("zoom", function () { + //this.svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); + }); - // My poor attempt to do something. SOMETHING... - console.log(this); - this.g.append("circle") - .attr("cx", 30) - .attr("cy", 30) - .attr("r", 20); + // Tree-structured data, stored as a four dimensional array. + // I wish the dataset would support four levels: document, paragraph, + // sentence, and word. Since the first two are not available, + // we just set them to zero. + this.data = new Array(); + + // the box of each sentence only display the first few words + this.excerptSize = 3; + this.excerptMaxLength = 0; + + this.wordLength = new Array(); + this.wordMaxLength = 0; + + // Margin (top and left) for a word in a box + this.margin = 20; + // All steps that create this staircase + this.steps = new Array(); } @@ -55,25 +95,194 @@ class Staircase { .attr('width', this.bounds.width) .attr('height', this.bounds.height); - this.g - .attr('transform','translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'); + // Err... I don't think the starcase needs a translate at the beginning + //this.g + // .attr('transform','translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'); if (!this.nodes.selectAll('.node-group').empty()) { this.updateGraph(); } - console.log(this); } - graph(words) { + graph(wordObjs, linkObjs) { + // generate a tree structure from the given list of words + this.generateData(wordObjs); + + var maxLength = this.getMaxLength(); + this.wordMaxLength = maxLength[0]; + this.excerptMaxLength = maxLength[1]; + + // draw nodes + this.drawNodes(); + + // draw links + this.drawLinks(); + + // set force simulation + this.updateGraph([]); + } + + // Create a tree from given data + // This tree has two levels: sentence & word. + // I wish the dataset supported up to four levels: document, paragraph, + // sentence, and word. + generateData(words) { + var idx = 0; + var docId = 0; + var parId = 0; + var senId = 0; + var wrdId = 0; + + // initiate a 4-dimensional array. + // this.data[0][1][2][3] means the 4th word in the 3rd sentence of + // the 2nd paragraph in the 1st document + this.data = new Array(new Array(new Array(new Array()))); + + while (idx < words.length) { + // If there is a period before this word, move to a new sentence + if (wrdId > 0 && words[idx - 1].val === ".") { + senId++; + this.data[docId][parId][senId] = new Array(); + wrdId = 0; + } + + this.data[docId][parId][senId][wrdId] = { + val: words[idx].val, + tag: words[idx].data.syntaxData.tag + }; + + wrdId++; + idx++; + } + } + + // get lengths of the longest word and the longest sentence excerpt + getMaxLength() { + var lengthWord = 0; + var lengthExcerpt = 0; + + for (var docId = 0; docId < this.data.length; docId++) { + for (var parId = 0; parId < this.data[docId].length; parId++) { + for (var senId = 0; senId < this.data[docId][parId].length; senId++) { + + // excerpt + if (this.data[docId][parId][senId].length >= 3) { + var excerpt = this.data[docId][parId][senId][0] + + " " + this.data[docId][parId][senId][1] + + " " + this.data[docId][parId][senId][2]; + var excerptText = this.g.append("text") + .attr("x", 0) + .attr("y", 0) + .text(excerpt) + ; + if (excerptText.node().getBBox().width > lengthExcerpt) + lengthExcerpt = excerptText.node().getBBox().width; + + this.g.selectAll("text").remove(); + } + + // word + for (var wrdId = 0; wrdId < this.data[docId][parId][senId].length; wrdId++) { + var text = this.g.append("text") + .attr("x", 0) + .attr("y", 0) + .text(this.data[docId][parId][senId][wrdId].val) + .attr("style", "font-size: 8; font-family: Helvetica, sans-serif") + ; + + if (text.node().getBBox().width > lengthWord) + lengthWord = text.node().getBBox().width; + + this.wordLength.push({ + width: text.node().getBBox().width, + height: text.node().getBBox().height + }); + this.g.selectAll("text").remove(); + } + } + } + } + + return [lengthWord, lengthExcerpt]; } drawNodes() { + var wordLoc = 0; + var loc_sen = 0; + + for (var docId = 0; docId < this.data.length; docId++) { + for (var parId = 0; parId < this.data[docId].length; parId++) { + for (var senId = 0; senId < this.data[docId][parId].length; senId++) { + for (var wrdId = 0; wrdId < this.data[docId][parId][senId].length; wrdId++) { + + var rect = this.g.append("rect") + .attr("x", wordLoc) + .attr("y", wordLoc) + .attr("width", this.wordMaxLength + this.margin) + .attr("height", this.wordMaxLength + this.margin) + .style("stroke", "black") + .style("stroke-width", 1) + .style("fill", "none") + ; + + var text = this.g.append("text") + .attr("x", wordLoc + this.margin) + .attr("y", wordLoc + this.margin) + .text(this.data[docId][parId][senId][wrdId].val) + .attr("style", "font-size: 8; font-family: Helvetica, sans-serif") + ; + + if (this.data[docId][parId][senId][wrdId].tag.length > 0) { + this.g.append("rect") + .attr("x", wordLoc + (this.wordMaxLength + this.margin)/2 ) + .attr("y", wordLoc + this.wordMaxLength - this.margin) + .attr("width", (this.wordMaxLength + this.margin)/2 ) + .attr("height", this.margin) + .style("fill", "red") + ; + var label = this.g.append("text") + .attr("x", wordLoc + this.wordMaxLength) + .attr("y", wordLoc + this.wordMaxLength) + .style("text-anchor","end") + //.attr("dominant-baseline","central") + .attr("fill","white") + .text(this.data[docId][parId][senId][wrdId].tag) + ; + } + + wordLoc += this.wordMaxLength + this.margin; + } + } + } + } } drawLinks() { } -}//end class GraphLayout + updateGraph(selectedWords) { + /* + console.log(this); + this.g.append("circle") + .attr("cx", this.steps[0].position.x) + .attr("cy", this.steps[0].position.y) + .attr("r", this.steps[0].size); + */ + } + +}//end class Staircase + + + +// A part of the staircase. Each step is a square which contains either +// a word or an excerpt of a sentence/paragraph. +class Step { + constructor() { + this.size = 20; + this.position = {x: 20, y: 20}; + this.style = {strokeColor: "black", strokeWidth: 1, fill: "none"}; + } +}// end class Step diff --git a/js/step.js b/js/step.js deleted file mode 100644 index f410d46..0000000 --- a/js/step.js +++ /dev/null @@ -1,7 +0,0 @@ -// A part of the staircase. Each step is a square which contains either -// a word or an excerpt of a sentence/paragraph. -class Step { - constructor() { - //this.size - } -} \ No newline at end of file From 6201363a2a2f1c0d5d4f63e4c0274f25fe328821 Mon Sep 17 00:00:00 2001 From: Hai Tran Date: Tue, 9 May 2017 14:46:51 -0500 Subject: [PATCH 3/7] Handle empty dataset --- js/staircase.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/js/staircase.js b/js/staircase.js index f575687..975abc1 100644 --- a/js/staircase.js +++ b/js/staircase.js @@ -10,7 +10,6 @@ class Staircase { document.body.appendChild(this.div); // dimensions & properties - //this.bounds = this.div.getBoundingClientRect(); var boundingClientRect = this.div.getBoundingClientRect(); // Extend the viewport @@ -19,18 +18,23 @@ class Staircase { bottom: boundingClientRect.bottom, left: boundingClientRect.left, right: boundingClientRect.right, - width: boundingClientRect.width * 5, - height: boundingClientRect.height * 5 + width: boundingClientRect.width, + height: boundingClientRect.height }; // d3 dom references this.svg = d3.select('#graph') .append('svg') - .attr('width', this.bounds.width) - .attr('height', this.bounds.height) - .style("overflow", "scroll") + .attr('width', this.bounds.width*2) + .attr('height', this.bounds.height*2) + //.attr("preserveAspectRatio", "xMinYMin meet") + //.attr("viewBox", "0 0 " + this.bounds.width + " " + this.bounds.height) + .style("overflow", "auto") ; + console.log(this.bounds); + console.log(this.svg); + // zoom var zoom = d3.zoom().scaleExtent([1, 5]) //.translateExtent([[0, -100], [this.bounds.width + 90, this.bounds.height + 100]]) @@ -66,8 +70,10 @@ class Staircase { this.wordLength = new Array(); this.wordMaxLength = 0; + this.fontSize = 8; + // Margin (top and left) for a word in a box - this.margin = 20; + this.margin = this.fontSize*1.5; // All steps that create this staircase this.steps = new Array(); @@ -105,21 +111,23 @@ class Staircase { } graph(wordObjs, linkObjs) { - // generate a tree structure from the given list of words - this.generateData(wordObjs); + if (this.data.length == 0) { + // generate a tree structure from the given list of words + this.generateData(wordObjs); - var maxLength = this.getMaxLength(); - this.wordMaxLength = maxLength[0]; - this.excerptMaxLength = maxLength[1]; + var maxLength = this.getMaxLength(); + this.wordMaxLength = maxLength[0]; + this.excerptMaxLength = maxLength[1]; - // draw nodes - this.drawNodes(); + // draw nodes + this.drawNodes(); - // draw links - this.drawLinks(); + // draw links + this.drawLinks(); - // set force simulation - this.updateGraph([]); + // set force simulation + this.updateGraph([]); + } } // Create a tree from given data From 2d134d5ce051e7560401e5bcb2aa2f4595a45c1d Mon Sep 17 00:00:00 2001 From: Hai Tran Date: Wed, 10 May 2017 16:51:34 -0500 Subject: [PATCH 4/7] Merge with master --- data/data1.json | 346 ++++ data/data2.json | 346 ++++ data/data3.json | 1898 +++++++++++++++++++ data/data4.json | 4510 +++++++++++++++++++++++++++++++++++++++++++++ index.html | 557 +----- js/GraphLayout.js | 248 +-- js/annotate.js | 24 +- js/config.js | 40 + js/interact.js | 111 +- js/parser.js | 100 + js/render.js | 98 +- js/staircase.js | 296 --- js/style.js | 8 +- js/utils.js | 4 +- test.html | 448 +++++ 15 files changed, 7915 insertions(+), 1119 deletions(-) create mode 100644 data/data1.json create mode 100644 data/data2.json create mode 100644 data/data3.json create mode 100644 data/data4.json create mode 100644 js/config.js create mode 100644 js/parser.js delete mode 100644 js/staircase.js create mode 100644 test.html diff --git a/data/data1.json b/data/data1.json new file mode 100644 index 0000000..0cbaa5e --- /dev/null +++ b/data/data1.json @@ -0,0 +1,346 @@ +{ + "eventData": { + "comments": [ + [ + "R1", + "FoundByRule", + "Phosphorylation_syntax_1a_noun + toRelationMention" + ], + [ + "E3", + "FoundByRule", + "Negative_regulation_syntax_1_verb" + ], + [ + "T3", + "FoundByRule", + "ner-family-entities" + ], + [ + "T4", + "FoundByRule", + "ner-family-entities" + ], + [ + "T1", + "FoundByRule", + "ner-family-entities" + ], + [ + "E1", + "FoundByRule", + "Phosphorylation_syntax_1a_noun" + ], + [ + "E2", + "FoundByRule", + "Ubiquitination_syntax_1a_noun" + ] + ], + "entities": [ + [ + "T1", + "Family", + [[ + "65", + "69" + ]] + ], + [ + "T3", + "Family", + [[ + "22", + "25" + ]] + ], + [ + "T4", + "Family", + [[ + "58", + "61" + ]] + ] + ], + "attributes": [], + "text": "The ubiquitination of RAS inhibits the phosphorylation of MEK by SMAD.", + "relations": [[ + "R1", + "Positive_regulation", + [ + [ + "Controlled", + "E1" + ], + [ + "Controller", + "T1" + ] + ] + ]], + "triggers": [ + [ + "T5", + "Phosphorylation", + [[ + "39", + "54" + ]] + ], + [ + "T6", + "Ubiquitination", + [[ + "4", + "18" + ]] + ], + [ + "T2", + "Negative_regulation", + [[ + "26", + "34" + ]] + ] + ], + "events": [ + [ + "E1", + "T5", + [[ + "Theme", + "T4" + ]] + ], + [ + "E2", + "T6", + [[ + "Theme", + "T3" + ]] + ], + [ + "E3", + "T2", + [ + [ + "Controlled", + "E1" + ], + [ + "Controller", + "E2" + ] + ] + ] + ] + }, + "syntaxData": { + "comments": [], + "entities": [ + [ + "T1", + "IN", + [[ + "19", + "21" + ]] + ], + [ + "T2", + "DT", + [[ + "0", + "3" + ]] + ], + [ + "T3", + "NN", + [[ + "65", + "69" + ]] + ], + [ + "T4", + "IN", + [[ + "62", + "64" + ]] + ], + [ + "T5", + "IN", + [[ + "55", + "57" + ]] + ], + [ + "T6", + "NN", + [[ + "22", + "25" + ]] + ], + [ + "T7", + "DT", + [[ + "35", + "38" + ]] + ], + [ + "T8", + "NN", + [[ + "58", + "61" + ]] + ], + [ + "T9", + "VBZ", + [[ + "26", + "34" + ]] + ], + [ + "T10", + ".", + [[ + "69", + "70" + ]] + ], + [ + "T11", + "NN", + [[ + "4", + "18" + ]] + ], + [ + "T12", + "NN", + [[ + "39", + "54" + ]] + ] + ], + "attributes": [], + "text": "The ubiquitination of RAS inhibits the phosphorylation of MEK by SMAD.", + "relations": [ + [ + "R1", + "det", + [ + [ + "governor", + "T11" + ], + [ + "dependent", + "T2" + ] + ] + ], + [ + "R2", + "prep_of", + [ + [ + "governor", + "T11" + ], + [ + "dependent", + "T6" + ] + ] + ], + [ + "R3", + "nsubj", + [ + [ + "governor", + "T9" + ], + [ + "dependent", + "T11" + ] + ] + ], + [ + "R4", + "dobj", + [ + [ + "governor", + "T9" + ], + [ + "dependent", + "T12" + ] + ] + ], + [ + "R5", + "prep_by", + [ + [ + "governor", + "T9" + ], + [ + "dependent", + "T3" + ] + ] + ], + [ + "R6", + "det", + [ + [ + "governor", + "T12" + ], + [ + "dependent", + "T7" + ] + ] + ], + [ + "R7", + "prep_of", + [ + [ + "governor", + "T12" + ], + [ + "dependent", + "T8" + ] + ] + ] + ], + "triggers": [], + "events": [] + } +} \ No newline at end of file diff --git a/data/data2.json b/data/data2.json new file mode 100644 index 0000000..82040a0 --- /dev/null +++ b/data/data2.json @@ -0,0 +1,346 @@ +{ + "eventData": { + "comments": [ + [ + "E3", + "FoundByRule", + "Positive_regulation_syntax_1_verb" + ], + [ + "R1", + "FoundByRule", + "Phosphorylation_syntax_1a_noun + toRelationMention" + ], + [ + "T3", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T2", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T4", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "E1", + "FoundByRule", + "Ubiquitination_syntax_1a_noun" + ], + [ + "E2", + "FoundByRule", + "Phosphorylation_syntax_1a_noun" + ] + ], + "entities": [ + [ + "T2", + "Gene_or_gene_product", + [[ + "31", + "34" + ]] + ], + [ + "T3", + "Gene_or_gene_product", + [[ + "23", + "27" + ]] + ], + [ + "T4", + "Gene_or_gene_product", + [[ + "66", + "69" + ]] + ] + ], + "attributes": [], + "text": "The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53.", + "relations": [[ + "R1", + "Positive_regulation", + [ + [ + "Controlled", + "E2" + ], + [ + "Controller", + "T2" + ] + ] + ]], + "triggers": [ + [ + "T5", + "Ubiquitination", + [[ + "48", + "62" + ]] + ], + [ + "T6", + "Phosphorylation", + [[ + "4", + "19" + ]] + ], + [ + "T1", + "Positive_regulation", + [[ + "35", + "43" + ]] + ] + ], + "events": [ + [ + "E1", + "T5", + [[ + "Theme", + "T4" + ]] + ], + [ + "E2", + "T6", + [[ + "Theme", + "T3" + ]] + ], + [ + "E3", + "T1", + [ + [ + "Controlled", + "E1" + ], + [ + "Controller", + "E2" + ] + ] + ] + ] + }, + "syntaxData": { + "comments": [], + "entities": [ + [ + "T1", + "IN", + [[ + "20", + "22" + ]] + ], + [ + "T2", + "DT", + [[ + "0", + "3" + ]] + ], + [ + "T3", + "NN", + [[ + "66", + "69" + ]] + ], + [ + "T4", + "IN", + [[ + "63", + "65" + ]] + ], + [ + "T5", + "DT", + [[ + "44", + "47" + ]] + ], + [ + "T6", + "NN", + [[ + "23", + "27" + ]] + ], + [ + "T7", + "NN", + [[ + "31", + "34" + ]] + ], + [ + "T8", + "NN", + [[ + "48", + "62" + ]] + ], + [ + "T9", + "IN", + [[ + "28", + "30" + ]] + ], + [ + "T10", + ".", + [[ + "69", + "70" + ]] + ], + [ + "T11", + "NN", + [[ + "4", + "19" + ]] + ], + [ + "T12", + "VBZ", + [[ + "35", + "43" + ]] + ] + ], + "attributes": [], + "text": "The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53.", + "relations": [ + [ + "R1", + "det", + [ + [ + "governor", + "T11" + ], + [ + "dependent", + "T2" + ] + ] + ], + [ + "R2", + "prep_of", + [ + [ + "governor", + "T11" + ], + [ + "dependent", + "T6" + ] + ] + ], + [ + "R3", + "prep_by", + [ + [ + "governor", + "T6" + ], + [ + "dependent", + "T7" + ] + ] + ], + [ + "R4", + "nsubj", + [ + [ + "governor", + "T12" + ], + [ + "dependent", + "T11" + ] + ] + ], + [ + "R5", + "dobj", + [ + [ + "governor", + "T12" + ], + [ + "dependent", + "T8" + ] + ] + ], + [ + "R6", + "det", + [ + [ + "governor", + "T8" + ], + [ + "dependent", + "T5" + ] + ] + ], + [ + "R7", + "prep_of", + [ + [ + "governor", + "T8" + ], + [ + "dependent", + "T3" + ] + ] + ] + ], + "triggers": [], + "events": [] + } +} \ No newline at end of file diff --git a/data/data3.json b/data/data3.json new file mode 100644 index 0000000..a7a192c --- /dev/null +++ b/data/data3.json @@ -0,0 +1,1898 @@ +{ + "eventData": { + "comments": [ + [ + "R1", + "FoundByRule", + "Phosphorylation_syntax_1a_verb + toRelationMention, pronominalMatch" + ], + [ + "R2", + "FoundByRule", + "Phosphorylation_syntax_1a_verb + toRelationMention" + ], + [ + "T3", + "FoundByRule", + "ner-family-entities" + ], + [ + "T4", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T5", + "FoundByRule", + "PRP" + ], + [ + "T6", + "FoundByRule", + "ner-family-entities" + ], + [ + "T7", + "FoundByRule", + "PRP" + ], + [ + "T8", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T9", + "FoundByRule", + "ner-family-entities" + ], + [ + "T10", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T11", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T12", + "FoundByRule", + "ner-family-entities" + ], + [ + "T13", + "FoundByRule", + "PRP" + ], + [ + "T14", + "FoundByRule", + "ner-family-entities" + ], + [ + "T15", + "FoundByRule", + "ner-family-entities" + ], + [ + "T1", + "FoundByRule", + "PRP" + ], + [ + "T16", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T17", + "FoundByRule", + "ner-family-entities" + ], + [ + "T18", + "FoundByRule", + "ner-family-entities" + ], + [ + "T2", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T19", + "FoundByRule", + "PRP" + ], + [ + "E3", + "FoundByRule", + "Ubiquitination_token_3_noun, pronominalMatch" + ], + [ + "E1", + "FoundByRule", + "Phosphorylation_syntax_1a_verb" + ], + [ + "E4", + "FoundByRule", + "binding1b, pronominalMatch" + ], + [ + "E5", + "FoundByRule", + "binding_token_1, pronominalMatch" + ], + [ + "E6", + "FoundByRule", + "Ubiquitination_syntax_4_noun" + ], + [ + "E2", + "FoundByRule", + "Phosphorylation_syntax_1a_verb, pronominalMatch" + ] + ], + "entities": [ + [ + "T1", + "Generic_entity", + [[ + "351", + "355" + ]] + ], + [ + "T2", + "Gene_or_gene_product", + [[ + "412", + "417" + ]] + ], + [ + "T3", + "Family", + [[ + "15", + "18" + ]] + ], + [ + "T4", + "Gene_or_gene_product", + [[ + "20", + "25" + ]] + ], + [ + "T5", + "Generic_entity", + [[ + "43", + "46" + ]] + ], + [ + "T6", + "Family", + [[ + "89", + "92" + ]] + ], + [ + "T7", + "Generic_entity", + [[ + "111", + "114" + ]] + ], + [ + "T8", + "Gene_or_gene_product", + [[ + "126", + "130" + ]] + ], + [ + "T9", + "Family", + [[ + "135", + "138" + ]] + ], + [ + "T10", + "Gene_or_gene_product", + [[ + "215", + "225" + ]] + ], + [ + "T11", + "Gene_or_gene_product", + [[ + "278", + "283" + ]] + ], + [ + "T12", + "Family", + [[ + "302", + "305" + ]] + ], + [ + "T13", + "Generic_entity", + [[ + "312", + "314" + ]] + ], + [ + "T14", + "Family", + [[ + "317", + "320" + ]] + ], + [ + "T15", + "Family", + [[ + "325", + "328" + ]] + ], + [ + "T16", + "Gene_or_gene_product", + [[ + "370", + "375" + ]] + ], + [ + "T17", + "Family", + [[ + "378", + "381" + ]] + ], + [ + "T18", + "Family", + [[ + "386", + "389" + ]] + ], + [ + "T19", + "Generic_entity", + [[ + "433", + "437" + ]] + ] + ], + "attributes": [], + "text": "Even more than Ras, ASPP2 is common, as is its ubiquitination.\r\nTo address the effect of Ras ubiquitination on its binding to PI3K and Raf family members, either total G12V-K-Ras or the ubiquitinated subfraction of G12V-K-Ras was immunoprecipitated.\r\nMuch work has been done on ASPP2. It is known that Ras binds it.\r\nRas and Mek are in proximity, and they phosphorylate ASPP2.\r\nRas and Mek are in proximity, and ASPP2 phosphorylates them.", + "relations": [ + [ + "R1", + "Positive_regulation", + [ + [ + "Controlled", + "E1" + ], + [ + "Controller", + "T1" + ] + ] + ], + [ + "R2", + "Positive_regulation", + [ + [ + "Controlled", + "E2" + ], + [ + "Controller", + "T2" + ] + ] + ] + ], + "triggers": [ + [ + "T21", + "Phosphorylation", + [[ + "356", + "369" + ]] + ], + [ + "T25", + "Phosphorylation", + [[ + "418", + "432" + ]] + ], + [ + "T20", + "Ubiquitination", + [[ + "47", + "61" + ]] + ], + [ + "T22", + "Binding", + [[ + "306", + "311" + ]] + ], + [ + "T23", + "Binding", + [[ + "115", + "122" + ]] + ], + [ + "T24", + "Ubiquitination", + [[ + "93", + "107" + ]] + ] + ], + "events": [ + [ + "E1", + "T21", + [[ + "Theme", + "T16" + ]] + ], + [ + "E2", + "T25", + [[ + "Theme", + "T19" + ]] + ], + [ + "E3", + "T20", + [[ + "Theme", + "T5" + ]] + ], + [ + "E4", + "T22", + [ + [ + "Theme", + "T12" + ], + [ + "Theme", + "T13" + ] + ] + ], + [ + "E5", + "T23", + [ + [ + "Theme", + "T7" + ], + [ + "Theme", + "T8" + ] + ] + ], + [ + "E6", + "T24", + [[ + "Theme", + "T6" + ]] + ] + ] + }, + "syntaxData": { + "comments": [], + "entities": [ + [ + "T1", + "CC", + [[ + "179", + "181" + ]] + ], + [ + "T2", + "PRP$", + [[ + "111", + "114" + ]] + ], + [ + "T3", + "IN", + [[ + "275", + "277" + ]] + ], + [ + "T4", + "NN", + [[ + "89", + "92" + ]] + ], + [ + "T5", + "NN", + [[ + "378", + "381" + ]] + ], + [ + "T6", + "DT", + [[ + "182", + "185" + ]] + ], + [ + "T7", + "IN", + [[ + "10", + "14" + ]] + ], + [ + "T8", + "RB", + [[ + "0", + "4" + ]] + ], + [ + "T9", + "NN", + [[ + "386", + "389" + ]] + ], + [ + "T10", + "CC", + [[ + "382", + "385" + ]] + ], + [ + "T11", + "NN", + [[ + "317", + "320" + ]] + ], + [ + "T12", + ".", + [[ + "248", + "249" + ]] + ], + [ + "T13", + "NN", + [[ + "370", + "375" + ]] + ], + [ + "T14", + "NN", + [[ + "302", + "305" + ]] + ], + [ + "T15", + "VBZ", + [[ + "40", + "42" + ]] + ], + [ + "T16", + "CC", + [[ + "347", + "350" + ]] + ], + [ + "T17", + "IN", + [[ + "212", + "214" + ]] + ], + [ + "T18", + "IN", + [[ + "37", + "39" + ]] + ], + [ + "T19", + ".", + [[ + "437", + "438" + ]] + ], + [ + "T20", + "VBZ", + [[ + "288", + "290" + ]] + ], + [ + "T21", + "CC", + [[ + "321", + "324" + ]] + ], + [ + "T22", + "VBZ", + [[ + "418", + "432" + ]] + ], + [ + "T23", + "JJ", + [[ + "162", + "167" + ]] + ], + [ + "T24", + "JJ", + [[ + "29", + "35" + ]] + ], + [ + "T25", + "JJ", + [[ + "251", + "255" + ]] + ], + [ + "T26", + "NN", + [[ + "15", + "18" + ]] + ], + [ + "T27", + "IN", + [[ + "333", + "335" + ]] + ], + [ + "T28", + "PRP", + [[ + "285", + "287" + ]] + ], + [ + "T29", + "PRP", + [[ + "433", + "437" + ]] + ], + [ + "T30", + "NN", + [[ + "93", + "107" + ]] + ], + [ + "T31", + "NN", + [[ + "126", + "130" + ]] + ], + [ + "T32", + "NN", + [[ + "20", + "25" + ]] + ], + [ + "T33", + "PRP", + [[ + "312", + "314" + ]] + ], + [ + "T34", + "NNS", + [[ + "168", + "178" + ]] + ], + [ + "T35", + "CC", + [[ + "131", + "134" + ]] + ], + [ + "T36", + "VB", + [[ + "67", + "74" + ]] + ], + [ + "T37", + "VBZ", + [[ + "306", + "311" + ]] + ], + [ + "T38", + "TO", + [[ + "123", + "125" + ]] + ], + [ + "T39", + ",", + [[ + "345", + "346" + ]] + ], + [ + "T40", + ".", + [[ + "375", + "376" + ]] + ], + [ + "T41", + "NN", + [[ + "115", + "122" + ]] + ], + [ + "T42", + "NN", + [[ + "215", + "225" + ]] + ], + [ + "T43", + "NN", + [[ + "336", + "345" + ]] + ], + [ + "T44", + "IN", + [[ + "86", + "88" + ]] + ], + [ + "T45", + "NN", + [[ + "278", + "283" + ]] + ], + [ + "T46", + ",", + [[ + "35", + "36" + ]] + ], + [ + "T47", + "VB", + [[ + "356", + "369" + ]] + ], + [ + "T48", + ",", + [[ + "18", + "19" + ]] + ], + [ + "T49", + "VBN", + [[ + "230", + "248" + ]] + ], + [ + "T50", + "CC", + [[ + "408", + "411" + ]] + ], + [ + "T51", + "IN", + [[ + "394", + "396" + ]] + ], + [ + "T52", + "VBN", + [[ + "291", + "296" + ]] + ], + [ + "T53", + ",", + [[ + "153", + "154" + ]] + ], + [ + "T54", + "NN", + [[ + "47", + "61" + ]] + ], + [ + "T55", + ".", + [[ + "61", + "62" + ]] + ], + [ + "T56", + "NN", + [[ + "79", + "85" + ]] + ], + [ + "T57", + "VBZ", + [[ + "261", + "264" + ]] + ], + [ + "T58", + "NN", + [[ + "397", + "406" + ]] + ], + [ + "T59", + "NNS", + [[ + "146", + "153" + ]] + ], + [ + "T60", + "PRP", + [[ + "351", + "355" + ]] + ], + [ + "T61", + ".", + [[ + "283", + "284" + ]] + ], + [ + "T62", + "NN", + [[ + "325", + "328" + ]] + ], + [ + "T63", + "VBN", + [[ + "270", + "274" + ]] + ], + [ + "T64", + "JJ", + [[ + "186", + "199" + ]] + ], + [ + "T65", + ".", + [[ + "314", + "315" + ]] + ], + [ + "T66", + "NN", + [[ + "139", + "145" + ]] + ], + [ + "T67", + "PRP$", + [[ + "43", + "46" + ]] + ], + [ + "T68", + "VBD", + [[ + "226", + "229" + ]] + ], + [ + "T69", + "JJR", + [[ + "5", + "9" + ]] + ], + [ + "T70", + "NN", + [[ + "200", + "211" + ]] + ], + [ + "T71", + "VBP", + [[ + "390", + "393" + ]] + ], + [ + "T72", + "CC", + [[ + "155", + "161" + ]] + ], + [ + "T73", + "NN", + [[ + "135", + "138" + ]] + ], + [ + "T74", + "NN", + [[ + "412", + "417" + ]] + ], + [ + "T75", + "IN", + [[ + "297", + "301" + ]] + ], + [ + "T76", + "IN", + [[ + "108", + "110" + ]] + ], + [ + "T77", + "VBN", + [[ + "265", + "269" + ]] + ], + [ + "T78", + "DT", + [[ + "75", + "78" + ]] + ], + [ + "T79", + "NN", + [[ + "256", + "260" + ]] + ], + [ + "T80", + "VBP", + [[ + "329", + "332" + ]] + ], + [ + "T81", + "TO", + [[ + "64", + "66" + ]] + ], + [ + "T82", + ",", + [[ + "406", + "407" + ]] + ], + [ + "T83", + "VBZ", + [[ + "26", + "28" + ]] + ] + ], + "attributes": [], + "text": "Even more than Ras, ASPP2 is common, as is its ubiquitination.\r\nTo address the effect of Ras ubiquitination on its binding to PI3K and Raf family members, either total G12V-K-Ras or the ubiquitinated subfraction of G12V-K-Ras was immunoprecipitated.\r\nMuch work has been done on ASPP2. It is known that Ras binds it.\r\nRas and Mek are in proximity, and they phosphorylate ASPP2.\r\nRas and Mek are in proximity, and ASPP2 phosphorylates them.", + "relations": [ + [ + "R1", + "advmod", + [ + [ + "governor", + "T69" + ], + [ + "dependent", + "T8" + ] + ] + ], + [ + "R2", + "prep_than", + [ + [ + "governor", + "T69" + ], + [ + "dependent", + "T26" + ] + ] + ], + [ + "R3", + "appos", + [ + [ + "governor", + "T26" + ], + [ + "dependent", + "T32" + ] + ] + ], + [ + "R4", + "nsubj", + [ + [ + "governor", + "T24" + ], + [ + "dependent", + "T69" + ] + ] + ], + [ + "R5", + "cop", + [ + [ + "governor", + "T24" + ], + [ + "dependent", + "T83" + ] + ] + ], + [ + "R6", + "advcl", + [ + [ + "governor", + "T24" + ], + [ + "dependent", + "T54" + ] + ] + ], + [ + "R7", + "mark", + [ + [ + "governor", + "T54" + ], + [ + "dependent", + "T18" + ] + ] + ], + [ + "R8", + "cop", + [ + [ + "governor", + "T54" + ], + [ + "dependent", + "T15" + ] + ] + ], + [ + "R9", + "poss", + [ + [ + "governor", + "T54" + ], + [ + "dependent", + "T67" + ] + ] + ], + [ + "R10", + "aux", + [ + [ + "governor", + "T36" + ], + [ + "dependent", + "T81" + ] + ] + ], + [ + "R11", + "dobj", + [ + [ + "governor", + "T36" + ], + [ + "dependent", + "T56" + ] + ] + ], + [ + "R12", + "prep_on", + [ + [ + "governor", + "T36" + ], + [ + "dependent", + "T41" + ] + ] + ], + [ + "R13", + "prep_to", + [ + [ + "governor", + "T36" + ], + [ + "dependent", + "T59" + ] + ] + ], + [ + "R14", + "det", + [ + [ + "governor", + "T56" + ], + [ + "dependent", + "T78" + ] + ] + ], + [ + "R15", + "prep_of", + [ + [ + "governor", + "T56" + ], + [ + "dependent", + "T30" + ] + ] + ], + [ + "R16", + "nn", + [ + [ + "governor", + "T30" + ], + [ + "dependent", + "T4" + ] + ] + ], + [ + "R17", + "poss", + [ + [ + "governor", + "T41" + ], + [ + "dependent", + "T2" + ] + ] + ], + [ + "R18", + "conj_and", + [ + [ + "governor", + "T31" + ], + [ + "dependent", + "T73" + ] + ] + ], + [ + "R19", + "nn", + [ + [ + "governor", + "T59" + ], + [ + "dependent", + "T31" + ] + ] + ], + [ + "R20", + "nn", + [ + [ + "governor", + "T59" + ], + [ + "dependent", + "T73" + ] + ] + ], + [ + "R21", + "nn", + [ + [ + "governor", + "T59" + ], + [ + "dependent", + "T66" + ] + ] + ], + [ + "R22", + "preconj", + [ + [ + "governor", + "T34" + ], + [ + "dependent", + "T72" + ] + ] + ], + [ + "R23", + "amod", + [ + [ + "governor", + "T34" + ], + [ + "dependent", + "T23" + ] + ] + ], + [ + "R24", + "conj_or", + [ + [ + "governor", + "T34" + ], + [ + "dependent", + "T70" + ] + ] + ], + [ + "R25", + "det", + [ + [ + "governor", + "T70" + ], + [ + "dependent", + "T6" + ] + ] + ], + [ + "R26", + "amod", + [ + [ + "governor", + "T70" + ], + [ + "dependent", + "T64" + ] + ] + ], + [ + "R27", + "prep_of", + [ + [ + "governor", + "T70" + ], + [ + "dependent", + "T42" + ] + ] + ], + [ + "R28", + "advcl", + [ + [ + "governor", + "T49" + ], + [ + "dependent", + "T36" + ] + ] + ], + [ + "R29", + "nsubjpass", + [ + [ + "governor", + "T49" + ], + [ + "dependent", + "T34" + ] + ] + ], + [ + "R30", + "nsubjpass", + [ + [ + "governor", + "T49" + ], + [ + "dependent", + "T70" + ] + ] + ], + [ + "R31", + "auxpass", + [ + [ + "governor", + "T49" + ], + [ + "dependent", + "T68" + ] + ] + ], + [ + "R32", + "amod", + [ + [ + "governor", + "T79" + ], + [ + "dependent", + "T25" + ] + ] + ], + [ + "R33", + "nsubjpass", + [ + [ + "governor", + "T63" + ], + [ + "dependent", + "T79" + ] + ] + ], + [ + "R34", + "aux", + [ + [ + "governor", + "T63" + ], + [ + "dependent", + "T57" + ] + ] + ], + [ + "R35", + "auxpass", + [ + [ + "governor", + "T63" + ], + [ + "dependent", + "T77" + ] + ] + ], + [ + "R36", + "prep_on", + [ + [ + "governor", + "T63" + ], + [ + "dependent", + "T45" + ] + ] + ], + [ + "R37", + "nsubjpass", + [ + [ + "governor", + "T52" + ], + [ + "dependent", + "T28" + ] + ] + ], + [ + "R38", + "auxpass", + [ + [ + "governor", + "T52" + ], + [ + "dependent", + "T20" + ] + ] + ], + [ + "R39", + "ccomp", + [ + [ + "governor", + "T52" + ], + [ + "dependent", + "T37" + ] + ] + ], + [ + "R40", + "mark", + [ + [ + "governor", + "T37" + ], + [ + "dependent", + "T75" + ] + ] + ], + [ + "R41", + "nsubj", + [ + [ + "governor", + "T37" + ], + [ + "dependent", + "T14" + ] + ] + ], + [ + "R42", + "dobj", + [ + [ + "governor", + "T37" + ], + [ + "dependent", + "T33" + ] + ] + ], + [ + "R43", + "conj_and", + [ + [ + "governor", + "T11" + ], + [ + "dependent", + "T62" + ] + ] + ], + [ + "R44", + "nsubj", + [ + [ + "governor", + "T80" + ], + [ + "dependent", + "T11" + ] + ] + ], + [ + "R45", + "nsubj", + [ + [ + "governor", + "T80" + ], + [ + "dependent", + "T62" + ] + ] + ], + [ + "R46", + "prep_in", + [ + [ + "governor", + "T80" + ], + [ + "dependent", + "T43" + ] + ] + ], + [ + "R47", + "conj_and", + [ + [ + "governor", + "T80" + ], + [ + "dependent", + "T47" + ] + ] + ], + [ + "R48", + "nsubj", + [ + [ + "governor", + "T47" + ], + [ + "dependent", + "T60" + ] + ] + ], + [ + "R49", + "dobj", + [ + [ + "governor", + "T47" + ], + [ + "dependent", + "T13" + ] + ] + ], + [ + "R50", + "conj_and", + [ + [ + "governor", + "T5" + ], + [ + "dependent", + "T9" + ] + ] + ], + [ + "R51", + "nsubj", + [ + [ + "governor", + "T71" + ], + [ + "dependent", + "T5" + ] + ] + ], + [ + "R52", + "nsubj", + [ + [ + "governor", + "T71" + ], + [ + "dependent", + "T9" + ] + ] + ], + [ + "R53", + "prep_in", + [ + [ + "governor", + "T71" + ], + [ + "dependent", + "T58" + ] + ] + ], + [ + "R54", + "conj_and", + [ + [ + "governor", + "T71" + ], + [ + "dependent", + "T22" + ] + ] + ], + [ + "R55", + "nsubj", + [ + [ + "governor", + "T22" + ], + [ + "dependent", + "T74" + ] + ] + ], + [ + "R56", + "dobj", + [ + [ + "governor", + "T22" + ], + [ + "dependent", + "T29" + ] + ] + ] + ], + "triggers": [], + "events": [] + } +} \ No newline at end of file diff --git a/data/data4.json b/data/data4.json new file mode 100644 index 0000000..e2c7aed --- /dev/null +++ b/data/data4.json @@ -0,0 +1,4510 @@ +{ + "eventData": { + "comments": [ + [ + "E2", + "FoundByRule", + "Positive_regulation_syntax_6_verb" + ], + [ + "E4", + "FoundByRule", + "Positive_regulation_syntax_6_verb" + ], + [ + "T3", + "FoundByRule", + "ner-family-entities" + ], + [ + "T4", + "FoundByRule", + "ner-family-entities" + ], + [ + "T5", + "FoundByRule", + "ner-family-entities" + ], + [ + "T6", + "FoundByRule", + "site_long" + ], + [ + "T7", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T8", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T9", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T10", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T11", + "FoundByRule", + "missing-location" + ], + [ + "T12", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T13", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T14", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T15", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T16", + "FoundByRule", + "ner-family-entities" + ], + [ + "T17", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T18", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T19", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T20", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T21", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T22", + "FoundByRule", + "site_long" + ], + [ + "T2", + "FoundByRule", + "ner-family-entities" + ], + [ + "T23", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T24", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T25", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T26", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T27", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T28", + "FoundByRule", + "ner-family-entities" + ], + [ + "T29", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T30", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T31", + "FoundByRule", + "ner-family-entities" + ], + [ + "T32", + "FoundByRule", + "site_long" + ], + [ + "T33", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T34", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "T35", + "FoundByRule", + "ner-gene_or_gene_product-entities" + ], + [ + "E5", + "FoundByRule", + "Phosphorylation_syntax_4_noun" + ], + [ + "E1", + "FoundByRule", + "Phosphorylation_syntax_4_noun" + ], + [ + "E3", + "FoundByRule", + "Phosphorylation_syntax_4_noun" + ], + [ + "E6", + "FoundByRule", + "Phosphorylation_syntax_4_noun" + ] + ], + "entities": [ + [ + "T2", + "Family", + [[ + "730", + "733" + ]] + ], + [ + "T3", + "Family", + [[ + "21", + "24" + ]] + ], + [ + "T4", + "Family", + [[ + "46", + "49" + ]] + ], + [ + "T5", + "Family", + [[ + "64", + "67" + ]] + ], + [ + "T6", + "Site", + [[ + "105", + "114" + ]] + ], + [ + "T7", + "Gene_or_gene_product", + [[ + "163", + "167" + ]] + ], + [ + "T8", + "Gene_or_gene_product", + [[ + "172", + "176" + ]] + ], + [ + "T9", + "Gene_or_gene_product", + [[ + "197", + "202" + ]] + ], + [ + "T10", + "Gene_or_gene_product", + [[ + "308", + "312" + ]] + ], + [ + "T11", + "Gene_or_gene_product", + [[ + "308", + "322" + ]] + ], + [ + "T12", + "Gene_or_gene_product", + [[ + "352", + "357" + ]] + ], + [ + "T13", + "Gene_or_gene_product", + [[ + "380", + "384" + ]] + ], + [ + "T14", + "Gene_or_gene_product", + [[ + "388", + "397" + ]] + ], + [ + "T15", + "Gene_or_gene_product", + [[ + "436", + "440" + ]] + ], + [ + "T16", + "Family", + [[ + "442", + "445" + ]] + ], + [ + "T17", + "Gene_or_gene_product", + [[ + "487", + "500" + ]] + ], + [ + "T18", + "Gene_or_gene_product", + [[ + "505", + "516" + ]] + ], + [ + "T19", + "Gene_or_gene_product", + [[ + "626", + "642" + ]] + ], + [ + "T20", + "Gene_or_gene_product", + [[ + "664", + "668" + ]] + ], + [ + "T21", + "Gene_or_gene_product", + [[ + "673", + "678" + ]] + ], + [ + "T22", + "Site", + [[ + "679", + "687" + ]] + ], + [ + "T23", + "Gene_or_gene_product", + [[ + "796", + "805" + ]] + ], + [ + "T24", + "Gene_or_gene_product", + [[ + "811", + "814" + ]] + ], + [ + "T25", + "Gene_or_gene_product", + [[ + "840", + "845" + ]] + ], + [ + "T26", + "Gene_or_gene_product", + [[ + "916", + "929" + ]] + ], + [ + "T27", + "Gene_or_gene_product", + [[ + "933", + "942" + ]] + ], + [ + "T28", + "Family", + [[ + "970", + "973" + ]] + ], + [ + "T29", + "Gene_or_gene_product", + [[ + "1124", + "1129" + ]] + ], + [ + "T30", + "Gene_or_gene_product", + [[ + "1176", + "1180" + ]] + ], + [ + "T31", + "Family", + [[ + "1260", + "1263" + ]] + ], + [ + "T32", + "Site", + [[ + "1325", + "1342" + ]] + ], + [ + "T33", + "Gene_or_gene_product", + [[ + "1375", + "1379" + ]] + ], + [ + "T34", + "Gene_or_gene_product", + [[ + "1381", + "1385" + ]] + ], + [ + "T35", + "Gene_or_gene_product", + [[ + "1391", + "1396" + ]] + ] + ], + "attributes": [], + "text": "We hypothesized that MEK inhibition activates AKT by inhibiting ERK activity, which blocks an inhibitory threonine phosphorylation on the juxtamembrane domains of EGFR and HER2, thereby increasing ERBB3 phosphorylation.\r\nTo test this hypothesis, we transiently transfected CHO-KI cells, which do not express ERBB receptors endogenously, with wild-type ERBB3 with either wild-type EGFR or EGFRT669A.\r\nIn cells transfected with wild-type EGFR, MEK inhibition led to feedback activation of phospho-ERBB3 and phosho-EGFR, recapitulating the results we had observed in our panel of cancer cell lines (Figure 6A).\r\nIn contrast, the EGFRT669A mutant increased both basal EGFR and ERBB3 tyrosine phosphorylation that was not augmented by MEK inhibition.\r\nAs a control, we treated CHO-KI cells expressing EGFRT669A with HRG ligand to induce maximal ERBB3 phosphorylation (Figure 6A), indicating that the lack of induction of phospho-ERBB3 in EGFRT669A expressing cells following MEK inhibition was not simply due to the saturation of the system with phospho-ERBB3.\r\nWe observed analogous results in CHO-KI cells expressing wild-type ERBB3 in combination with wild-type or T677A mutant HER2 (Figure 6B).\r\nTogether these results support the hypothesis that inhibition of ERK-mediated phosphorylation of a conserved juxtamembrane domain threonine residue leads to feedback activation of EGFR, HER2, and ERBB3 (Figure 7).", + "relations": [], + "triggers": [ + [ + "T37", + "Phosphorylation", + [[ + "688", + "703" + ]] + ], + [ + "T1", + "Negative_regulation", + [[ + "717", + "726" + ]] + ], + [ + "T36", + "Phosphorylation", + [[ + "846", + "861" + ]] + ], + [ + "T38", + "Phosphorylation", + [[ + "203", + "218" + ]] + ] + ], + "events": [ + [ + "E1", + "T37", + [ + [ + "Theme", + "T20" + ], + [ + "Site", + "T22" + ] + ] + ], + [ + "E2", + "T1", + [ + [ + "Controlled", + "E1" + ], + [ + "Controller", + "T2" + ] + ] + ], + [ + "E3", + "T37", + [ + [ + "Theme", + "T21" + ], + [ + "Site", + "T22" + ] + ] + ], + [ + "E4", + "T1", + [ + [ + "Controlled", + "E3" + ], + [ + "Controller", + "T2" + ] + ] + ], + [ + "E5", + "T36", + [[ + "Theme", + "T25" + ]] + ], + [ + "E6", + "T38", + [[ + "Theme", + "T9" + ]] + ] + ] + }, + "syntaxData": { + "comments": [], + "entities": [ + [ + "T1", + "JJ", + [[ + "342", + "351" + ]] + ], + [ + "T2", + "NN", + [[ + "273", + "279" + ]] + ], + [ + "T3", + "NN", + [[ + "916", + "929" + ]] + ], + [ + "T4", + "NN", + [[ + "436", + "440" + ]] + ], + [ + "T5", + "NN", + [[ + "577", + "583" + ]] + ], + [ + "T6", + "VBG", + [[ + "186", + "196" + ]] + ], + [ + "T7", + "NN", + [[ + "197", + "202" + ]] + ], + [ + "T8", + "NN", + [[ + "673", + "678" + ]] + ], + [ + "T9", + "PRP", + [[ + "246", + "248" + ]] + ], + [ + "T10", + "PRP", + [[ + "1057", + "1059" + ]] + ], + [ + "T11", + ",", + [[ + "516", + "517" + ]] + ], + [ + "T12", + "NN", + [[ + "815", + "821" + ]] + ], + [ + "T13", + "TO", + [[ + "1004", + "1006" + ]] + ], + [ + "T14", + "NN", + [[ + "1246", + "1256" + ]] + ], + [ + "T15", + "NN", + [[ + "203", + "218" + ]] + ], + [ + "T16", + "NN", + [[ + "115", + "130" + ]] + ], + [ + "T17", + ".", + [[ + "1407", + "1408" + ]] + ], + [ + "T18", + "IN", + [[ + "1022", + "1024" + ]] + ], + [ + "T19", + "NN", + [[ + "1163", + "1168" + ]] + ], + [ + "T20", + "NN", + [[ + "664", + "668" + ]] + ], + [ + "T21", + "NN", + [[ + "352", + "357" + ]] + ], + [ + "T22", + "IN", + [[ + "574", + "576" + ]] + ], + [ + "T23", + "NN", + [[ + "1375", + "1379" + ]] + ], + [ + "T24", + "IN", + [[ + "16", + "20" + ]] + ], + [ + "T25", + "PRP", + [[ + "0", + "2" + ]] + ], + [ + "T26", + "NN", + [[ + "172", + "176" + ]] + ], + [ + "T27", + "JJ", + [[ + "1069", + "1078" + ]] + ], + [ + "T28", + "CC", + [[ + "669", + "672" + ]] + ], + [ + "T29", + "VBD", + [[ + "1264", + "1272" + ]] + ], + [ + "T30", + "DT", + [[ + "533", + "536" + ]] + ], + [ + "T31", + "DT", + [[ + "134", + "137" + ]] + ], + [ + "T32", + "JJ", + [[ + "1294", + "1303" + ]] + ], + [ + "T33", + "VBD", + [[ + "1060", + "1068" + ]] + ], + [ + "T34", + "JJ", + [[ + "1150", + "1159" + ]] + ], + [ + "T35", + "IN", + [[ + "747", + "749" + ]] + ], + [ + "T36", + ".", + [[ + "397", + "398" + ]] + ], + [ + "T37", + "IN", + [[ + "806", + "810" + ]] + ], + [ + "T38", + "IN", + [[ + "160", + "162" + ]] + ], + [ + "T39", + "NN", + [[ + "846", + "861" + ]] + ], + [ + "T40", + "NN", + [[ + "626", + "635" + ]] + ], + [ + "T41", + "DT", + [[ + "1226", + "1229" + ]] + ], + [ + "T42", + "NN", + [[ + "68", + "76" + ]] + ], + [ + "T43", + "RB", + [[ + "993", + "999" + ]] + ], + [ + "T44", + "RB", + [[ + "989", + "992" + ]] + ], + [ + "T45", + "NNS", + [[ + "779", + "784" + ]] + ], + [ + "T46", + "NN", + [[ + "974", + "984" + ]] + ], + [ + "T47", + "TO", + [[ + "461", + "463" + ]] + ], + [ + "T48", + "NN", + [[ + "1361", + "1371" + ]] + ], + [ + "T49", + "IN", + [[ + "561", + "563" + ]] + ], + [ + "T50", + "NN", + [[ + "138", + "151" + ]] + ], + [ + "T51", + "IN", + [[ + "131", + "133" + ]] + ], + [ + "T52", + "JJ", + [[ + "370", + "379" + ]] + ], + [ + "T53", + "NN", + [[ + "64", + "67" + ]] + ], + [ + "T54", + "IN", + [[ + "1241", + "1245" + ]] + ], + [ + "T55", + "NN", + [[ + "1133", + "1144" + ]] + ], + [ + "T56", + "NN", + [[ + "612", + "620" + ]] + ], + [ + "T57", + "DT", + [[ + "1204", + "1209" + ]] + ], + [ + "T58", + "DT", + [[ + "750", + "751" + ]] + ], + [ + "T59", + "NN", + [[ + "1124", + "1129" + ]] + ], + [ + "T60", + "NN", + [[ + "1011", + "1021" + ]] + ], + [ + "T61", + ",", + [[ + "335", + "336" + ]] + ], + [ + "T62", + "NNS", + [[ + "1210", + "1217" + ]] + ], + [ + "T63", + "NN", + [[ + "688", + "703" + ]] + ], + [ + "T64", + "IN", + [[ + "50", + "52" + ]] + ], + [ + "T65", + "IN", + [[ + "400", + "402" + ]] + ], + [ + "T66", + "IN", + [[ + "484", + "486" + ]] + ], + [ + "T67", + "NN", + [[ + "21", + "24" + ]] + ], + [ + "T68", + "NN", + [[ + "1260", + "1263" + ]] + ], + [ + "T69", + "PRP", + [[ + "761", + "763" + ]] + ], + [ + "T70", + "IN", + [[ + "609", + "611" + ]] + ], + [ + "T71", + "NN", + [[ + "933", + "942" + ]] + ], + [ + "T72", + "JJ", + [[ + "1000", + "1003" + ]] + ], + [ + "T73", + "DT", + [[ + "91", + "93" + ]] + ], + [ + "T74", + "NN", + [[ + "1176", + "1180" + ]] + ], + [ + "T75", + "IN", + [[ + "1130", + "1132" + ]] + ], + [ + "T76", + "RB", + [[ + "249", + "260" + ]] + ], + [ + "T77", + "WDT", + [[ + "287", + "292" + ]] + ], + [ + "T78", + "VBZ", + [[ + "36", + "45" + ]] + ], + [ + "T79", + "VBD", + [[ + "643", + "652" + ]] + ], + [ + "T80", + "IN", + [[ + "1372", + "1374" + ]] + ], + [ + "T81", + "NN", + [[ + "1230", + "1240" + ]] + ], + [ + "T82", + "NN", + [[ + "446", + "456" + ]] + ], + [ + "T83", + "IN", + [[ + "337", + "341" + ]] + ], + [ + "T84", + "IN", + [[ + "1257", + "1259" + ]] + ], + [ + "T85", + ",", + [[ + "1385", + "1386" + ]] + ], + [ + "T86", + "VBP", + [[ + "293", + "295" + ]] + ], + [ + "T87", + "VB", + [[ + "224", + "228" + ]] + ], + [ + "T88", + "VBP", + [[ + "1218", + "1225" + ]] + ], + [ + "T89", + "NN", + [[ + "1304", + "1317" + ]] + ], + [ + "T90", + "NN", + [[ + "1273", + "1288" + ]] + ], + [ + "T91", + "NN", + [[ + "636", + "642" + ]] + ], + [ + "T92", + "JJ", + [[ + "94", + "104" + ]] + ], + [ + "T93", + "NN", + [[ + "1041", + "1054" + ]] + ], + [ + "T94", + ",", + [[ + "285", + "286" + ]] + ], + [ + "T95", + "NN", + [[ + "943", + "953" + ]] + ], + [ + "T96", + "IN", + [[ + "727", + "729" + ]] + ], + [ + "T97", + "NN", + [[ + "772", + "778" + ]] + ], + [ + "T98", + "DT", + [[ + "1292", + "1293" + ]] + ], + [ + "T99", + "IN", + [[ + "886", + "890" + ]] + ], + [ + "T100", + "NN", + [[ + "811", + "814" + ]] + ], + [ + "T101", + "DT", + [[ + "1007", + "1010" + ]] + ], + [ + "T102", + "NNS", + [[ + "280", + "285" + ]] + ], + [ + "T103", + "NN", + [[ + "679", + "687" + ]] + ], + [ + "T104", + "TO", + [[ + "822", + "824" + ]] + ], + [ + "T105", + "NN", + [[ + "380", + "384" + ]] + ], + [ + "T106", + "CC", + [[ + "501", + "504" + ]] + ], + [ + "T107", + "VBD", + [[ + "764", + "771" + ]] + ], + [ + "T108", + "NN", + [[ + "1318", + "1324" + ]] + ], + [ + "T109", + ",", + [[ + "244", + "245" + ]] + ], + [ + "T110", + ",", + [[ + "440", + "441" + ]] + ], + [ + "T111", + "VBG", + [[ + "53", + "63" + ]] + ], + [ + "T112", + ",", + [[ + "873", + "874" + ]] + ], + [ + "T113", + ".", + [[ + "606", + "607" + ]] + ], + [ + "T114", + "NN", + [[ + "796", + "805" + ]] + ], + [ + "T115", + "NN", + [[ + "25", + "35" + ]] + ], + [ + "T116", + "NN", + [[ + "163", + "167" + ]] + ], + [ + "T117", + "NN", + [[ + "388", + "397" + ]] + ], + [ + "T118", + "VBD", + [[ + "457", + "460" + ]] + ], + [ + "T119", + "NN", + [[ + "584", + "588" + ]] + ], + [ + "T120", + "VBG", + [[ + "1103", + "1113" + ]] + ], + [ + "T121", + "IN", + [[ + "1087", + "1089" + ]] + ], + [ + "T122", + "IN", + [[ + "930", + "932" + ]] + ], + [ + "T123", + "IN", + [[ + "1145", + "1149" + ]] + ], + [ + "T124", + ".", + [[ + "744", + "745" + ]] + ], + [ + "T125", + ",", + [[ + "620", + "621" + ]] + ], + [ + "T126", + "NN", + [[ + "1169", + "1175" + ]] + ], + [ + "T127", + "CC", + [[ + "1387", + "1390" + ]] + ], + [ + "T128", + "NNS", + [[ + "313", + "322" + ]] + ], + [ + "T129", + "WDT", + [[ + "78", + "83" + ]] + ], + [ + "T130", + "NN", + [[ + "105", + "114" + ]] + ], + [ + "T131", + "VBZ", + [[ + "1343", + "1348" + ]] + ], + [ + "T132", + ".", + [[ + "1054", + "1055" + ]] + ], + [ + "T133", + "PRP", + [[ + "545", + "547" + ]] + ], + [ + "T134", + "VBZ", + [[ + "84", + "90" + ]] + ], + [ + "T135", + "RB", + [[ + "178", + "185" + ]] + ], + [ + "T136", + "NN", + [[ + "234", + "244" + ]] + ], + [ + "T137", + "VBN", + [[ + "409", + "420" + ]] + ], + [ + "T138", + "NN", + [[ + "1090", + "1096" + ]] + ], + [ + "T139", + "NN", + [[ + "308", + "312" + ]] + ], + [ + "T140", + "NN", + [[ + "1352", + "1360" + ]] + ], + [ + "T141", + "VBG", + [[ + "785", + "795" + ]] + ], + [ + "T142", + "IN", + [[ + "900", + "902" + ]] + ], + [ + "T143", + "NN", + [[ + "487", + "500" + ]] + ], + [ + "T144", + "VBN", + [[ + "552", + "560" + ]] + ], + [ + "T145", + "NN", + [[ + "442", + "445" + ]] + ], + [ + "T146", + "NN", + [[ + "752", + "759" + ]] + ], + [ + "T147", + "NN", + [[ + "1335", + "1342" + ]] + ], + [ + "T148", + "JJ", + [[ + "426", + "435" + ]] + ], + [ + "T149", + "IN", + [[ + "913", + "915" + ]] + ], + [ + "T150", + "NNS", + [[ + "954", + "959" + ]] + ], + [ + "T151", + "IN", + [[ + "358", + "362" + ]] + ], + [ + "T152", + "CC", + [[ + "653", + "657" + ]] + ], + [ + "T153", + "VB", + [[ + "300", + "307" + ]] + ], + [ + "T154", + ",", + [[ + "76", + "77" + ]] + ], + [ + "T155", + "CC", + [[ + "385", + "387" + ]] + ], + [ + "T156", + "NN", + [[ + "903", + "912" + ]] + ], + [ + "T157", + "VBD", + [[ + "709", + "712" + ]] + ], + [ + "T158", + "NN", + [[ + "1325", + "1334" + ]] + ], + [ + "T159", + "NN", + [[ + "970", + "973" + ]] + ], + [ + "T160", + "VBD", + [[ + "3", + "15" + ]] + ], + [ + "T161", + "NNS", + [[ + "152", + "159" + ]] + ], + [ + "T162", + "VB", + [[ + "825", + "831" + ]] + ], + [ + "T163", + "VBD", + [[ + "548", + "551" + ]] + ], + [ + "T164", + "CC", + [[ + "363", + "369" + ]] + ], + [ + "T165", + "NNS", + [[ + "1079", + "1086" + ]] + ], + [ + "T166", + "RB", + [[ + "323", + "335" + ]] + ], + [ + "T167", + "RB", + [[ + "296", + "299" + ]] + ], + [ + "T168", + "JJ", + [[ + "832", + "839" + ]] + ], + [ + "T169", + "NN", + [[ + "464", + "472" + ]] + ], + [ + "T170", + "JJ", + [[ + "1114", + "1123" + ]] + ], + [ + "T171", + "NN", + [[ + "505", + "516" + ]] + ], + [ + "T172", + "DT", + [[ + "622", + "625" + ]] + ], + [ + "T173", + "TO", + [[ + "1349", + "1351" + ]] + ], + [ + "T174", + "IN", + [[ + "1289", + "1291" + ]] + ], + [ + "T175", + "VBD", + [[ + "261", + "272" + ]] + ], + [ + "T176", + ",", + [[ + "176", + "177" + ]] + ], + [ + "T177", + "NN", + [[ + "730", + "733" + ]] + ], + [ + "T178", + "NN", + [[ + "1381", + "1385" + ]] + ], + [ + "T179", + "IN", + [[ + "421", + "425" + ]] + ], + [ + "T180", + ".", + [[ + "1192", + "1193" + ]] + ], + [ + "T181", + "NN", + [[ + "895", + "899" + ]] + ], + [ + "T182", + "NNS", + [[ + "537", + "544" + ]] + ], + [ + "T183", + "DT", + [[ + "229", + "233" + ]] + ], + [ + "T184", + "VBG", + [[ + "960", + "969" + ]] + ], + [ + "T185", + "RB", + [[ + "713", + "716" + ]] + ], + [ + "T186", + "WDT", + [[ + "704", + "708" + ]] + ], + [ + "T187", + "NNS", + [[ + "403", + "408" + ]] + ], + [ + "T188", + "VBN", + [[ + "717", + "726" + ]] + ], + [ + "T189", + ",", + [[ + "759", + "760" + ]] + ], + [ + "T190", + "RB", + [[ + "1195", + "1203" + ]] + ], + [ + "T191", + "NNS", + [[ + "589", + "594" + ]] + ], + [ + "T192", + "NN", + [[ + "1029", + "1035" + ]] + ], + [ + "T193", + "NN", + [[ + "568", + "573" + ]] + ], + [ + "T194", + "CC", + [[ + "1160", + "1162" + ]] + ], + [ + "T195", + "TO", + [[ + "221", + "223" + ]] + ], + [ + "T196", + "JJ", + [[ + "658", + "663" + ]] + ], + [ + "T197", + "VBG", + [[ + "875", + "885" + ]] + ], + [ + "T198", + "NNS", + [[ + "1097", + "1102" + ]] + ], + [ + "T199", + "DT", + [[ + "1025", + "1028" + ]] + ], + [ + "T200", + "PRP$", + [[ + "564", + "567" + ]] + ], + [ + "T201", + "IN", + [[ + "1036", + "1040" + ]] + ], + [ + "T202", + "NN", + [[ + "840", + "845" + ]] + ], + [ + "T203", + ".", + [[ + "218", + "219" + ]] + ], + [ + "T204", + "NN", + [[ + "46", + "49" + ]] + ], + [ + "T205", + "VBD", + [[ + "985", + "988" + ]] + ], + [ + "T206", + "NN", + [[ + "473", + "483" + ]] + ], + [ + "T207", + "CC", + [[ + "168", + "171" + ]] + ], + [ + "T208", + "NN", + [[ + "734", + "744" + ]] + ], + [ + "T209", + "VBG", + [[ + "518", + "532" + ]] + ], + [ + "T210", + "NN", + [[ + "1391", + "1396" + ]] + ], + [ + "T211", + ",", + [[ + "1379", + "1380" + ]] + ], + [ + "T212", + "DT", + [[ + "891", + "894" + ]] + ] + ], + "attributes": [], + "text": "We hypothesized that MEK inhibition activates AKT by inhibiting ERK activity, which blocks an inhibitory threonine phosphorylation on the juxtamembrane domains of EGFR and HER2, thereby increasing ERBB3 phosphorylation.\r\nTo test this hypothesis, we transiently transfected CHO-KI cells, which do not express ERBB receptors endogenously, with wild-type ERBB3 with either wild-type EGFR or EGFRT669A.\r\nIn cells transfected with wild-type EGFR, MEK inhibition led to feedback activation of phospho-ERBB3 and phosho-EGFR, recapitulating the results we had observed in our panel of cancer cell lines (Figure 6A).\r\nIn contrast, the EGFRT669A mutant increased both basal EGFR and ERBB3 tyrosine phosphorylation that was not augmented by MEK inhibition.\r\nAs a control, we treated CHO-KI cells expressing EGFRT669A with HRG ligand to induce maximal ERBB3 phosphorylation (Figure 6A), indicating that the lack of induction of phospho-ERBB3 in EGFRT669A expressing cells following MEK inhibition was not simply due to the saturation of the system with phospho-ERBB3.\r\nWe observed analogous results in CHO-KI cells expressing wild-type ERBB3 in combination with wild-type or T677A mutant HER2 (Figure 6B).\r\nTogether these results support the hypothesis that inhibition of ERK-mediated phosphorylation of a conserved juxtamembrane domain threonine residue leads to feedback activation of EGFR, HER2, and ERBB3 (Figure 7).", + "relations": [ + [ + "R1", + "nsubj", + [ + [ + "governor", + "T160" + ], + [ + "dependent", + "T25" + ] + ] + ], + [ + "R2", + "ccomp", + [ + [ + "governor", + "T160" + ], + [ + "dependent", + "T78" + ] + ] + ], + [ + "R3", + "nn", + [ + [ + "governor", + "T115" + ], + [ + "dependent", + "T67" + ] + ] + ], + [ + "R4", + "mark", + [ + [ + "governor", + "T78" + ], + [ + "dependent", + "T24" + ] + ] + ], + [ + "R5", + "nsubj", + [ + [ + "governor", + "T78" + ], + [ + "dependent", + "T115" + ] + ] + ], + [ + "R6", + "dobj", + [ + [ + "governor", + "T78" + ], + [ + "dependent", + "T204" + ] + ] + ], + [ + "R7", + "prep_by", + [ + [ + "governor", + "T78" + ], + [ + "dependent", + "T42" + ] + ] + ], + [ + "R8", + "amod", + [ + [ + "governor", + "T42" + ], + [ + "dependent", + "T111" + ] + ] + ], + [ + "R9", + "nn", + [ + [ + "governor", + "T42" + ], + [ + "dependent", + "T53" + ] + ] + ], + [ + "R10", + "rcmod", + [ + [ + "governor", + "T42" + ], + [ + "dependent", + "T134" + ] + ] + ], + [ + "R11", + "nsubj", + [ + [ + "governor", + "T134" + ], + [ + "dependent", + "T129" + ] + ] + ], + [ + "R12", + "dobj", + [ + [ + "governor", + "T134" + ], + [ + "dependent", + "T16" + ] + ] + ], + [ + "R13", + "prep_on", + [ + [ + "governor", + "T134" + ], + [ + "dependent", + "T161" + ] + ] + ], + [ + "R14", + "vmod", + [ + [ + "governor", + "T134" + ], + [ + "dependent", + "T6" + ] + ] + ], + [ + "R15", + "det", + [ + [ + "governor", + "T16" + ], + [ + "dependent", + "T73" + ] + ] + ], + [ + "R16", + "amod", + [ + [ + "governor", + "T16" + ], + [ + "dependent", + "T92" + ] + ] + ], + [ + "R17", + "nn", + [ + [ + "governor", + "T16" + ], + [ + "dependent", + "T130" + ] + ] + ], + [ + "R18", + "det", + [ + [ + "governor", + "T161" + ], + [ + "dependent", + "T31" + ] + ] + ], + [ + "R19", + "nn", + [ + [ + "governor", + "T161" + ], + [ + "dependent", + "T50" + ] + ] + ], + [ + "R20", + "prep_of", + [ + [ + "governor", + "T161" + ], + [ + "dependent", + "T116" + ] + ] + ], + [ + "R21", + "prep_of", + [ + [ + "governor", + "T161" + ], + [ + "dependent", + "T26" + ] + ] + ], + [ + "R22", + "conj_and", + [ + [ + "governor", + "T116" + ], + [ + "dependent", + "T26" + ] + ] + ], + [ + "R23", + "advmod", + [ + [ + "governor", + "T6" + ], + [ + "dependent", + "T135" + ] + ] + ], + [ + "R24", + "dobj", + [ + [ + "governor", + "T6" + ], + [ + "dependent", + "T15" + ] + ] + ], + [ + "R25", + "nn", + [ + [ + "governor", + "T15" + ], + [ + "dependent", + "T7" + ] + ] + ], + [ + "R26", + "aux", + [ + [ + "governor", + "T87" + ], + [ + "dependent", + "T195" + ] + ] + ], + [ + "R27", + "dobj", + [ + [ + "governor", + "T87" + ], + [ + "dependent", + "T136" + ] + ] + ], + [ + "R28", + "det", + [ + [ + "governor", + "T136" + ], + [ + "dependent", + "T183" + ] + ] + ], + [ + "R29", + "advcl", + [ + [ + "governor", + "T175" + ], + [ + "dependent", + "T87" + ] + ] + ], + [ + "R30", + "nsubj", + [ + [ + "governor", + "T175" + ], + [ + "dependent", + "T9" + ] + ] + ], + [ + "R31", + "advmod", + [ + [ + "governor", + "T175" + ], + [ + "dependent", + "T76" + ] + ] + ], + [ + "R32", + "dobj", + [ + [ + "governor", + "T175" + ], + [ + "dependent", + "T102" + ] + ] + ], + [ + "R33", + "nn", + [ + [ + "governor", + "T102" + ], + [ + "dependent", + "T2" + ] + ] + ], + [ + "R34", + "rcmod", + [ + [ + "governor", + "T102" + ], + [ + "dependent", + "T153" + ] + ] + ], + [ + "R35", + "nsubj", + [ + [ + "governor", + "T153" + ], + [ + "dependent", + "T77" + ] + ] + ], + [ + "R36", + "aux", + [ + [ + "governor", + "T153" + ], + [ + "dependent", + "T86" + ] + ] + ], + [ + "R37", + "neg", + [ + [ + "governor", + "T153" + ], + [ + "dependent", + "T167" + ] + ] + ], + [ + "R38", + "dobj", + [ + [ + "governor", + "T153" + ], + [ + "dependent", + "T128" + ] + ] + ], + [ + "R39", + "advmod", + [ + [ + "governor", + "T153" + ], + [ + "dependent", + "T166" + ] + ] + ], + [ + "R40", + "prep_with", + [ + [ + "governor", + "T153" + ], + [ + "dependent", + "T21" + ] + ] + ], + [ + "R41", + "nn", + [ + [ + "governor", + "T128" + ], + [ + "dependent", + "T139" + ] + ] + ], + [ + "R42", + "amod", + [ + [ + "governor", + "T21" + ], + [ + "dependent", + "T1" + ] + ] + ], + [ + "R43", + "prep_with", + [ + [ + "governor", + "T21" + ], + [ + "dependent", + "T105" + ] + ] + ], + [ + "R44", + "prep_with", + [ + [ + "governor", + "T21" + ], + [ + "dependent", + "T117" + ] + ] + ], + [ + "R45", + "preconj", + [ + [ + "governor", + "T105" + ], + [ + "dependent", + "T164" + ] + ] + ], + [ + "R46", + "amod", + [ + [ + "governor", + "T105" + ], + [ + "dependent", + "T52" + ] + ] + ], + [ + "R47", + "conj_or", + [ + [ + "governor", + "T105" + ], + [ + "dependent", + "T117" + ] + ] + ], + [ + "R48", + "vmod", + [ + [ + "governor", + "T187" + ], + [ + "dependent", + "T137" + ] + ] + ], + [ + "R49", + "prep_with", + [ + [ + "governor", + "T137" + ], + [ + "dependent", + "T4" + ] + ] + ], + [ + "R50", + "amod", + [ + [ + "governor", + "T4" + ], + [ + "dependent", + "T148" + ] + ] + ], + [ + "R51", + "nn", + [ + [ + "governor", + "T82" + ], + [ + "dependent", + "T145" + ] + ] + ], + [ + "R52", + "prep_in", + [ + [ + "governor", + "T118" + ], + [ + "dependent", + "T187" + ] + ] + ], + [ + "R53", + "nsubj", + [ + [ + "governor", + "T118" + ], + [ + "dependent", + "T82" + ] + ] + ], + [ + "R54", + "prep_to", + [ + [ + "governor", + "T118" + ], + [ + "dependent", + "T206" + ] + ] + ], + [ + "R55", + "xcomp", + [ + [ + "governor", + "T118" + ], + [ + "dependent", + "T209" + ] + ] + ], + [ + "R56", + "nn", + [ + [ + "governor", + "T206" + ], + [ + "dependent", + "T169" + ] + ] + ], + [ + "R57", + "prep_of", + [ + [ + "governor", + "T206" + ], + [ + "dependent", + "T143" + ] + ] + ], + [ + "R58", + "prep_of", + [ + [ + "governor", + "T206" + ], + [ + "dependent", + "T171" + ] + ] + ], + [ + "R59", + "conj_and", + [ + [ + "governor", + "T143" + ], + [ + "dependent", + "T171" + ] + ] + ], + [ + "R60", + "dobj", + [ + [ + "governor", + "T209" + ], + [ + "dependent", + "T182" + ] + ] + ], + [ + "R61", + "det", + [ + [ + "governor", + "T182" + ], + [ + "dependent", + "T30" + ] + ] + ], + [ + "R62", + "rcmod", + [ + [ + "governor", + "T182" + ], + [ + "dependent", + "T144" + ] + ] + ], + [ + "R63", + "nsubj", + [ + [ + "governor", + "T144" + ], + [ + "dependent", + "T133" + ] + ] + ], + [ + "R64", + "aux", + [ + [ + "governor", + "T144" + ], + [ + "dependent", + "T163" + ] + ] + ], + [ + "R65", + "prep_in", + [ + [ + "governor", + "T144" + ], + [ + "dependent", + "T193" + ] + ] + ], + [ + "R66", + "poss", + [ + [ + "governor", + "T193" + ], + [ + "dependent", + "T200" + ] + ] + ], + [ + "R67", + "prep_of", + [ + [ + "governor", + "T193" + ], + [ + "dependent", + "T191" + ] + ] + ], + [ + "R68", + "nn", + [ + [ + "governor", + "T191" + ], + [ + "dependent", + "T5" + ] + ] + ], + [ + "R69", + "nn", + [ + [ + "governor", + "T191" + ], + [ + "dependent", + "T119" + ] + ] + ], + [ + "R70", + "det", + [ + [ + "governor", + "T91" + ], + [ + "dependent", + "T172" + ] + ] + ], + [ + "R71", + "nn", + [ + [ + "governor", + "T91" + ], + [ + "dependent", + "T40" + ] + ] + ], + [ + "R72", + "prep_in", + [ + [ + "governor", + "T79" + ], + [ + "dependent", + "T56" + ] + ] + ], + [ + "R73", + "nsubj", + [ + [ + "governor", + "T79" + ], + [ + "dependent", + "T91" + ] + ] + ], + [ + "R74", + "prep", + [ + [ + "governor", + "T79" + ], + [ + "dependent", + "T152" + ] + ] + ], + [ + "R75", + "pobj", + [ + [ + "governor", + "T152" + ], + [ + "dependent", + "T20" + ] + ] + ], + [ + "R76", + "pobj", + [ + [ + "governor", + "T152" + ], + [ + "dependent", + "T63" + ] + ] + ], + [ + "R77", + "amod", + [ + [ + "governor", + "T20" + ], + [ + "dependent", + "T196" + ] + ] + ], + [ + "R78", + "conj_and", + [ + [ + "governor", + "T20" + ], + [ + "dependent", + "T63" + ] + ] + ], + [ + "R79", + "rcmod", + [ + [ + "governor", + "T20" + ], + [ + "dependent", + "T188" + ] + ] + ], + [ + "R80", + "nn", + [ + [ + "governor", + "T63" + ], + [ + "dependent", + "T8" + ] + ] + ], + [ + "R81", + "nn", + [ + [ + "governor", + "T63" + ], + [ + "dependent", + "T103" + ] + ] + ], + [ + "R82", + "nsubjpass", + [ + [ + "governor", + "T188" + ], + [ + "dependent", + "T186" + ] + ] + ], + [ + "R83", + "auxpass", + [ + [ + "governor", + "T188" + ], + [ + "dependent", + "T157" + ] + ] + ], + [ + "R84", + "neg", + [ + [ + "governor", + "T188" + ], + [ + "dependent", + "T185" + ] + ] + ], + [ + "R85", + "agent", + [ + [ + "governor", + "T188" + ], + [ + "dependent", + "T208" + ] + ] + ], + [ + "R86", + "nn", + [ + [ + "governor", + "T208" + ], + [ + "dependent", + "T177" + ] + ] + ], + [ + "R87", + "det", + [ + [ + "governor", + "T146" + ], + [ + "dependent", + "T58" + ] + ] + ], + [ + "R88", + "prep_as", + [ + [ + "governor", + "T107" + ], + [ + "dependent", + "T146" + ] + ] + ], + [ + "R89", + "nsubj", + [ + [ + "governor", + "T107" + ], + [ + "dependent", + "T69" + ] + ] + ], + [ + "R90", + "dobj", + [ + [ + "governor", + "T107" + ], + [ + "dependent", + "T45" + ] + ] + ], + [ + "R91", + "vmod", + [ + [ + "governor", + "T107" + ], + [ + "dependent", + "T197" + ] + ] + ], + [ + "R92", + "nn", + [ + [ + "governor", + "T45" + ], + [ + "dependent", + "T97" + ] + ] + ], + [ + "R93", + "vmod", + [ + [ + "governor", + "T45" + ], + [ + "dependent", + "T141" + ] + ] + ], + [ + "R94", + "dobj", + [ + [ + "governor", + "T141" + ], + [ + "dependent", + "T114" + ] + ] + ], + [ + "R95", + "prep_with", + [ + [ + "governor", + "T141" + ], + [ + "dependent", + "T12" + ] + ] + ], + [ + "R96", + "vmod", + [ + [ + "governor", + "T141" + ], + [ + "dependent", + "T162" + ] + ] + ], + [ + "R97", + "nn", + [ + [ + "governor", + "T12" + ], + [ + "dependent", + "T100" + ] + ] + ], + [ + "R98", + "aux", + [ + [ + "governor", + "T162" + ], + [ + "dependent", + "T104" + ] + ] + ], + [ + "R99", + "dobj", + [ + [ + "governor", + "T162" + ], + [ + "dependent", + "T39" + ] + ] + ], + [ + "R100", + "amod", + [ + [ + "governor", + "T39" + ], + [ + "dependent", + "T168" + ] + ] + ], + [ + "R101", + "nn", + [ + [ + "governor", + "T39" + ], + [ + "dependent", + "T202" + ] + ] + ], + [ + "R102", + "ccomp", + [ + [ + "governor", + "T197" + ], + [ + "dependent", + "T72" + ] + ] + ], + [ + "R103", + "det", + [ + [ + "governor", + "T181" + ], + [ + "dependent", + "T212" + ] + ] + ], + [ + "R104", + "prep_of", + [ + [ + "governor", + "T181" + ], + [ + "dependent", + "T156" + ] + ] + ], + [ + "R105", + "prep_of", + [ + [ + "governor", + "T156" + ], + [ + "dependent", + "T3" + ] + ] + ], + [ + "R106", + "prep_in", + [ + [ + "governor", + "T3" + ], + [ + "dependent", + "T150" + ] + ] + ], + [ + "R107", + "nn", + [ + [ + "governor", + "T150" + ], + [ + "dependent", + "T71" + ] + ] + ], + [ + "R108", + "nn", + [ + [ + "governor", + "T150" + ], + [ + "dependent", + "T95" + ] + ] + ], + [ + "R109", + "prep_following", + [ + [ + "governor", + "T150" + ], + [ + "dependent", + "T46" + ] + ] + ], + [ + "R110", + "nn", + [ + [ + "governor", + "T46" + ], + [ + "dependent", + "T159" + ] + ] + ], + [ + "R111", + "mark", + [ + [ + "governor", + "T72" + ], + [ + "dependent", + "T99" + ] + ] + ], + [ + "R112", + "nsubj", + [ + [ + "governor", + "T72" + ], + [ + "dependent", + "T181" + ] + ] + ], + [ + "R113", + "cop", + [ + [ + "governor", + "T72" + ], + [ + "dependent", + "T205" + ] + ] + ], + [ + "R114", + "neg", + [ + [ + "governor", + "T72" + ], + [ + "dependent", + "T44" + ] + ] + ], + [ + "R115", + "advmod", + [ + [ + "governor", + "T72" + ], + [ + "dependent", + "T43" + ] + ] + ], + [ + "R116", + "prep_to", + [ + [ + "governor", + "T72" + ], + [ + "dependent", + "T60" + ] + ] + ], + [ + "R117", + "det", + [ + [ + "governor", + "T60" + ], + [ + "dependent", + "T101" + ] + ] + ], + [ + "R118", + "prep_of", + [ + [ + "governor", + "T60" + ], + [ + "dependent", + "T192" + ] + ] + ], + [ + "R119", + "det", + [ + [ + "governor", + "T192" + ], + [ + "dependent", + "T199" + ] + ] + ], + [ + "R120", + "prep_with", + [ + [ + "governor", + "T192" + ], + [ + "dependent", + "T93" + ] + ] + ], + [ + "R121", + "nsubj", + [ + [ + "governor", + "T33" + ], + [ + "dependent", + "T10" + ] + ] + ], + [ + "R122", + "dobj", + [ + [ + "governor", + "T33" + ], + [ + "dependent", + "T165" + ] + ] + ], + [ + "R123", + "prep_in", + [ + [ + "governor", + "T33" + ], + [ + "dependent", + "T198" + ] + ] + ], + [ + "R124", + "xcomp", + [ + [ + "governor", + "T33" + ], + [ + "dependent", + "T120" + ] + ] + ], + [ + "R125", + "amod", + [ + [ + "governor", + "T165" + ], + [ + "dependent", + "T27" + ] + ] + ], + [ + "R126", + "nn", + [ + [ + "governor", + "T198" + ], + [ + "dependent", + "T138" + ] + ] + ], + [ + "R127", + "dobj", + [ + [ + "governor", + "T120" + ], + [ + "dependent", + "T59" + ] + ] + ], + [ + "R128", + "prep_in", + [ + [ + "governor", + "T120" + ], + [ + "dependent", + "T55" + ] + ] + ], + [ + "R129", + "prep_with", + [ + [ + "governor", + "T120" + ], + [ + "dependent", + "T34" + ] + ] + ], + [ + "R130", + "prep_with", + [ + [ + "governor", + "T120" + ], + [ + "dependent", + "T74" + ] + ] + ], + [ + "R131", + "amod", + [ + [ + "governor", + "T59" + ], + [ + "dependent", + "T170" + ] + ] + ], + [ + "R132", + "conj_or", + [ + [ + "governor", + "T34" + ], + [ + "dependent", + "T74" + ] + ] + ], + [ + "R133", + "nn", + [ + [ + "governor", + "T74" + ], + [ + "dependent", + "T19" + ] + ] + ], + [ + "R134", + "nn", + [ + [ + "governor", + "T74" + ], + [ + "dependent", + "T126" + ] + ] + ], + [ + "R135", + "det", + [ + [ + "governor", + "T62" + ], + [ + "dependent", + "T57" + ] + ] + ], + [ + "R136", + "advmod", + [ + [ + "governor", + "T88" + ], + [ + "dependent", + "T190" + ] + ] + ], + [ + "R137", + "nsubj", + [ + [ + "governor", + "T88" + ], + [ + "dependent", + "T62" + ] + ] + ], + [ + "R138", + "dobj", + [ + [ + "governor", + "T88" + ], + [ + "dependent", + "T81" + ] + ] + ], + [ + "R139", + "ccomp", + [ + [ + "governor", + "T88" + ], + [ + "dependent", + "T29" + ] + ] + ], + [ + "R140", + "det", + [ + [ + "governor", + "T81" + ], + [ + "dependent", + "T41" + ] + ] + ], + [ + "R141", + "prep_of", + [ + [ + "governor", + "T14" + ], + [ + "dependent", + "T68" + ] + ] + ], + [ + "R142", + "mark", + [ + [ + "governor", + "T29" + ], + [ + "dependent", + "T54" + ] + ] + ], + [ + "R143", + "nsubj", + [ + [ + "governor", + "T29" + ], + [ + "dependent", + "T14" + ] + ] + ], + [ + "R144", + "ccomp", + [ + [ + "governor", + "T29" + ], + [ + "dependent", + "T131" + ] + ] + ], + [ + "R145", + "prep_of", + [ + [ + "governor", + "T90" + ], + [ + "dependent", + "T147" + ] + ] + ], + [ + "R146", + "det", + [ + [ + "governor", + "T147" + ], + [ + "dependent", + "T98" + ] + ] + ], + [ + "R147", + "amod", + [ + [ + "governor", + "T147" + ], + [ + "dependent", + "T32" + ] + ] + ], + [ + "R148", + "nn", + [ + [ + "governor", + "T147" + ], + [ + "dependent", + "T89" + ] + ] + ], + [ + "R149", + "nn", + [ + [ + "governor", + "T147" + ], + [ + "dependent", + "T108" + ] + ] + ], + [ + "R150", + "nn", + [ + [ + "governor", + "T147" + ], + [ + "dependent", + "T158" + ] + ] + ], + [ + "R151", + "nsubj", + [ + [ + "governor", + "T131" + ], + [ + "dependent", + "T90" + ] + ] + ], + [ + "R152", + "prep_to", + [ + [ + "governor", + "T131" + ], + [ + "dependent", + "T48" + ] + ] + ], + [ + "R153", + "nn", + [ + [ + "governor", + "T48" + ], + [ + "dependent", + "T140" + ] + ] + ], + [ + "R154", + "prep_of", + [ + [ + "governor", + "T48" + ], + [ + "dependent", + "T23" + ] + ] + ], + [ + "R155", + "prep_of", + [ + [ + "governor", + "T48" + ], + [ + "dependent", + "T178" + ] + ] + ], + [ + "R156", + "prep_of", + [ + [ + "governor", + "T48" + ], + [ + "dependent", + "T210" + ] + ] + ], + [ + "R157", + "conj_and", + [ + [ + "governor", + "T23" + ], + [ + "dependent", + "T178" + ] + ] + ], + [ + "R158", + "conj_and", + [ + [ + "governor", + "T23" + ], + [ + "dependent", + "T210" + ] + ] + ] + ], + "triggers": [], + "events": [] + } +} \ No newline at end of file diff --git a/index.html b/index.html index d6a909a..3252ca5 100644 --- a/index.html +++ b/index.html @@ -42,10 +42,8 @@ } .split-left {width:66.5%; overflow:hidden;} -.split-right {transform:translateX(0) !important; overflow: auto;} - +.split-right {transform:translateX(0) !important;} .node { cursor: pointer; } - #graph { transition:transform 200ms ease; transform:translateX(100%); @@ -55,7 +53,6 @@ position:fixed; top:0; right:0; - overflow: auto; } @@ -65,9 +62,14 @@
@@ -81,9 +83,10 @@ - - + + + @@ -93,89 +96,27 @@ diff --git a/js/GraphLayout.js b/js/GraphLayout.js index e95d8e8..7d78163 100644 --- a/js/GraphLayout.js +++ b/js/GraphLayout.js @@ -25,7 +25,7 @@ class GraphLayout { // selected words to generate graph around this.words = []; - this.distanceFromRoot = 30; // default value for max dist from root + this.maxDepth = 30; // default value for max dist from root this.data = { flat: {}, anchors: [], @@ -34,14 +34,6 @@ class GraphLayout { // force simulation this.simulation = d3.forceSimulation() - .force('link', d3.forceLink().id(d => d.id)) - .force('collision', d3.forceCollide(d => { - return d.role === "link-anchor" ? 0 : 20; - })) - .force('charge', d3.forceManyBody() - .strength(d => d.role === "link-anchor" ? 0 : -30) - .distanceMax(100) - ) .force('center', d3.forceCenter( 0,0 )); } @@ -75,10 +67,11 @@ class GraphLayout { if (this.words.length === words.length && this.words.every((w,i) => words[i] === w)) { return; } else { this.words = words; } - this.generateData(); console.log('data', this.data); + return; + // draw nodes this.drawNodes(); @@ -90,102 +83,57 @@ class GraphLayout { } generateData() { - // flatten nodes/links within a given distance of selected words - var d = this.data.flat = {}; + console.log(this.words); + const d = this.data.flat = {}; + const maxDepth = this.maxDepth; this.words.forEach(root => { - var maxDepth = this.distanceFromRoot; function addToDataset(node,depth) { if (depth > maxDepth) { return; } // done if (d[node.id] && d[node.id].depth <= depth) { // skip return; } - if (node.type === "WORD") { + if (node instanceof Word) { d[node.id] = { id: node.id, depth: depth, data: node } } - else if (node.type === "LINK") { + else if (node instanceof Link) { d[node.id] = { id: node.id, depth: depth, data: node } // recurse to start/endpoint - if (node.s) { addToDataset(node.s, depth + 1); } - if (node.e) { addToDataset(node.e, depth + 1); } + if (node.words) { + node.words.forEach(anchor => addToDataset(anchor, depth + 1)); + } } // recurse to adjacent links - var links = [].concat( node.parentsL, node.parentsR ); + var links = [].concat( node.parentsL, node.parentsC, node.parentsR ); links.forEach(l => addToDataset(l, depth + 1)); } addToDataset(root, 0); }); // sort flat data into nodes and links - var a = this.data.anchors = []; - var l = this.data.links = []; + const a = this.data.anchors = []; + const l = this.data.links = []; - for (var i in d) { - if (d[i].data.type === "WORD") { - d[i].role = "word"; - a.push(d[i]); + for (var datum in d) { + if (d[datum].data instanceof Word) { + a.push(d[datum]); } else { - d[i].stops = []; - d[i].role = "link"; - l.push(d[i]); + l.push(d[datum]); } } - // identify anchors (endpoints of links): can be words or other links - function getAnchorPoint(node) { - if (d[node.id]) { - if (d[node.id].role === "word") { - return d[node.id]; - } - else { - // create anchor point along link - var linkAnchor = { - id: node.id, - data: node, - role: "link-anchor", - link: d[node.id] - }; - linkAnchor.link.stops.push(linkAnchor); // circular ref - a.push(linkAnchor); - return linkAnchor; - } - } - else { - // endpoint not in range of data - var emptyNode = { - id: node.id, - data:node, - role: "nil" - }; - a.push(emptyNode); - return emptyNode; - } - } + console.log(a, l); - l.forEach(link => { - var s = link.data.s, - e = link.data.e; - - link.source = getAnchorPoint(s); - link.target = getAnchorPoint(e); - }); - // evenly space stops on initialization - l.forEach(link => { - var tmax = link.stops.length + 1; - link.stops.forEach((stop,i) => { - stop.t = (i + 1)/tmax; - }) - }) }//end generateData() drawNodes() { @@ -202,126 +150,18 @@ class GraphLayout { d.fy = d.y; }) .on('drag', function(d) { - if (d.role !== "link-anchor") { - d.fx += d3.event.dx, - d.fy += d3.event.dy; - } - else { - // get distance to source/target - var nsDx = d.link.source.x - d.x, - nsDy = d.link.source.y - d.y, - ntDx = d.link.target.x - d.x, - ntDy = d.link.target.y - d.y, - - esDx = d.link.source.x - d3.event.x, - esDy = d.link.source.y - d3.event.y, - etDx = d.link.target.x - d3.event.x, - etDy = d.link.target.y - d3.event.y; - - var nodeDistanceToSource = nsDx*nsDx + nsDy*nsDy, - nodeDistanceToTarget = ntDx*ntDx + ntDy*ntDy, - dragDistanceToSource = esDx*esDx + esDy*esDy, - dragDistanceToTarget = etDx*etDx + etDy*etDy; - - var direction = 0; - if (dragDistanceToSource < nodeDistanceToSource) { - direction = -0.01; - } - else if (dragDistanceToTarget < nodeDistanceToTarget) { - direction = 0.01; - } - else { - direction = dragDistanceToSource { if (!d3.event.active) { sim.alphaTarget(0); } - if (d.role !== "link-anchor") { - d.fx = d.fy = null; - } }); // data entry/merge - var nodeGroup = this.nodes.selectAll('.node-group') - .data(this.data.anchors); - - nodeGroup.exit().remove(); - var nodeEnter = nodeGroup.enter().append('g') - .attr('class','node-group') - .attr("transform", () => { - return 'translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'; - }); - - nodeEnter.append('circle') - .attr('class','node'); - var label = nodeEnter.append('g') - .attr('class','node-label') - .attr('pointer-events','none') - .attr('transform','translate(10,-5)'); - label.append('text') - .style('font-size','0.8em') - .attr('text-anchor','start'); - label.append('rect') - .attr('rx',1) - .attr('ry',1) - .attr('fill', '#fafaea') - .attr('stroke','#cacabc'); - - nodeGroup = nodeGroup.merge(nodeEnter); - nodeGroup - .classed('node-word', d => d.role === 'word') - .on('mouseover', (d) => { - function mouseoverWord(word) { - // TODO: link back to word in "drawing" svg - - } - if (d.role === "word") { mouseoverWord( d.data ); } - console.log('moused over',d) - }) - .on('mouseout', (d) => { - function mouseoutWord(word) { - - } - }) - .call(drag); - - // draw circle - var node = nodeGroup.selectAll('.node') - .data(d => [d]) - .attr('r',(d) => d.role === 'word' ? 7 : 4) - .attr('stroke', 'rgba(0,0,0,0.2)') - .attr('fill',(d) => { - if (d.role !== 'word') { - return 'transparent'; - } - else { - return colors((d.depth+2)/10); - } - }); - - // draw text label - label = nodeGroup.selectAll('.node-label') - .raise() - .data(d => [d]); - - label.select('text') - .text(d => d.role === "word" ? d.data.val : '') - .attr('x',5); - label.select('rect') - .style('display', d => d.role === "word" ? "block" : "none") - .attr('width', function() { - return this.parentNode.getElementsByTagName('text')[0].getBBox().width + 10; - }) - .attr('height','1.5em') - .attr('y','-1em') - .lower(); - - this.nodes.selectAll('.node-word').raise(); + // var nodeGroup = this.nodes.selectAll('.node-group') + // .data(this.data.anchors); } drawLinks() { @@ -354,38 +194,9 @@ class GraphLayout { function tick() { node - .datum(d => { - if (d.role === "link-anchor") { - // get position of link-anchor on line - var target = d.link.target, - source = d.link.source; - - var dx = target.x - source.x, - dy = target.y - source.y, - dr = Math.sqrt( dx * dx + dy * dy); - - if (dr === 0) { - d.fx = target.x, - d.fy = target.y; - return d; - } - - var sin60 = Math.sqrt(3)/2; - var cx = source.x + dx * 0.5 - dy * sin60, - cy = source.y + dy * 0.5 + dx * sin60; - - var acos = Math.acos( (source.x - cx)/dr ), - asin = Math.asin( (source.y - cy)/dr ); - - var theta = (asin < 0) ? -acos : acos; - - d.fx = cx + dr*Math.cos(theta + Math.PI/3 * d.t), - d.fy = cy + dr*Math.sin(theta + Math.PI/3 * d.t); - } - else { - d.x = clampX(d.x); - d.y = clampY(d.y); - } + .datum(d => { + d.x = clampX(d.x); + d.y = clampY(d.y); return d; }) .attr("transform", (d) => { @@ -395,7 +206,6 @@ class GraphLayout { link .attr('d', arrowPath); - function arrowPath(d,i) { var target = d.target, source = d.source; @@ -404,10 +214,6 @@ class GraphLayout { dy = target.y - source.y, dr = Math.sqrt( dx * dx + dy * dy); - // if (target.role === "link-anchor" || source.role === "link-anchor") { - // dr /= 2; - // } - return "M" + source.x + "," + source.y + "A" + dr + "," + dr + " 0 0,1 " + target.x + "," + target.y; @@ -418,8 +224,6 @@ class GraphLayout { .nodes(this.data.anchors) .on('tick', tick); - // this.simulation.force('link').links(this.data.links); - if (this.simulation.alpha() < 0.1) { this.simulation.alpha(0.3).restart(); } diff --git a/js/annotate.js b/js/annotate.js index 6f916d8..6cd983b 100644 --- a/js/annotate.js +++ b/js/annotate.js @@ -257,10 +257,10 @@ class Word { this.leftX = this.tempX; this.rightX = this.tempX + this.tempW; - this.percPos = (this.leftX-edgepadding) / (svgWidth-edgepadding*2); + this.percPos = (this.leftX-Config.edgePadding) / (Config.svgWidth-Config.edgePadding*2); this.leftHandle.x(this.tempX); - this.rightHandle.x(this.rightX - handleW); + this.rightHandle.x(this.rightX - Config.handleW); } draw() { @@ -269,12 +269,12 @@ class Word { } getMinWidth() { //min width is the maximum of: the word text, the tag text, or the size of the two handles + a little bit - return Math.max(minWordWidth, this.maxtextw); + return Math.max(Config.minWordWidth, this.maxtextw); } - //getMaxWidth() must return a value less than row width - edgepaddings, else will try to reposition long words forever!!! + //getMaxWidth() must return a value less than row width - Config.edgePaddings, else will try to reposition long words forever!!! getMaxWidth() { - return (this.row.rect.width() - (edgepadding*2)) / 3.1; + return (this.row.rect.width() - (Config.edgePadding*2)) / 3.1; } toString() { @@ -291,7 +291,7 @@ class Word { function checkSlotAvailabity(num, slotArr) { - if (debug) { + if (Config.debug) { if (slotArr.indexOf(num) < 0) { ////console.log("slot " + num + " not found..." ); } else { @@ -633,11 +633,11 @@ function createLink(link) { if (link.leftType == types.WORD && link.rightType == types.WORD) { - calcAttachPoints(link, word2word_strategy); + calcAttachPoints(link, Config.word2word_strategy); } else if (link.leftType == types.LINK && link.rightType == types.LINK) { - calcAttachPoints(link, link2link_strategy); + calcAttachPoints(link, Config.link2link_strategy); } else { - calcAttachPoints(link, word2link_strategy); + calcAttachPoints(link, Config.word2link_strategy); } @@ -736,11 +736,11 @@ function determineParentLinkOffsets(word, side, parentLinks, totalAttachmentPoin if (totalAttachmentPoints <= 1) { console.log("here totalAttachmentPoints = " + totalAttachmentPoints); pinc = 0.5; - poff = 0.5; //attachmentMargin + (pinc * offsetIdx); + poff = 0.5; //Config.attachmentMargin + (pinc * offsetIdx); } else { - pinc = ((1.0 - (attachmentMargin*2))*1.0) / (totalAttachmentPoints - 1); - poff = attachmentMargin + (pinc * offsetIdx); + pinc = ((1.0 - (Config.attachmentMargin*2))*1.0) / (totalAttachmentPoints - 1); + poff = Config.attachmentMargin + (pinc * offsetIdx); } console.log("poff = " + poff); diff --git a/js/config.js b/js/config.js new file mode 100644 index 0000000..954b9c6 --- /dev/null +++ b/js/config.js @@ -0,0 +1,40 @@ +const Config = { + debug: true, + svgWidth: window.innerWidth - 16, + svgHeight: 1000, + evenRowsColor: '#efeff4', + oddRowsColor: '#dddddf', + rowEdgeColor: 'transparent', + levelPadding: 16, + textPaddingX: 8, + textPaddingY: 6, + wordPadding: 4, + edgePadding: 10, + rowPadding: 30, + hideLinkLinesPercentage: 3.0, //percentage at which links and arrows are hidden + hideLinkTextPercentage: 7.0, //percentage at which words are link words are hidden + handleW: 10, + handleH: 16, + handleColor: '#ff0000', + handleOpacity: 0.1, + arrowH: 5, + arrowMH: 5, + arrowW: 3, + wordHeight: 16, + minWordWidth:25, + evenRowsColor_selected: '#cdcdff', + oddRowsColor_selected: '#bbbbff', + dragRectSide: 8, + dragRectMargin: 1, + dragDir: 0, + linkStrokeThickness: 1.5, + linkStrokeColor: '#cc9999', + linkStrokeOpacity: 1, + linkStrokeThickness_selected: 1.5, + linkStrokeColor_selected: '#449944', + linkStrokeOpacity_selected: 1.0, + attachmentMargin: 0.1, + word2word_strategy: strategies.FARTHEST, + word2link_strategy: strategies.CLOSEST, + link2link_strategy: strategies.FARTHEST //CLOSEST sometimes causes overlaps - need to be a bit more rigorous when assigning slots - don't assign any slots that have the potential to overlap (when dragged manually)? - or let the buyer beware that this could happen - they can always move out of the way - right now it won't automatically overlap, but won't prevent a user from doing it. +}; \ No newline at end of file diff --git a/js/interact.js b/js/interact.js index 02983f7..7f72dc4 100644 --- a/js/interact.js +++ b/js/interact.js @@ -49,7 +49,6 @@ function setupMouseOverInteractions(word) { function mover(word){ // console.log("in mover for " + word.val); - word.isHovered = true; if (word.isSelected) { @@ -308,23 +307,23 @@ function manageDrag(arrowSVG, x, y, lo, arrowInfo, arrowIdx) { var word = arrowInfo.word; // if (side == sides.LEFT) { - var xPos = (x - leftX) + arrowW; + var xPos = (x - leftX) + Config.arrowW; var percentage = xPos / (linkWidth/1); var ux = x; if (percentage < 0.0) { console.log("AAA"); percentage = 0.0; - ux = leftX - arrowW; + ux = leftX - Config.arrowW; } else if (percentage > 1.0) { console.log("BBB"); percentage = 1.0; - ux = rightX - arrowW; + ux = rightX - Config.arrowW; } /* } else if (side == sides.RIGHT) { - var xPos = linkWidth - ((x - leftX) + arrowW); + var xPos = linkWidth - ((x - leftX) + Config.arrowW); var percentage = xPos / (linkWidth/1); var ux = x; @@ -332,11 +331,11 @@ function manageDrag(arrowSVG, x, y, lo, arrowInfo, arrowIdx) { if (percentage < 0.0) { console.log("CCC"); percentage = 0.0; - ux = rightX - arrowW; + ux = rightX - Config.arrowW; } else if (percentage > 1.0) { console.log("DDD"); percentage = 1.0; - ux = leftX - arrowW; + ux = leftX - Config.arrowW; } } @@ -373,7 +372,7 @@ console.log("percentage for arrowIdx ("+arrowIdx+") = " + percentage); if (side == sides.LEFT) { - var xPos = (x - leftX) + arrowW; + var xPos = (x - leftX) + Config.arrowW; //console.log("x = " + x + ", xPos = " + xPos); var percentage = xPos / (linkWidth/2); @@ -381,24 +380,24 @@ var ux = x; if (percentage < 0.0) { percentage = 0.0; -ux = leftX - arrowW; +ux = leftX - Config.arrowW; } else if (percentage > 2.0) { percentage = 2.0; -ux = leftX - arrowW + (linkWidth/2); +ux = leftX - Config.arrowW + (linkWidth/2); } } else if (side == sides.RIGHT) { -var xPos = linkWidth - ((x - leftX) + arrowW); +var xPos = linkWidth - ((x - leftX) + Config.arrowW); var percentage = xPos / (linkWidth/2); var ux = x; if (percentage < 0.0) { percentage = 0.0; -ux = leftX - arrowW; +ux = leftX - Config.arrowW; } else if (percentage > 2.0) { percentage = 2.0; -ux = leftX - arrowW + (linkWidth); +ux = leftX - Config.arrowW + (linkWidth); } } @@ -519,13 +518,13 @@ function dragRightHandle(x, y, word) { } function checkIfCanDragRightHandleLeft(x, y, word) { - var rw = Math.max( Math.min(word.getMaxWidth(), (x - word.leftX + handleW)), word.getMinWidth() ); + var rw = Math.max( Math.min(word.getMaxWidth(), (x - word.leftX + Config.handleW)), word.getMinWidth() ); setWordToXW(word, word.leftX, rw); - var rv = checkIfCanMoveLeft(x - (rw - handleW), rw, y, word, false); - //rv.x = word.leftX + rw - handleW; - rv.x = word.tempX + word.tempW - handleW; + var rv = checkIfCanMoveLeft(x - (rw - Config.handleW), rw, y, word, false); + //rv.x = word.leftX + rw - Config.handleW; + rv.x = word.tempX + word.tempW - Config.handleW; rv.y = word.y; return rv; @@ -535,14 +534,14 @@ function checkIfCanDragRightHandleLeft(x, y, word) { function checkIfCanDragRightHandleRight(x, y, word) { - var rw = Math.max( Math.min(word.getMaxWidth(), (x - word.leftX + handleW) ), word.getMinWidth() ); + var rw = Math.max( Math.min(word.getMaxWidth(), (x - word.leftX + Config.handleW) ), word.getMinWidth() ); setWordToXW(word, word.leftX, rw); - var rv = checkIfCanMoveRight(x - (rw - handleW), rw, y, word, false); - //rv.x = word.leftX + rw - handleW; - // rv.x = word.rightX - handleW; - rv.x = word.tempX + word.tempW - handleW; + var rv = checkIfCanMoveRight(x - (rw - Config.handleW), rw, y, word, false); + //rv.x = word.leftX + rw - Config.handleW; + // rv.x = word.rightX - Config.handleW; + rv.x = word.tempX + word.tempW - Config.handleW; rv.y = word.y; // return {x, y:word.rightHandle.bbox().y}; @@ -584,10 +583,10 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) { w = origXW - rx; } } else { - //make sure our X val isn't *before* the leftmost edgepadding - if (x < edgepadding) { + //make sure our X val isn't *before* the leftmost Config.edgePadding + if (x < Config.edgePadding) { var origXW = word.rightX; - rx = edgepadding; + rx = Config.edgePadding; w = origXW - rx; } } @@ -602,7 +601,7 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) { if (posInRow == word.row.words.length - 1) { //did i hit the right side of the row? - if (x+w > svgWidth - (edgepadding)) { + if (x+w > Config.svgWidth - (Config.edgePadding)) { if (word.row.idx == rows.length - 1 ) { //then we're on the last row appendRow(); @@ -612,7 +611,7 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) { //handle drag offset if i am dragging this word if (word == rowOffsetWord) { - rowOffsetX -= (svgWidth - (2*edgepadding) - (w) ); + rowOffsetX -= (Config.svgWidth - (2*Config.edgePadding) - (w) ); } rx = vals.x; @@ -679,24 +678,24 @@ function checkIfCanMoveLeft(x, w, y, word, adjustWidth) { if (posInRow == 0) { //did i hit the left side of the row? - if (x < edgepadding) { + if (x < Config.edgePadding) { if (word.row.idx > 0 && checkIfSpaceToMoveUpARow(w, rows[word.row.idx - 1]) == true) { moveWordUpARow(word); //handle drag offset if i am dragging this word if (word == rowOffsetWord) { - rowOffsetX += (svgWidth - (2*edgepadding) - (w) ); + rowOffsetX += (Config.svgWidth - (2*Config.edgePadding) - (w) ); } - rx = svgWidth - edgepadding - w; + rx = Config.svgWidth - Config.edgePadding - w; ry = word.bbox.y; //refire this checkIfCanMoveLeft, since it will push words on the previous row out of the way, if needed -- may break up this method into little pieces so can fire something more granular checkIfCanMoveLeft(rx, w, y, word, false); } else { - rx = edgepadding; //on top row, so can't move left of left margin + rx = Config.edgePadding; //on top row, so can't move left of left margin } } } @@ -764,13 +763,13 @@ function moveWordToNewPosition(w, nx, ny) { w.leftX = nx; w.rightX = nx + w.bbox.w; - w.percPos = (w.leftX-edgepadding) / (svgWidth-edgepadding*2); + w.percPos = (w.leftX-Config.edgePadding) / (Config.svgWidth-Config.edgePadding*2); w.underneathRect.x(nx); w.underneathRect.y(ny); w.text.x(nx + (w.bbox.w/2) - (w.text.bbox().w/2) ); - w.text.y(ny + textpaddingY*2); // - texts.wordText.descent); + w.text.y(ny + Config.textPaddingY*2); // - texts.wordText.descent); @@ -779,7 +778,7 @@ function moveWordToNewPosition(w, nx, ny) { if (w.tag != null) { w.tagtext.x(nx + (w.bbox.w/2) - (w.tagtext.bbox().w/2) ); - w.tagtext.y(ny + textpaddingY/2);// - texts.tagText.descent); + w.tagtext.y(ny + Config.textPaddingY/2);// - texts.tagText.descent); } console.log("ny = " + ny); @@ -790,11 +789,11 @@ function moveWordToNewPosition(w, nx, ny) { - var handley = ny + ( w.wh / 2 ) - ( handleH / 2 ); + var handley = ny + ( w.wh / 2 ) - ( Config.handleH / 2 ); w.leftHandle.x(nx); w.leftHandle.y(handley); - w.rightHandle.x( w.rightX - handleW ); + w.rightHandle.x( w.rightX - Config.handleW ); w.rightHandle.y(handley); w.needsUpdate = true; @@ -825,7 +824,7 @@ function dragWord(x, y, word) { function checkIfSpaceToMoveUpARow(width, prevRow) { var cw = width; - var rowWidth = svgWidth - (edgepadding*2); + var rowWidth = Config.svgWidth - (Config.edgePadding*2); for (var i = prevRow.words.length - 1; i >= 0; i--) { prevWord = prevRow.words[i]; @@ -854,7 +853,7 @@ function checkIfSpaceToMoveUpARow(width, prevRow) { function checkIfSpaceToMoveDownARow(width, nextRow) { var cw = width; - var rowWidth = svgWidth - (edgepadding*2); + var rowWidth = Config.svgWidth - (Config.edgePadding*2); //how many words on the next row would have to move forward for this word to fit on the next row? for (var i = 0; i < nextRow.words.length; i++) { @@ -892,7 +891,7 @@ function moveWordDownARow(w) { var w = rows[currentRowIdx].words.pop(); rows[nextRowIdx].words.unshift(w); w.row = rows[nextRowIdx]; - var nx = edgepadding; + var nx = Config.edgePadding; var ny = w.row.ry + w.row.rh - w.wh; @@ -918,9 +917,9 @@ function moveWordUpARow(w) { var ny = w.row.ry + w.row.rh - w.wh; if (w.needsUpdate) { - nx = svgWidth - edgepadding - w.tempW; + nx = Config.svgWidth - Config.edgePadding - w.tempW; } else { - nx = svgWidth - edgepadding - (w.rightX - w.leftX); //w.aboveRect.width(); + nx = Config.svgWidth - Config.edgePadding - (w.rightX - w.leftX); //w.aboveRect.width(); } moveWordToNewPosition(w, nx, ny); @@ -974,7 +973,7 @@ function dragRow(x, y, row) { if (row.idx < rows.length - 1) { - nextY = (rows[row.idx + 1].lineBottom.bbox().y - wordHeight ) - (dragRectSide + dragRectMargin) - rowpadding/2 ; + nextY = (rows[row.idx + 1].lineBottom.bbox().y - Config.wordHeight ) - (Config.dragRectSide + Config.dragRectMargin) - Config.rowPadding/2 ; if (y > nextY) { nextRowTooSmall = true; @@ -983,17 +982,17 @@ function dragRow(x, y, row) { //check that this row height is not smaller than the max word height in the row - if (inc + dragRectSide + dragRectMargin < wordHeight) { - row.rect.height(wordHeight); - y = row.rect.bbox().y + row.rect.bbox().h - (dragRectSide + dragRectMargin); - row.lineBottom.y(y + dragRectSide + dragRectMargin); + if (inc + Config.dragRectSide + Config.dragRectMargin < Config.wordHeight) { + row.rect.height(Config.wordHeight); + y = row.rect.bbox().y + row.rect.bbox().h - (Config.dragRectSide + Config.dragRectMargin); + row.lineBottom.y(y + Config.dragRectSide + Config.dragRectMargin); } else if (row.idx < rows.length - 1 && nextRowTooSmall == true) { //check that this row is not expanding so large that it is bigger than the next row's smallest size y = nextY; - row.lineBottom.y(y + dragRectSide + dragRectMargin ); - row.rect.height((y - prevY) + dragRectSide + dragRectMargin); + row.lineBottom.y(y + Config.dragRectSide + Config.dragRectMargin ); + row.rect.height((y - prevY) + Config.dragRectSide + Config.dragRectMargin); } else { //this y val is fine - row.rect.height(inc + dragRectSide + dragRectMargin); - row.lineBottom.y(y + dragRectSide + dragRectMargin); + row.rect.height(inc + Config.dragRectSide + Config.dragRectMargin); + row.lineBottom.y(y + Config.dragRectSide + Config.dragRectMargin); } row.ry = row.rect.y(); @@ -1005,19 +1004,19 @@ function dragRow(x, y, row) { //updateLinksOfWord(row.words[i]); } - row.baseHeight = row.lineBottom.y() - (textpaddingY*2) - texts.wordText.maxHeight; + row.baseHeight = row.lineBottom.y() - (Config.textPaddingY*2) - texts.wordText.maxHeight; if (row.idx < rows.length - 1) { var nextrow = rows[row.idx + 1]; - nextrow.rect.y(row.rect.bbox().y + row.rect.bbox().h + rowpadding/2); - nextrow.rect.height( nextrow.dragRect.bbox().y - y - (rowpadding/2)); + nextrow.rect.y(row.rect.bbox().y + row.rect.bbox().h + Config.rowPadding/2); + nextrow.rect.height( nextrow.dragRect.bbox().y - y - (Config.rowPadding/2)); nextrow.ry = nextrow.rect.y(); nextrow.rh = nextrow.rect.height(); - nextrow.lineTop.y(row.rect.bbox().y + row.rect.bbox().h + rowpadding/2); + nextrow.lineTop.y(row.rect.bbox().y + row.rect.bbox().h + Config.rowPadding/2); for (var i = 0; i < nextrow.words.length; i++) { //updateLinksOfWord(nextrow.words[i]); @@ -1045,10 +1044,10 @@ function setWordToY(word, wy) { word.underneathRect.y(wy); word.leftHandle.y(wy); word.rightHandle.y(wy); - word.text.y(word.bbox.y + textpaddingY*2); + word.text.y(word.bbox.y + Config.textPaddingY*2); if (word.tag != null) { - word.tagtext.y(word.bbox.y + textpaddingY/2); + word.tagtext.y(word.bbox.y + Config.textPaddingY/2); } } diff --git a/js/parser.js b/js/parser.js new file mode 100644 index 0000000..69d8c88 --- /dev/null +++ b/js/parser.js @@ -0,0 +1,100 @@ +class Parser { + constructor() { + this.text = ""; + this.tokens = []; + this.data = {}; + } + + /* load a json from a path */ + readJson(path, callback) { + + var json = path || './data/data1.json'; + + function loadJSON(path, callback2) { + var httpRequest = new XMLHttpRequest(); + httpRequest.onreadystatechange = function() { + if (httpRequest.readyState === 4) { + if (httpRequest.status === 200) { + var data = JSON.parse(httpRequest.responseText); + if (callback2) { + callback2(data); + } + if (callback) { + callback(); + } + } + } + }; + httpRequest.open('GET', path); + httpRequest.send(); + } + + /* parse json file*/ + loadJSON(json, this.parseData.bind(this)); + } + + /** + * parse a json file + */ + parseData(data) { + /* first get string tokens from the syntaxData */ + this.text = data.syntaxData.text; + this.tokens = data.syntaxData.entities + .map(x => x[2][0]) + .sort((a, b) => a[0] - b[0]) + .map(interval => this.text.substring(interval[0], interval[1])); + + /* parse the event data: entities, triggers, events, and relations */ + const e = data.eventData; + const entities = e.entities.map(arr => { + return { + id: arr[0], + type: arr[1], + interval: arr[2][0], + string: e.text.substring(arr[2][0][0], arr[2][0][1]) + }; + }); + + const triggers = e.triggers.map(arr => { + return { + id: arr[0], + type: arr[1], + interval: arr[2][0], + string: e.text.substring(arr[2][0][0], arr[2][0][1]) + }; + }); + + const events = e.events.map(arr => { + return { + id: arr[0], + trigger: arr[1], + arguments: arr[2].map(argument => { + return { + id: argument[1], + type: argument[0] + }; + }) + }; + }); + + const relations = e.relations.map(arr => { + return { + id: arr[0], + type: arr[1], + arguments: arr[2].map(argument => { + return { + id: argument[1], + type: argument[0] + }; + }) + }; + }); + + this.data = { + entities, + triggers, + events, + relations + }; + } +} \ No newline at end of file diff --git a/js/render.js b/js/render.js index 07a7e54..4c77f65 100644 --- a/js/render.js +++ b/js/render.js @@ -75,7 +75,7 @@ function checkIfEverythingFits(row) { } if (ii == row.words.length - 1) { - if (word.rightX > (svgWidth - edgepadding) ) { + if (word.rightX > (Config.svgWidth - Config.edgePadding) ) { return false; } } @@ -93,8 +93,8 @@ function checkIfNeedToResizeWords(row) { totalW += word.aboveRect.width(); } - if (totalW > svgWidth - (edgepadding*2)) { - return totalW - (svgWidth - (edgepadding*2)); + if (totalW > Config.svgWidth - (Config.edgePadding*2)) { + return totalW - (Config.svgWidth - (Config.edgePadding*2)); } return 0; @@ -115,7 +115,7 @@ function recalculateRows(percChange) { row.lineTop.plot(0, row.ry, draw.width(), row.ry); row.lineBottom.plot(0, row.ry+row.rh, draw.width(), row.ry+row.rh); - row.dragRect.x(draw.width() - (dragRectSide+dragRectMargin)); + row.dragRect.x(draw.width() - (Config.dragRectSide+Config.dragRectMargin)); //first pass at resizing @@ -130,7 +130,7 @@ function recalculateRows(percChange) { //var nw = Math.max(word.getMinWidth(), word.aboveRect.width() * percChange); //nw = Math.max(nw, word.getMaxWidth()); - var nx = edgepadding + (word.percPos * (svgWidth-edgepadding*2)); + var nx = Config.edgePadding + (word.percPos * (Config.svgWidth-Config.edgePadding*2)); setWordToXW(word, nx, nw); word.update(); @@ -154,7 +154,7 @@ function recalculateRows(percChange) { var wordsFitInRow = true; - if (row.getMinWidth() > (svgWidth - edgepadding*2)) { + if (row.getMinWidth() > (Config.svgWidth - Config.edgePadding*2)) { //console.log("words will not fit in row! have to adjust..."); wordsFitInRow = false; } @@ -270,8 +270,8 @@ function removeLastRow() { function changeSizeOfSVGPanel(w, h) { - svgWidth = w; - svgHeight = h; + Config.svgWidth = w; + Config.svgHeight = h; draw.size(w, h); } @@ -283,13 +283,13 @@ function appendRow() { row.maxSlots = 0; - row.ry = rowpadding/2 + rows[row.idx - 1].rect.bbox().y + rows[row.idx - 1].rect.bbox().h; + row.ry = Config.rowPadding/2 + rows[row.idx - 1].rect.bbox().y + rows[row.idx - 1].rect.bbox().h; row.rh = rows[row.idx - 1].rect.bbox().h; if (row.idx % 2 == 0) { - row.color = evenRowsColor; + row.color = Config.evenRowsColor; } else { - row.color = oddRowsColor; + row.color = Config.oddRowsColor; } drawRow(row); @@ -300,7 +300,7 @@ function appendRow() { function drawRow(row) { - row.rect = rowGroup.rect(svgWidth,row.rh).x(0).y(row.ry); + row.rect = rowGroup.rect(Config.svgWidth,row.rh).x(0).y(row.ry); if (row.idx % 2 == 0) { row.rect.style(styles.rowRectEvenFill.style); @@ -308,13 +308,13 @@ function drawRow(row) { row.rect.style(styles.rowRectOddFill.style); } - row.lineTop = rowGroup.line(0, row.ry, svgWidth, row.ry).style(styles.rowLineStroke.style); - row.lineBottom = rowGroup.line(0, row.ry+row.rh, svgWidth, row.ry+row.rh).style(styles.rowLineStroke.style); + row.lineTop = rowGroup.line(0, row.ry, Config.svgWidth, row.ry).style(styles.rowLineStroke.style); + row.lineBottom = rowGroup.line(0, row.ry+row.rh, Config.svgWidth, row.ry+row.rh).style(styles.rowLineStroke.style); - row.dragRect = rowGroup.rect(dragRectSide,dragRectSide).x(svgWidth - (dragRectSide+dragRectMargin)).y(row.ry + row.rh - (dragRectSide+dragRectMargin)).style(styles.rowDragRectFill.style); + row.dragRect = rowGroup.rect(Config.dragRectSide,Config.dragRectSide).x(Config.svgWidth - (Config.dragRectSide+Config.dragRectMargin)).y(row.ry + row.rh - (Config.dragRectSide+Config.dragRectMargin)).style(styles.rowDragRectFill.style); - row.baseHeight = row.lineBottom.y() - (textpaddingY*2) - texts.wordText.maxHeight; + row.baseHeight = row.lineBottom.y() - (Config.textPaddingY*2) - texts.wordText.maxHeight; setUpRowDraggable(row); } @@ -370,16 +370,16 @@ function setUpRowsAndWords(words) { rows.push(row); row.maxSlots = 0; - x = edgepadding; + x = Config.edgePadding; - } else if (x + word.tw + (textpaddingX*2) + edgepadding > svgWidth) { //if would be wider than the screen width, then start a new row + } else if (x + word.tw + (Config.textPaddingX*2) + Config.edgePadding > Config.svgWidth) { //if would be wider than the screen width, then start a new row rowNum++; row = new Row(rowNum); rows.push(row); row.maxSlots = 0; - x = edgepadding; + x = Config.edgePadding; } row.words.push(word); @@ -389,15 +389,15 @@ function setUpRowsAndWords(words) { //calculate x position and width of the Word word.wx = x; - word.ww = word.tw + (textpaddingX * 2); + word.ww = word.tw + (Config.textPaddingX * 2); if (word.tag != null) { - word.tww = word.ww; //maxtextw + (textpaddingX * 2); + word.tww = word.ww; //maxtextw + (Config.textPaddingX * 2); word.twx = word.wx; } - x += word.ww + wordpadding; + x += word.ww + Config.wordPadding; } @@ -407,29 +407,29 @@ function setUpRowsAndWords(words) { var row = rows[i]; if (i == 0) { - row.ry = rowpadding / 2; + row.ry = Config.rowPadding / 2; } else { - row.ry = rowpadding / 2 + rows[row.idx - 1].ry + rows[row.idx - 1].rh; + row.ry = Config.rowPadding / 2 + rows[row.idx - 1].ry + rows[row.idx - 1].rh; } - row.rh = rowpadding + ((textpaddingY * 2) + texts.wordText.maxHeight) + (levelpadding * row.maxSlots); + row.rh = Config.rowPadding + ((Config.textPaddingY * 2) + texts.wordText.maxHeight) + (Config.levelPadding * row.maxSlots); if (row.idx % 2 == 0) { - row.color = evenRowsColor; + row.color = Config.evenRowsColor; } else { - row.color = oddRowsColor; + row.color = Config.oddRowsColor; } for (var ii = 0; ii < row.words.length; ii++) { var word = row.words[ii]; word.h = 0; //the number of link levels is 0 for the word itself - word.wh = texts.wordText.maxHeight + textpaddingY*2; + word.wh = texts.wordText.maxHeight + Config.textPaddingY*2; word.wy = row.ry + row.rh - word.wh; if (word.tag != null) { var tag_textwh = getTextWidthAndHeight(word.tag, texts.tagText.style); - word.twh = texts.tagText.maxHeight + textpaddingY*2; + word.twh = texts.tagText.maxHeight + Config.textPaddingY*2; word.twy = word.wy - word.twh; } @@ -448,7 +448,7 @@ function drawWord(word) { word.text = draw.text(function(add) { add.text(word.val) - .y(word.wy + textpaddingY*2) // - texts.wordText.descent) + .y(word.wy + Config.textPaddingY*2) // - texts.wordText.descent) .x(word.wx + (word.ww/2) - (textwh.w / 2)) .font(texts.wordText.style); }); @@ -462,7 +462,7 @@ function drawWord(word) { word.tagtext = draw.text(function(add) { add.text(word.tag) - .y(word.wy + textpaddingY/2) // - texts.tagText.descent) + .y(word.wy + Config.textPaddingY/2) // - texts.tagText.descent) .x(tagXPos) .font(texts.tagText.style); }); @@ -471,16 +471,16 @@ function drawWord(word) { //this rect is invisible, but used for detecting mouseevents, as its drawn on top of the text+underneathRect (which provided the color+fill+stroke) word.aboveRect = draw.rect(word.ww, word.wh).x( word.wx ).y( word.wy ).fill( {color:'#fff',opacity: 0.0} ); - word.leftHandle = draw.rect(handleW, handleH).x(word.wx).y( word.wy + (word.wh / 2 ) - (handleH / 2) ).style(styles.handleFill.style); + word.leftHandle = draw.rect(Config.handleW, Config.handleH).x(word.wx).y( word.wy + (word.wh / 2 ) - (Config.handleH / 2) ).style(styles.handleFill.style); - word.rightHandle = draw.rect(handleW,handleH).x(word.wx + word.ww - (handleW)).y( word.wy + (word.wh / 2 ) - (handleH / 2) ).style(styles.handleFill.style); + word.rightHandle = draw.rect(Config.handleW,Config.handleH).x(word.wx + word.ww - (Config.handleW)).y( word.wy + (word.wh / 2 ) - (Config.handleH / 2) ).style(styles.handleFill.style); word.bbox = word.aboveRect.bbox(); word.leftX = word.aboveRect.bbox().x; word.rightX = word.aboveRect.bbox().x + word.aboveRect.bbox().w; - word.percPos = (word.leftX-edgepadding) / (svgWidth-edgepadding*2); + word.percPos = (word.leftX-Config.edgePadding) / (Config.svgWidth-Config.edgePadding*2); //set up mouse interactions @@ -908,10 +908,10 @@ function getLinkStyles(link, xpts) { var middleLength = 0; if (link.numLineSegments > 2) { - middleLength = (svgWidth-edgepadding*2) * (link.numLineSegments - 2); + middleLength = (Config.svgWidth-Config.edgePadding*2) * (link.numLineSegments - 2); } - var firstLength = (svgWidth-edgepadding) - left; - var lastLength = right - edgepadding; + var firstLength = (Config.svgWidth-Config.edgePadding) - left; + var lastLength = right - Config.edgePadding; var totalLength = firstLength + middleLength + lastLength; var sx = 0.0; @@ -929,9 +929,9 @@ function getLinkStyles(link, xpts) { sx += firstLength; } else if (i > 0 && i < link.numLineSegments - 1) { sp = sx / totalLength; - ep = (sx + (svgWidth-edgepadding*2)) / totalLength; + ep = (sx + (Config.svgWidth-Config.edgePadding*2)) / totalLength; - sx += (svgWidth-edgepadding*2); + sx += (Config.svgWidth-Config.edgePadding*2); } else { sp = sx / totalLength; ep = 1.0; @@ -1041,7 +1041,7 @@ function calculateOnlyRow(rowNum, link, percentagePadding, xPositions, linkStyle link.polylines[0] = {polyline: pathline, style: lineStyle}; - if (percentagePadding < hideLinkLinesPercentage) { //only bother drawing links if there's room in the row + if (percentagePadding < Config.hideLinkLinesPercentage) { //only bother drawing links if there's room in the row link.polylines[0].visibility = false; for (var i = 0; i < xPositions.length; i++) { @@ -1063,7 +1063,7 @@ function calculateOnlyRow(rowNum, link, percentagePadding, xPositions, linkStyle //setupLineInteractions(link); //only can interact with them if they are visible } - calculateLinkLabels(0, rowNum, (xL + xR) / 2, yPos, link, (percentagePadding < hideLinkTextPercentage)); + calculateLinkLabels(0, rowNum, (xL + xR) / 2, yPos, link, (percentagePadding < Config.hideLinkTextPercentage)); link.linesLeftX.push(xL); @@ -1087,7 +1087,7 @@ function calculateStartRow(idx, rowNum, link, percentagePadding, xPositions, lin }); var xL = arrowPos[0].x ; - var xR = svgWidth; + var xR = Config.svgWidth; //can there be a start row with NO arrows?? @@ -1113,7 +1113,7 @@ function calculateStartRow(idx, rowNum, link, percentagePadding, xPositions, lin //storeLeftArrow(p1x, p1y, link, link.leftWord, link.leftAttach, getLeftXForLeftWord(link), getRightXForLeftWord(link)); - if (percentagePadding < hideLinkLinesPercentage) { + if (percentagePadding < Config.hideLinkLinesPercentage) { link.polylines[idx].visibility = false; for (var i = 0; i < xPositions.length; i++) { var wordIdx = xPositions[i].wordIdx; @@ -1133,7 +1133,7 @@ function calculateStartRow(idx, rowNum, link, percentagePadding, xPositions, lin //setupLineInteractions(link); //only can interact with them if they are visible } - calculateLinkLabels(idx, rowNum, (xL + xR)/2, yPos, link, (percentagePadding < hideLinkTextPercentage)); + calculateLinkLabels(idx, rowNum, (xL + xR)/2, yPos, link, (percentagePadding < Config.hideLinkTextPercentage)); } @@ -1148,7 +1148,7 @@ function calculateMiddleRow (idx, rowNum, link, percentagePadding, xPositions, l }); var xL = 0; //xPositions[0]; - var xR = svgWidth; //xPositions[link.words.length - 1]; + var xR = Config.svgWidth; //xPositions[link.words.length - 1]; var pathline = 'M '+ (xL-10) + ' ' + (yPos-10) + ' L ' + xL + ' ' + yPos + @@ -1176,7 +1176,7 @@ function calculateMiddleRow (idx, rowNum, link, percentagePadding, xPositions, l link.polylines[idx] = {polyline: pathline, style: linkStyles[idx]}; - if (percentagePadding < hideLinkLinesPercentage) { + if (percentagePadding < Config.hideLinkLinesPercentage) { link.polylines[idx].visibility = false; for (var i = 0; i < xPositions.length; i++) { var wordIdx = xPositions[i].wordIdx; @@ -1193,7 +1193,7 @@ function calculateMiddleRow (idx, rowNum, link, percentagePadding, xPositions, l //setupLineInteractions(link); //only can interact with them if they are visible } - calculateLinkLabels(idx, rowNum, (xL+xR) / 2, yPos, link, (percentagePadding < hideLinkTextPercentage)); + calculateLinkLabels(idx, rowNum, (xL+xR) / 2, yPos, link, (percentagePadding < Config.hideLinkTextPercentage)); } @@ -1279,7 +1279,7 @@ function calculateEndRow(idx, rowNum, link, percentagePadding, xPositions, linkS //storeRightArrow(p4x, p4y, link, link.rightWord, link.rightAttach, getLeftXForRightWord(link), getRightXForRightWord(link)); - if (percentagePadding < hideLinkLinesPercentage) { //only bother drawing links if there's room in the row + if (percentagePadding < Config.hideLinkLinesPercentage) { //only bother drawing links if there's room in the row link.polylines[idx].visibility = false; for (var i = 0; i < xPositions.length; i++) { @@ -1309,7 +1309,7 @@ function calculateEndRow(idx, rowNum, link, percentagePadding, xPositions, linkS //setupLineInteractions(link); //only can interact with them if they are visible } - calculateLinkLabels(idx, rowNum, (xL+xR) / 2, yPos, link, (percentagePadding < hideLinkTextPercentage)); + calculateLinkLabels(idx, rowNum, (xL+xR) / 2, yPos, link, (percentagePadding < Config.hideLinkTextPercentage)); } diff --git a/js/staircase.js b/js/staircase.js deleted file mode 100644 index 975abc1..0000000 --- a/js/staircase.js +++ /dev/null @@ -1,296 +0,0 @@ -class Staircase { - constructor() { - this.isOpen = false; - - // references to dom elements - this.drawing = document.getElementById('drawing'); - this.div = document.getElementById('graph') || - document.createElement('div'); - this.div.id = "graph"; - document.body.appendChild(this.div); - - // dimensions & properties - var boundingClientRect = this.div.getBoundingClientRect(); - - // Extend the viewport - this.bounds = { - top: boundingClientRect.top, - bottom: boundingClientRect.bottom, - left: boundingClientRect.left, - right: boundingClientRect.right, - width: boundingClientRect.width, - height: boundingClientRect.height - }; - - // d3 dom references - this.svg = d3.select('#graph') - .append('svg') - .attr('width', this.bounds.width*2) - .attr('height', this.bounds.height*2) - //.attr("preserveAspectRatio", "xMinYMin meet") - //.attr("viewBox", "0 0 " + this.bounds.width + " " + this.bounds.height) - .style("overflow", "auto") - ; - - console.log(this.bounds); - console.log(this.svg); - - // zoom - var zoom = d3.zoom().scaleExtent([1, 5]) - //.translateExtent([[0, -100], [this.bounds.width + 90, this.bounds.height + 100]]) - ; - - this.g = this.svg.append('g') - .attr('transform', 'translate(' + 10 + ',' + 10 + ')') - .call(zoom) - ; - - this.links = this.g.append('g') - .attr('class','links') - ; - - this.nodes = this.g.append('g') - .attr('class','nodes') - ; - - zoom.on("zoom", function () { - //this.svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); - }); - - // Tree-structured data, stored as a four dimensional array. - // I wish the dataset would support four levels: document, paragraph, - // sentence, and word. Since the first two are not available, - // we just set them to zero. - this.data = new Array(); - - // the box of each sentence only display the first few words - this.excerptSize = 3; - this.excerptMaxLength = 0; - - this.wordLength = new Array(); - this.wordMaxLength = 0; - - this.fontSize = 8; - - // Margin (top and left) for a word in a box - this.margin = this.fontSize*1.5; - - // All steps that create this staircase - this.steps = new Array(); - - } - - open() { - this.isOpen = true; - this.drawing.classList.add('split-left'); - this.div.classList.add('split-right'); - this.resize(); - } - - close() { - if (this.isOpen) { - this.isOpen = false; - this.drawing.classList.remove('split-left'); - this.div.classList.remove('split-right'); - } - } - - resize() { - this.bounds = this.div.getBoundingClientRect(); - this.svg - .attr('width', this.bounds.width) - .attr('height', this.bounds.height); - - // Err... I don't think the starcase needs a translate at the beginning - //this.g - // .attr('transform','translate(' + this.bounds.width/2 + ',' + this.bounds.height/2 + ')'); - - if (!this.nodes.selectAll('.node-group').empty()) { - this.updateGraph(); - } - } - - graph(wordObjs, linkObjs) { - if (this.data.length == 0) { - // generate a tree structure from the given list of words - this.generateData(wordObjs); - - var maxLength = this.getMaxLength(); - this.wordMaxLength = maxLength[0]; - this.excerptMaxLength = maxLength[1]; - - // draw nodes - this.drawNodes(); - - // draw links - this.drawLinks(); - - // set force simulation - this.updateGraph([]); - } - } - - // Create a tree from given data - // This tree has two levels: sentence & word. - // I wish the dataset supported up to four levels: document, paragraph, - // sentence, and word. - generateData(words) { - var idx = 0; - var docId = 0; - var parId = 0; - var senId = 0; - var wrdId = 0; - - // initiate a 4-dimensional array. - // this.data[0][1][2][3] means the 4th word in the 3rd sentence of - // the 2nd paragraph in the 1st document - this.data = new Array(new Array(new Array(new Array()))); - - while (idx < words.length) { - // If there is a period before this word, move to a new sentence - if (wrdId > 0 && words[idx - 1].val === ".") { - senId++; - this.data[docId][parId][senId] = new Array(); - wrdId = 0; - } - - this.data[docId][parId][senId][wrdId] = { - val: words[idx].val, - tag: words[idx].data.syntaxData.tag - }; - - wrdId++; - idx++; - } - } - - // get lengths of the longest word and the longest sentence excerpt - getMaxLength() { - var lengthWord = 0; - var lengthExcerpt = 0; - - for (var docId = 0; docId < this.data.length; docId++) { - for (var parId = 0; parId < this.data[docId].length; parId++) { - for (var senId = 0; senId < this.data[docId][parId].length; senId++) { - - // excerpt - if (this.data[docId][parId][senId].length >= 3) { - var excerpt = this.data[docId][parId][senId][0] - + " " + this.data[docId][parId][senId][1] - + " " + this.data[docId][parId][senId][2]; - var excerptText = this.g.append("text") - .attr("x", 0) - .attr("y", 0) - .text(excerpt) - ; - if (excerptText.node().getBBox().width > lengthExcerpt) - lengthExcerpt = excerptText.node().getBBox().width; - - this.g.selectAll("text").remove(); - } - - // word - for (var wrdId = 0; wrdId < this.data[docId][parId][senId].length; wrdId++) { - var text = this.g.append("text") - .attr("x", 0) - .attr("y", 0) - .text(this.data[docId][parId][senId][wrdId].val) - .attr("style", "font-size: 8; font-family: Helvetica, sans-serif") - ; - - if (text.node().getBBox().width > lengthWord) - lengthWord = text.node().getBBox().width; - - this.wordLength.push({ - width: text.node().getBBox().width, - height: text.node().getBBox().height - }); - - this.g.selectAll("text").remove(); - } - } - } - } - - return [lengthWord, lengthExcerpt]; - } - - drawNodes() { - var wordLoc = 0; - var loc_sen = 0; - - for (var docId = 0; docId < this.data.length; docId++) { - for (var parId = 0; parId < this.data[docId].length; parId++) { - for (var senId = 0; senId < this.data[docId][parId].length; senId++) { - for (var wrdId = 0; wrdId < this.data[docId][parId][senId].length; wrdId++) { - - var rect = this.g.append("rect") - .attr("x", wordLoc) - .attr("y", wordLoc) - .attr("width", this.wordMaxLength + this.margin) - .attr("height", this.wordMaxLength + this.margin) - .style("stroke", "black") - .style("stroke-width", 1) - .style("fill", "none") - ; - - var text = this.g.append("text") - .attr("x", wordLoc + this.margin) - .attr("y", wordLoc + this.margin) - .text(this.data[docId][parId][senId][wrdId].val) - .attr("style", "font-size: 8; font-family: Helvetica, sans-serif") - ; - - if (this.data[docId][parId][senId][wrdId].tag.length > 0) { - this.g.append("rect") - .attr("x", wordLoc + (this.wordMaxLength + this.margin)/2 ) - .attr("y", wordLoc + this.wordMaxLength - this.margin) - .attr("width", (this.wordMaxLength + this.margin)/2 ) - .attr("height", this.margin) - .style("fill", "red") - ; - - var label = this.g.append("text") - .attr("x", wordLoc + this.wordMaxLength) - .attr("y", wordLoc + this.wordMaxLength) - .style("text-anchor","end") - //.attr("dominant-baseline","central") - .attr("fill","white") - .text(this.data[docId][parId][senId][wrdId].tag) - ; - } - - wordLoc += this.wordMaxLength + this.margin; - } - } - } - } - } - - drawLinks() { - - } - - updateGraph(selectedWords) { - /* - console.log(this); - this.g.append("circle") - .attr("cx", this.steps[0].position.x) - .attr("cy", this.steps[0].position.y) - .attr("r", this.steps[0].size); - */ - } - -}//end class Staircase - - - -// A part of the staircase. Each step is a square which contains either -// a word or an excerpt of a sentence/paragraph. -class Step { - constructor() { - this.size = 20; - this.position = {x: 20, y: 20}; - this.style = {strokeColor: "black", strokeWidth: 1, fill: "none"}; - } -}// end class Step diff --git a/js/style.js b/js/style.js index 72d7918..a7b4c1f 100644 --- a/js/style.js +++ b/js/style.js @@ -378,11 +378,11 @@ function setupStyles(svg) { styleArr.tagFill.hoveringAndSelecting('#fcc', 1.0/*, new LineStyle('#000000', 1)*/); - styleArr.labelEvenFill = new FillStyle(evenRowsColor, 1.0); - styleArr.labelOddFill = new FillStyle(oddRowsColor, 1.0); + styleArr.labelEvenFill = new FillStyle(Config.evenRowsColor, 1.0); + styleArr.labelOddFill = new FillStyle(Config.oddRowsColor, 1.0); - styleArr.rowRectEvenFill = new FillStyle(evenRowsColor, 1.0); - styleArr.rowRectOddFill = new FillStyle(oddRowsColor, 1.0); + styleArr.rowRectEvenFill = new FillStyle(Config.evenRowsColor, 1.0); + styleArr.rowRectOddFill = new FillStyle(Config.oddRowsColor, 1.0); styleArr.rowLineStroke = new LineStyle("#555555", 0.5, 1.0); styleArr.rowDragRectFill = new FillStyle('#000'); diff --git a/js/utils.js b/js/utils.js index 919d7e2..7d69d5c 100644 --- a/js/utils.js +++ b/js/utils.js @@ -256,7 +256,7 @@ function getDescentForFont(str, fs) { function printLink(link) { - if (debug) { + if (Config.debug) { //console.log("----- \nprinting link ["+ link.id + "]: "); //console.log(link); //console.log("-----"); @@ -265,7 +265,7 @@ function printLink(link) { function debugSlots() { // var debug = false; - if (debug) { + if (Config.debug) { for (var i = 0; i < wordObjs.length; i++) { //console.log("slots taken for word " + wordObjs[i].val + " :"); diff --git a/test.html b/test.html new file mode 100644 index 0000000..02b3cbc --- /dev/null +++ b/test.html @@ -0,0 +1,448 @@ + + + + + + + + \ No newline at end of file From 7d07ebfcc602ebe12359355a2eb2a045f93ce1d1 Mon Sep 17 00:00:00 2001 From: Hai Tran Date: Fri, 19 May 2017 12:14:44 -0500 Subject: [PATCH 5/7] Initiate staircase --- hai.html | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 hai.html diff --git a/hai.html b/hai.html new file mode 100644 index 0000000..2b02988 --- /dev/null +++ b/hai.html @@ -0,0 +1,190 @@ + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + From aa72e93282adbbe22af9cd9f0b54b18598a33194 Mon Sep 17 00:00:00 2001 From: Hai Tran Date: Tue, 6 Jun 2017 19:24:48 -0500 Subject: [PATCH 6/7] Extend parser so it can generate links among sentences as well (unfinished) --- hai.html | 145 ++++++++++++++++++++++++++----------------- js/SentenceParser.js | 132 +++++++++++++++++++++++++++++++++++++++ js/staircase.js | 19 ++++++ 3 files changed, 240 insertions(+), 56 deletions(-) create mode 100644 js/SentenceParser.js create mode 100644 js/staircase.js diff --git a/hai.html b/hai.html index 2b02988..4096b6e 100644 --- a/hai.html +++ b/hai.html @@ -28,6 +28,16 @@ #drawing { margin-top:30px; + height: 100%; +} + +.axis path { + display: none; +} + +.axis line { + stroke-opacity: 0.1; + shape-rendering: crispEdges; } @@ -66,25 +76,65 @@ - + + @@ -70,6 +33,7 @@ + @@ -80,144 +44,212 @@ + + + diff --git a/js/staircase.js b/js/staircase.js index 85f9142..39c8cb2 100644 --- a/js/staircase.js +++ b/js/staircase.js @@ -1,19 +1,86 @@ -class Step { - - constructor() { - this.id = 0; - this.size = 100; - this.bgColor = "#ffffff"; - this.borderColor = "#000000"; - this.x = 0; - this.y = 0; - this.text = ""; - this.textX = 0; - this.textY = 0; - this.textColor = "#000000"; - this.fontsize = 12; - this.zoomLevel = 0; - - } - -} +class Staircase { + constructor(el) { + // container element + this.div = el; + + // dimensions & properties + this.bounds = this.div.getBoundingClientRect(); + + // d3 dom references + this.svg = d3.select(this.div).append('svg') + .attr('width', this.bounds.width) + .attr('height', this.bounds.height); + this.g = this.svg.append('g'); + + this.steps = this.g.append("g") + .attr("class", "steps"); + + // margins and drag event for positioning svg + this.leftMargin = 0; + this.topMargin = 0; + + this.dx = 0; + this.dy = 0; + this.svg + .call(d3.drag() + .on('drag', () => { + this.dx += d3.event.dx; + this.dy += d3.event.dy; + this.adjustMargins(this.dx, this.dy); + }) + ) + .on('dblclick', () => { + if (d3.event.target === this.svg.node()) { + this.dx = this.dy = 0; + this.adjustMargins(); + } + }); + this.resize(); + + // selected words to generate graph around + this.words = []; + + } + + resize() { + this.bounds = this.div.getBoundingClientRect(); + this.svg + .attr('width', this.bounds.width) + .attr('height', this.bounds.height); + + this.adjustMargins(); + } + + adjustMargins(dx = 0, dy = 0) { + this.g.attr('transform','translate(' + (20 + dx + this.leftMargin) + ', ' + (10 + dy + this.topMargin) + ')'); + } + + clear() { + this.words = []; + this.steps.selectAll('*').remove(); + } + + graph(words) { + this.words = words; + console.log(this.words); + + this.data = this.words.map(word => { + }); + + this.updateGraph(); + } + + updateGraph() { + let steps = this.steps.selectAll('.stepGroup') + .data(this.data); + steps.exit().remove(); + + steps.enter().append('g') + .attr('class','stepGroup') + .merge(steps) + .each((d, i, el) => { + el = d3.select(el[i]) + .attr('transform', 'translate(10, 0)'); + }); + } +}//end class Staircase