summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-10-21 11:19:34 +0300
committerAlon Levy <alon@pobox.com>2014-10-21 11:19:35 +0300
commit2f0900466a6a1bbb002d7ae95a4f03e462b9953f (patch)
tree06d70d29c327f978c4cf3829e96b1ecff3d4089c
parentb8119bfb95550fdb9014df3a80791024a9923867 (diff)
test_analyzer: better test
need better graph accessors to give only the 'real' nodes & links - that will fix some of the tests, leaving the real wrong ones
-rw-r--r--scripts/rhizicore.js1
-rw-r--r--tests/test_analyzer.js19
2 files changed, 16 insertions, 4 deletions
diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js
index 9c2d299f..b53774ea 100644
--- a/scripts/rhizicore.js
+++ b/scripts/rhizicore.js
@@ -505,6 +505,7 @@ function myGraph(el) {
nodes.length = 0;
links.length = 0;
}
+ this.clear = clear;
function empty() {
return nodes.length == 0 && links.length == 0;
diff --git a/tests/test_analyzer.js b/tests/test_analyzer.js
index bd74429b..0b5403a3 100644
--- a/tests/test_analyzer.js
+++ b/tests/test_analyzer.js
@@ -19,17 +19,28 @@ base.run_tests({
done: function (errors, window) {
debugger;
var analyzeSentence = window.require('textanalysis.ui').analyzeSentence;
- console.log(process.argv);
- if (process.argv.length >= 2) {
+ if (process.argv.length > 2) {
analyzeSentence(process.argv.slice(2).join(" "), true);
base.dump_graphviz(window.require('rhizicore').force);
} else {
- for (var k in data) {
+ for (var k = 0; k < data.length; ++k) {
var sentence = data[k][0];
var expected_nodes = data[k][1];
var expected_links = data[k][2];
+ base.reset(window);
+ console.log('analyzing ' + sentence);
analyzeSentence(sentence, true);
- // TODO - compare graphs
+ var nodes = base.nodes(window);
+ var links = base.links(window);
+ if (nodes != expected_nodes) {
+ console.log('expected: ' + expected_nodes);
+ console.log('got: ' + nodes.join('|'));
+ }
+ if (links != expected_links) {
+ console.log('expected: ' + expected_links);
+ console.log('got: ' + links);
+ }
+ base.dump_graphviz(window.require('rhizicore').force);
}
}
process.exit();