summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-09-23 20:16:36 +0300
committerAlon Levy <alon@pobox.com>2014-09-23 20:16:37 +0300
commit2e3173f3cda29c988444aa52d917dcd11edf24e3 (patch)
tree3ebaca0a898204e78338322c4380fc40c2f50e23
parenta77d15610f1acfcdc6ce671b2fb036cd80382a6f (diff)
Fixes #50: drop parenthesis for prefix including sentences
Previously: prefix #a does #b => ((a, b), [(a, b, "does (prefix)")]) now: => ((a, b), [(a, b, "prefix #a does #b")])
-rw-r--r--scripts/textanalysis.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/textanalysis.js b/scripts/textanalysis.js
index 29c473f3..ba35c8fe 100644
--- a/scripts/textanalysis.js
+++ b/scripts/textanalysis.js
@@ -137,19 +137,23 @@ function TextAnalyser2(newtext, finalize) {
newlinks[linkindex] += sentence[m] + " ";
}
}
- if (newnodes.length === 0) prefix += sentence[m] + " ";
+ if (newnodes.length === 0) {
+ prefix += sentence[m];
+ }
break;
}
}
- //ATTACH SENTENCE PREFIX
- if (prefix) newlinks[1] += "(" + prefix + ")";
+ //PREFIX not null case - put complete sentence in first link.
+ if (prefix) {
+ newlinks[1] = prefix + " " + newnodes[0] + " " + newlinks[1] + newnodes[1];
+ }
//WRITE COMPLETE SENTENCE
linkindex = 0;
nodeindex = 0;
var word = "";
- var completeSentence = "";
+ var completeSentence = prefix.length > 0 ? String(prefix) + " " : "";
for (var m = 0; m < orderStack.length; m++) {
if (orderStack[m] === "NODE") {
word += " (" + newnodes[nodeindex] + ") ";