summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-09-28 15:04:05 +0300
committerAlon Levy <alon@pobox.com>2014-09-28 15:04:05 +0300
commit9d4ada6425effb1223a74810646fe0a380c91008 (patch)
tree043f34a462c10e1a35658c71bd00185208975906 /scripts
parent77987826027b26b528f0b3dcbdc898395bf677c1 (diff)
textanalysis: move graph touching function to non ui part
Diffstat (limited to 'scripts')
-rw-r--r--scripts/textanalysis-ui.js16
-rw-r--r--scripts/textanalysis.js16
2 files changed, 17 insertions, 15 deletions
diff --git a/scripts/textanalysis-ui.js b/scripts/textanalysis-ui.js
index 19f1b188..d79ceb0a 100644
--- a/scripts/textanalysis-ui.js
+++ b/scripts/textanalysis-ui.js
@@ -22,21 +22,7 @@ function analyzeSentence(sentence, finalize)
$('.typeselection').css('left', 0);
break;
}
- //REINITIALISE GRAPH (DUMB BUT IT WORKS)
- graph.removeNodes("temp");
- graph.removeLinks("temp");
- for (var k in ret.nodes) {
- var n = ret.nodes[k];
- graph.addNode(n.id, n.type, n.state);
- }
- for (var k in ret.links) {
- var l = ret.links[k];
- graph.addLink(l.sourceId, l.targetId, l.name, l.state, ret.drop_conjugator_links);
- }
-
- //UPDATE GRAPH ONCE
- graph.update();
-
+ ret.applyToGraph(graph);
if (finalize || sentence.length == 0) {
$('.typeselection').css('top', -300);
$('.typeselection').css('left', 0);
diff --git a/scripts/textanalysis.js b/scripts/textanalysis.js
index 7ac32277..ecebdbeb 100644
--- a/scripts/textanalysis.js
+++ b/scripts/textanalysis.js
@@ -284,5 +284,21 @@ var textAnalyser2 = function (newtext, finalize) {
//FOR THE EXTERNAL ARROW-TYPE CHANGER
lastnode = newnodes[nodeindex];
+ ret.applyToGraph = function(graph) {
+ //REINITIALISE GRAPH (DUMB BUT IT WORKS)
+ graph.removeNodes("temp");
+ graph.removeLinks("temp");
+ for (var k in ret.nodes) {
+ var n = ret.nodes[k];
+ graph.addNode(n.id, n.type, n.state);
+ }
+ for (var k in ret.links) {
+ var l = ret.links[k];
+ graph.addLink(l.sourceId, l.targetId, l.name, l.state, ret.drop_conjugator_links);
+ }
+ //UPDATE GRAPH ONCE
+ graph.update();
+ }
+
return ret;
}