diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-12-10 03:03:48 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-16 10:59:14 +0200 |
| commit | d67cb649f26259954d1cfeb0665f93d2059ed1cd (patch) | |
| tree | f92484c87d120a99ea84675c2e6a0d4d9ed3da75 | |
| parent | 23760b4ae30876e064788fb8060fc7987e3d29c4 (diff) | |
addLink: drop drop_conjugator_links param, extract apply_conjugator_link_logic()
| -rw-r--r-- | src/model/graph.js | 7 | ||||
| -rw-r--r-- | src/textanalysis.js | 14 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/model/graph.js b/src/model/graph.js index 2e28d727..cc838db2 100644 --- a/src/model/graph.js +++ b/src/model/graph.js @@ -311,17 +311,14 @@ function Graph() { + dst_name + ' (' + dst_id + ')'); return; } - this.addLink(src_id, dst_id, name, state, drop_conjugator_links); + this.addLink(src_id, dst_id, name, state); } - function addLink(src_id, dst_id, name, state, drop_conjugator_links) { + function addLink(src_id, dst_id, name, state, peer_notify) { var src = find_node__by_id(src_id); var dst = find_node__by_id(dst_id); var found = findLink(src_id,dst_id,name); - if (drop_conjugator_links && name && (name.replace(/ /g,"") === "and")) { - state = "temp"; - } if (undefined === src || undefined === dst) { console.log('addLink: undefined src / dst'); return; diff --git a/src/textanalysis.js b/src/textanalysis.js index 963628e6..fdc4e837 100644 --- a/src/textanalysis.js +++ b/src/textanalysis.js @@ -189,6 +189,12 @@ var textAnalyser = function (newtext, finalize) { ret.link_set_add.push(link); } + function apply_conjugator_link_logic(link, drop_conjugator_links){ + if (drop_conjugator_links && link.name && (link.name.replace(/ /g,"") === "and")) { + link.state = "temp"; + } + } + if (newtext.indexOf('#') == -1 || finalize) { lastnode = null; } @@ -396,11 +402,11 @@ var textAnalyser = function (newtext, finalize) { } ret.for_each_link_add(function (link) { + apply_conjugator_link_logic(link, ret.drop_conjugator_links); graph.addLinkByName(link.__src.name, link.__dst.name, link.name, - link.state, - ret.drop_conjugator_links); + link.state); }); } else { // REINITIALISE GRAPH (DUMB BUT IT WORKS) @@ -421,11 +427,11 @@ var textAnalyser = function (newtext, finalize) { ret.for_each_link_add(function (link) { if (false == finalize || link.name !== 'and') { + apply_conjugator_link_logic(link, ret.drop_conjugator_links); graph.addLinkByName(link.__src, link.__dst, link.name, - link.state, - ret.drop_conjugator_links); + link.state); } }); } |
