{"action":"created","comment":{"url":"https://api.github.com/repos/opencog/opencog/pulls/comments/72485623","id":72485623,"diff_hunk":"@@ -0,0 +1,163 @@\n+/*\n+ * Globals.cc\n+ *\n+ *  Created on: 2 Mar 2016\n+ *      Author: misgana\n+ */\n+\n+#include <fstream>\n+\n+#include \"Globals.h\"\n+\n+using namespace opencog;\n+using namespace opencog::ECANExperiment;\n+\n+std::vector<std::vector<std::string>> opencog::ECANExperiment::swords;\n+std::vector<std::string> opencog::ECANExperiment::words;\n+\n+int opencog::ECANExperiment::current_group = 0;\n+\n+int opencog::ECANExperiment::special_word_occurence_period = 1;\n+\n+bool opencog::ECANExperiment::are_similar(const Handle& h1, const Handle& h2, bool strict_type_match)\n+{\n+    if (h1 == h2)\n+        return true;\n+\n+    if (NodeCast(h1) and NodeCast(h2))\n+        return !strict_type_match or h1->getType() == h2->getType();\n+\n+    LinkPtr lh1(LinkCast(h1));\n+    LinkPtr lh2(LinkCast(h2));\n+\n+    if (lh1 and lh2) {\n+        if (strict_type_match and (lh1->getType() != lh2->getType()))\n+            return false;\n+\n+        HandleSeq hseqh1 = lh1->getOutgoingSet();\n+        HandleSeq hseqh2 = lh2->getOutgoingSet();\n+\n+        if (hseqh1.size() != hseqh2.size())\n+            return false;\n+\n+        // Unordered links should be treated in a special way\n+        if (classserver().isA(lh1->getType(), UNORDERED_LINK) or classserver().isA(\n+                lh2->getType(), UNORDERED_LINK)) {\n+\n+            for (const auto& h1 : hseqh1) {\n+                for (auto it = hseqh2.begin(); it != hseqh2.end(); ++it) {\n+                    if (are_similar(h1, h2, strict_type_match)) {\n+                        hseqh2.erase(it);\n+                        break;\n+                    }\n+                }\n+            }\n+\n+            // Empty means all has been mapped. Success.\n+            return hseqh2.empty() or false;\n+        }\n+\n+        for (HandleSeq::size_type i = 0; i < hseqh1.size(); i++) {\n+            if (not are_similar(hseqh1[i], hseqh2[i], strict_type_match))\n+                return false;\n+        }\n+\n+        return true;\n+    }\n+\n+    return false;\n+}\n+\n+bool opencog::ECANExperiment::exists_in(const Handle& hlink, const Handle& h)\n+{\n+    if (hlink == h) {\n+        return true;\n+    } else {\n+        LinkPtr lp(LinkCast(hlink));\n+        if (nullptr == lp)\n+            return false;\n+\n+        auto outg = lp->getOutgoingSet();\n+        if (std::find(outg.begin(), outg.end(), h) != outg.end())\n+            return true;\n+        else {\n+            for (const Handle& hi : outg) {\n+                if (LinkCast(hi) and exists_in(hi, h))\n+                    return true;\n+            }\n+        }\n+        return false;\n+    }\n+}\n+\n+bool opencog::ECANExperiment::is_friendship_reln(const Handle& h)\n+{\n+    AtomSpace as;\n+    as.add_atom(h);\n+    Handle friends_predicate = as.add_node(PREDICATE_NODE, \"friends\");\n+    Handle var_1 = as.add_node(CONCEPT_NODE, \"$0343O45FFEWW\");\n+    Handle var_2 = as.add_node(CONCEPT_NODE, \"$0343045FFEWY\");\n+    Handle friend_list = as.add_link(LIST_LINK, HandleSeq { var_1, var_2 });\n+    Handle eval_link = as.add_link(EVALUATION_LINK, { friends_predicate,\n+                                                      friend_list });\n+    as.add_atom(eval_link);","path":"examples/attention/Globals.cc","position":103,"original_position":103,"commit_id":"4778370b39fc3f9301c1d403b5d196f3161c784b","original_commit_id":"4778370b39fc3f9301c1d403b5d196f3161c784b","user":{"login":"linas","id":94368,"avatar_url":"https://avatars.githubusercontent.com/u/94368?v=3","gravatar_id":"","url":"https://api.github.com/users/linas","html_url":"https://github.com/linas","followers_url":"https://api.github.com/users/linas/followers","following_url":"https://api.github.com/users/linas/following{/other_user}","gists_url":"https://api.github.com/users/linas/gists{/gist_id}","starred_url":"https://api.github.com/users/linas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linas/subscriptions","organizations_url":"https://api.github.com/users/linas/orgs","repos_url":"https://api.github.com/users/linas/repos","events_url":"https://api.github.com/users/linas/events{/privacy}","received_events_url":"https://api.github.com/users/linas/received_events","type":"User","site_admin":false},"body":"Huh ... this is exactly why we have python and scheme bindings (and haskell!) -- its because adding atoms to the atomspace in C++ is verbose and painful, and any changes require a recompile.","created_at":"2016-07-27T17:36:08Z","updated_at":"2016-07-27T17:36:08Z","html_url":"https://github.com/opencog/opencog/pull/2321#discussion_r72485623","pull_request_url":"https://api.github.com/repos/opencog/opencog/pulls/2321","_links":{"self":{"href":"https://api.github.com/repos/opencog/opencog/pulls/comments/72485623"},"html":{"href":"https://github.com/opencog/opencog/pull/2321#discussion_r72485623"},"pull_request":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2321"}}},"pull_request":{"url":"https://api.github.com/repos/opencog/opencog/pulls/2321","id":79010312,"html_url":"https://github.com/opencog/opencog/pull/2321","diff_url":"https://github.com/opencog/opencog/pull/2321.diff","patch_url":"https://github.com/opencog/opencog/pull/2321.patch","issue_url":"https://api.github.com/repos/opencog/opencog/issues/2321","number":2321,"state":"open","locked":false,"title":"Attention Experiment","user":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"body":"This code merges my ECAN Experiment it is located in opencog/experiments/attention.\r\n\r\nIt also improves/fixes some things in ECAN.","created_at":"2016-07-27T11:49:27Z","updated_at":"2016-07-27T17:36:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf132f2ff2d58e6481b77bff68b8342f46d367ad","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/opencog/opencog/pulls/2321/commits","review_comments_url":"https://api.github.com/repos/opencog/opencog/pulls/2321/comments","review_comment_url":"https://api.github.com/repos/opencog/opencog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencog/opencog/issues/2321/comments","statuses_url":"https://api.github.com/repos/opencog/opencog/statuses/4778370b39fc3f9301c1d403b5d196f3161c784b","head":{"label":"rTreutlein:ExpInMaster","ref":"ExpInMaster","sha":"4778370b39fc3f9301c1d403b5d196f3161c784b","user":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"repo":{"id":46968067,"name":"opencog","full_name":"rTreutlein/opencog","owner":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rTreutlein/opencog","description":"A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)","fork":true,"url":"https://api.github.com/repos/rTreutlein/opencog","forks_url":"https://api.github.com/repos/rTreutlein/opencog/forks","keys_url":"https://api.github.com/repos/rTreutlein/opencog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rTreutlein/opencog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rTreutlein/opencog/teams","hooks_url":"https://api.github.com/repos/rTreutlein/opencog/hooks","issue_events_url":"https://api.github.com/repos/rTreutlein/opencog/issues/events{/number}","events_url":"https://api.github.com/repos/rTreutlein/opencog/events","assignees_url":"https://api.github.com/repos/rTreutlein/opencog/assignees{/user}","branches_url":"https://api.github.com/repos/rTreutlein/opencog/branches{/branch}","tags_url":"https://api.github.com/repos/rTreutlein/opencog/tags","blobs_url":"https://api.github.com/repos/rTreutlein/opencog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rTreutlein/opencog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rTreutlein/opencog/git/refs{/sha}","trees_url":"https://api.github.com/repos/rTreutlein/opencog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rTreutlein/opencog/statuses/{sha}","languages_url":"https://api.github.com/repos/rTreutlein/opencog/languages","stargazers_url":"https://api.github.com/repos/rTreutlein/opencog/stargazers","contributors_url":"https://api.github.com/repos/rTreutlein/opencog/contributors","subscribers_url":"https://api.github.com/repos/rTreutlein/opencog/subscribers","subscription_url":"https://api.github.com/repos/rTreutlein/opencog/subscription","commits_url":"https://api.github.com/repos/rTreutlein/opencog/commits{/sha}","git_commits_url":"https://api.github.com/repos/rTreutlein/opencog/git/commits{/sha}","comments_url":"https://api.github.com/repos/rTreutlein/opencog/comments{/number}","issue_comment_url":"https://api.github.com/repos/rTreutlein/opencog/issues/comments{/number}","contents_url":"https://api.github.com/repos/rTreutlein/opencog/contents/{+path}","compare_url":"https://api.github.com/repos/rTreutlein/opencog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rTreutlein/opencog/merges","archive_url":"https://api.github.com/repos/rTreutlein/opencog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rTreutlein/opencog/downloads","issues_url":"https://api.github.com/repos/rTreutlein/opencog/issues{/number}","pulls_url":"https://api.github.com/repos/rTreutlein/opencog/pulls{/number}","milestones_url":"https://api.github.com/repos/rTreutlein/opencog/milestones{/number}","notifications_url":"https://api.github.com/repos/rTreutlein/opencog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rTreutlein/opencog/labels{/name}","releases_url":"https://api.github.com/repos/rTreutlein/opencog/releases{/id}","deployments_url":"https://api.github.com/repos/rTreutlein/opencog/deployments","created_at":"2015-11-27T08:19:26Z","updated_at":"2016-06-30T19:36:53Z","pushed_at":"2016-07-27T11:47:29Z","git_url":"git://github.com/rTreutlein/opencog.git","ssh_url":"git@github.com:rTreutlein/opencog.git","clone_url":"https://github.com/rTreutlein/opencog.git","svn_url":"https://github.com/rTreutlein/opencog","homepage":"http://wiki.opencog.org/w/Development","size":148853,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencog:master","ref":"master","sha":"5e78946a1b3f8477de9d1f8b231c62c3af9e16f3","user":{"login":"opencog","id":2109913,"avatar_url":"https://avatars.githubusercontent.com/u/2109913?v=3","gravatar_id":"","url":"https://api.github.com/users/opencog","html_url":"https://github.com/opencog","followers_url":"https://api.github.com/users/opencog/followers","following_url":"https://api.github.com/users/opencog/following{/other_user}","gists_url":"https://api.github.com/users/opencog/gists{/gist_id}","starred_url":"https://api.github.com/users/opencog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencog/subscriptions","organizations_url":"https://api.github.com/users/opencog/orgs","repos_url":"https://api.github.com/users/opencog/repos","events_url":"https://api.github.com/users/opencog/events{/privacy}","received_events_url":"https://api.github.com/users/opencog/received_events","type":"Organization","site_admin":false},"repo":{"id":6365343,"name":"opencog","full_name":"opencog/opencog","owner":{"login":"opencog","id":2109913,"avatar_url":"https://avatars.githubusercontent.com/u/2109913?v=3","gravatar_id":"","url":"https://api.github.com/users/opencog","html_url":"https://github.com/opencog","followers_url":"https://api.github.com/users/opencog/followers","following_url":"https://api.github.com/users/opencog/following{/other_user}","gists_url":"https://api.github.com/users/opencog/gists{/gist_id}","starred_url":"https://api.github.com/users/opencog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencog/subscriptions","organizations_url":"https://api.github.com/users/opencog/orgs","repos_url":"https://api.github.com/users/opencog/repos","events_url":"https://api.github.com/users/opencog/events{/privacy}","received_events_url":"https://api.github.com/users/opencog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opencog/opencog","description":"A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)","fork":false,"url":"https://api.github.com/repos/opencog/opencog","forks_url":"https://api.github.com/repos/opencog/opencog/forks","keys_url":"https://api.github.com/repos/opencog/opencog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencog/opencog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencog/opencog/teams","hooks_url":"https://api.github.com/repos/opencog/opencog/hooks","issue_events_url":"https://api.github.com/repos/opencog/opencog/issues/events{/number}","events_url":"https://api.github.com/repos/opencog/opencog/events","assignees_url":"https://api.github.com/repos/opencog/opencog/assignees{/user}","branches_url":"https://api.github.com/repos/opencog/opencog/branches{/branch}","tags_url":"https://api.github.com/repos/opencog/opencog/tags","blobs_url":"https://api.github.com/repos/opencog/opencog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencog/opencog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencog/opencog/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencog/opencog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencog/opencog/statuses/{sha}","languages_url":"https://api.github.com/repos/opencog/opencog/languages","stargazers_url":"https://api.github.com/repos/opencog/opencog/stargazers","contributors_url":"https://api.github.com/repos/opencog/opencog/contributors","subscribers_url":"https://api.github.com/repos/opencog/opencog/subscribers","subscription_url":"https://api.github.com/repos/opencog/opencog/subscription","commits_url":"https://api.github.com/repos/opencog/opencog/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencog/opencog/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencog/opencog/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencog/opencog/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencog/opencog/contents/{+path}","compare_url":"https://api.github.com/repos/opencog/opencog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencog/opencog/merges","archive_url":"https://api.github.com/repos/opencog/opencog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencog/opencog/downloads","issues_url":"https://api.github.com/repos/opencog/opencog/issues{/number}","pulls_url":"https://api.github.com/repos/opencog/opencog/pulls{/number}","milestones_url":"https://api.github.com/repos/opencog/opencog/milestones{/number}","notifications_url":"https://api.github.com/repos/opencog/opencog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencog/opencog/labels{/name}","releases_url":"https://api.github.com/repos/opencog/opencog/releases{/id}","deployments_url":"https://api.github.com/repos/opencog/opencog/deployments","created_at":"2012-10-24T06:10:15Z","updated_at":"2016-07-27T14:03:18Z","pushed_at":"2016-07-27T11:49:27Z","git_url":"git://github.com/opencog/opencog.git","ssh_url":"git@github.com:opencog/opencog.git","clone_url":"https://github.com/opencog/opencog.git","svn_url":"https://github.com/opencog/opencog","homepage":"http://wiki.opencog.org/w/Development","size":162610,"stargazers_count":1001,"watchers_count":1001,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":455,"mirror_url":null,"open_issues_count":67,"forks":455,"open_issues":67,"watchers":1001,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2321"},"html":{"href":"https://github.com/opencog/opencog/pull/2321"},"issue":{"href":"https://api.github.com/repos/opencog/opencog/issues/2321"},"comments":{"href":"https://api.github.com/repos/opencog/opencog/issues/2321/comments"},"review_comments":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2321/comments"},"review_comment":{"href":"https://api.github.com/repos/opencog/opencog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2321/commits"},"statuses":{"href":"https://api.github.com/repos/opencog/opencog/statuses/4778370b39fc3f9301c1d403b5d196f3161c784b"}}}}
{"actor":{"display_login":"linas"}}