From 731f9e7d362c95f07edfb672c24688b30cc95a15 Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 1 Aug 2014 19:18:02 +0300 Subject: BetterAnalysis+Suggestions+TypeSelection AND cases are managed better small graph bugs resolved Typeselection works just as before now New nodes added to suggestion box Previous phrases added to suggestion box --- scripts/textanalysis.js | 460 +++++++++++++++++------------------------------- 1 file changed, 164 insertions(+), 296 deletions(-) (limited to 'scripts') diff --git a/scripts/textanalysis.js b/scripts/textanalysis.js index 31e6cd43..49fb671d 100644 --- a/scripts/textanalysis.js +++ b/scripts/textanalysis.js @@ -1,14 +1,12 @@ var text = ""; -var opened = false; var sugg = ["AJAX", "Neo4J", "Rhizi", "Research", "CRI", "SageBionetworks", "Hero.coli", "CSS", "NodeJS", "HTML5", "Angular", "D3", "ProofOfConcept", "Graphs", "CloudComputing", "BigData", "ProblemSolving", "PHP", "Javascript", "BackBone", "Cooperation", "SemanticWeb"]; var typeindex = 0; var names = ["Jean-ChristopheThalabard", "MaévaVignes", "AbdelElAbed", "ValérieTaly", "SébastienDutreuil", "AntoineBERGEL", "AntoineAngot", "JérômeFeret", "CharlèneGayrard", "HugoJimenezPerez", "CaterinaUrban", "GaëlleChevalon", "IanMarcus", "AntoineTALY", "ChantalLOTTON", "Ana-MariaLennon-Duménil", "FrédériqueCarlier-Grynkorn", "PascalMartin", "TamaraMilosevic", "NicolasCarpi", "StéphaneDaoudy", "DanijelaMaticVignjevic", "EugenioCinquemani", "VincentDAHIREL", "MartinLenz", "MaïlysChassagne", "AnneSchmidt", "SophieSacquinMora", "Richard-EmmanuelEastes", "MichelMorange", "EwaZlotek-Zlotkiewicz", "A.m.o.d.s.e.nC.h.o.t.i.a", "AlexandreVaugoux", "AnnemiekJMCornelissen", "ClémentNizak", "AntoineFrenoy", "ArielB.Lindner", "BenjaminBrogniart", "ChristopheZimmer", "ClaireRibrault", "DavidTareste", "DenisLafeuille", "DorGarbash", "DusanMISEVIC", "EddaNitschke", "FrançoisTaddei", "GregoryBatt", "JeanLucLebrun", "JesseHimmelstein", "KevinLhoste", "LauraCiriani", "LivioRiboli-Sasco", "NathalieSussfeld", "JakeEdwinWintermute", "MarlyneNogbou", "MatthieuPiel", "PascalHersen", "Pierre-YvesBourguignon", "TimoBetz", "RaphaëlGoujet", "StéphaneDebove", "VincentDanos", "TamKienDuong"]; var nodetypes = ["person", "project", "skill", "deliverable", "objective"]; -var previousorder = "NOTHING"; -var nodecounter = 0; -var nodereplaced = false; -var newlink = ""; +var sentenceStack = []; +var nodeindex, linkindex; +var typeStack = []; var ExecutionStack = []; @@ -20,43 +18,43 @@ $('#textanalyser').autocompleteTrigger({ source: sugg }); -$('#textanalyser').submit(function () { +$('#textanalyser').submit(function() { //finalize text input, empty - text=$('#textanalyser').val(); + text = $('#textanalyser').val(); $('#textanalyser').val(""); - TextAnalyser2(text,true); + TextAnalyser2(text, true); + typeStack=[]; return false; }); -$(document).keydown(function (e) { +$(document).keydown(function(e) { //RIGHT - if (e.keyCode == 37 ) { + if (e.keyCode == 37) { e.preventDefault(); - changeType("up",lastnode); + changeType("up", lastnode); return false; } - //LEFT - if (e.keyCode == 39 ) { + if (e.keyCode == 39) { e.preventDefault(); - changeType("down",lastnode); + changeType("down", lastnode); return false; } - if (e.keyCode == 13) { - text=$('#textanalyser').val(); + text = $('#textanalyser').val(); $('#textanalyser').val(""); - TextAnalyser2(text,true); + TextAnalyser2(text, true); + typeStack=[]; return false; } }); -function changeType(arg,id) { +function changeType(arg, id) { if (arg === 'up') { if (typeindex < 4) typeindex++; else typeindex = 0; @@ -74,343 +72,213 @@ function changeType(arg,id) { graph.updateGraph(); } - - - -window.setInterval(function () { +window.setInterval(function() { if ($('#textanalyser').val() != text) { $('.typeselection').css('top', -300); $('.typeselection').css('left', 0); // text changed text = $('#textanalyser').val(); - TextAnalyser2(text,false); - + TextAnalyser2(text, false); } }, 5); - - - - -var sentenceStack = []; -var nodeindex,linkindex; - -function TextAnalyser2(newtext,finalize) { - var states = ["NOTHING", "NEWNODE", "EDITNODE", "CLOSENODE", "NEWLINK", "EDITLINK" , "SPECIAL" , "QUARTET"]; - var segment = [], subsegment = [], sentence = []; - var newlinks=[];linkindex=0; - var newnodes=[];nodeindex=0; +function TextAnalyser2(newtext, finalize) { + var states = ["NOTHING", "NEWNODE", "EDITNODE", "CLOSENODE", "NEWLINK", "EDITLINK", "SPECIAL", "QUARTET"]; + var segment = [], + subsegment = [], + sentence = []; + var newlinks = []; + var newnodes = []; + linkindex = 0; + nodeindex = 0; var orderStack = []; - var quoteword=""; - var ANDcase=false; - var prefix=""; + var quoteword = ""; + var ANDcase = false; + var ANDcount = 0; + var prefix = ""; //Sentence Sequencing //Build the words and cuts the main elements - segment=newtext.split("#"); - for(var j=0;j "; - completeSentence+=newlinks[linkindex]; + word += " -->" + newlinks[linkindex] + " --> "; + completeSentence += newlinks[linkindex]; } } //REBUILD GRAPH - linkindex=0; - nodeindex=0; - - var typesetter=""; - if(finalize===false)typesetter="temp"; - else typesetter="perm"; + linkindex = 0; + nodeindex = 0; + + //CHANGE TO PERMANENT STATE AND UPDATE SUGGESTIONLIST + var typesetter = ""; + if (finalize === true) { + typesetter = "perm"; + for (var n = 0; n < newnodes.length; n++) { + if (Unique(newnodes[n])) { + sugg.push(newnodes[n]); + } + } + sugg.push(text); + } else { + typesetter = "temp"; + } + //REINITIALISE GRAPH (DUMB BUT IT WORKS) graph.removeNodes("temp"); graph.removeLinks("temp"); - if(orderStack.length>0)graph.addNode("","bubble","temp"); + //ADD SURROUNDING BUBBLE + if (orderStack.length > 0) graph.addNode("", "bubble", "temp"); + + var abnormalGraph=false; + if(newlinks.length >= 4 && ANDcount<2 )abnormalGraph=true; + //0-N ORDER STACK - for(var m=0; m=4){ - for(var l=1;l 0); - break; - case "CLOSENODE": - do { - newnode = newtext.charAt(index) + newnode; - newnode = newnode.replace(/\s/g, ''); - index--; - } while (newtext.charAt(index) !== "#" && index > 0); - break; - case "NEWLINK": - - newlink = ""; - - break; - case "EDITLINK": - newnode = ""; - break; - } - - - //$('.debug').html("node n "+nodecounter+" state: "+order+" nodename: |"+newnode+ "| link: |"+newlink+"| lastnode: |"+addednodes[nodecounter-2]+"rep: "+nodereplaced); - - - switch (order) { - case states[0]: - window.setTimeout(function () { - $('#textanalyser').css('box-shadow', '0 0 0px #303030') - }, 200); - break; - case states[1]: - - - if (nodecounter % 2 === 0) { - graph.addNode("", nodetypes[typeindex], "temp"); - } else { - graph.addNode("", nodetypes[typeindex], "temp"); - } - graph.editType("x", "temp", nodetypes[typeindex]); - nodecounter++; - break; - case states[2]: - if (nodereplaced === true) { - //graph.removeLink(); - //graph.addLink - graph.addNode(newnode, nodetypes[typeindex], "temp"); - graph.editLinkTarget(addednodes[nodecounter - 2], replacement, newnode); - replacement = ""; - } - nodereplaced = false; - if (AddedUnique(newnode)) { - - } else if (nodecounter % 2 === 0) { - console.log("not unique, replace"); - graph.addLink(addednodes[nodecounter - 2], newnode, newlink, "temp"); - graph.removeNode("x", "temp"); - nodereplaced = true; - replacement = newnode; + var verb = ""; + if (abnormalGraph) { + for (var l = 1; l < newlinks.length; l++) { + if (newlinks[l]) + if (newlinks[l].replace(/ /g, "") !== "and") { + verb = newlinks[l]; + } } - graph.editName("x", "temp", newnode); - graph.findCoordinates("x", "temp"); - break; - case states[3]: - - nodereplaced = false; - graph.editState("x", "temp", "perm"); - addednodes.push(newnode); - if (Unique(newnode)) sugg.push(newnode); - - if (nodecounter % 2 === 0) { - - $('#textanalyser').css('box-shadow', '0 0 30px #FFFF8F'); - $('#textanalyser').val(""); - graph.removeNode("x", "temp"); - previousorder = states[0]; - newnode = ""; + graph.addNode(completeSentence, "chainlink", typesetter); + for (var n = 0; n < newnodes.length; n++) { + graph.addLink(newnodes[n], completeSentence, verb, typesetter); } - break; - case states[4]: - graph.addNode("", "empty", "temp"); - graph.addLink(addednodes[nodecounter - 1], "", newlink, "perm"); - break; - case states[5]: - graph.editLink(addednodes[nodecounter - 1], "", newlink); - break; } + //FOR THE EXTERNAL ARROW-TYPE CHANGER + lastnode = newnodes[nodeindex]; - + //UPDATE GRAPH ONCE + graph.update(); } -*/ function Unique(newnode) { -- cgit v1.3.1