{"action":"opened","number":1187,"pull_request":{"url":"https://api.github.com/repos/opencog/opencog/pulls/1187","id":27015822,"html_url":"https://github.com/opencog/opencog/pull/1187","diff_url":"https://github.com/opencog/opencog/pull/1187.diff","patch_url":"https://github.com/opencog/opencog/pull/1187.patch","issue_url":"https://api.github.com/repos/opencog/opencog/issues/1187","number":1187,"state":"open","locked":false,"title":"SuReal: scheme primitives for running the Pattern Matcher","user":{"login":"williampma","id":7298267,"avatar_url":"https://avatars.githubusercontent.com/u/7298267?v=3","gravatar_id":"","url":"https://api.github.com/users/williampma","html_url":"https://github.com/williampma","followers_url":"https://api.github.com/users/williampma/followers","following_url":"https://api.github.com/users/williampma/following{/other_user}","gists_url":"https://api.github.com/users/williampma/gists{/gist_id}","starred_url":"https://api.github.com/users/williampma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williampma/subscriptions","organizations_url":"https://api.github.com/users/williampma/orgs","repos_url":"https://api.github.com/users/williampma/repos","events_url":"https://api.github.com/users/williampma/events{/privacy}","received_events_url":"https://api.github.com/users/williampma/received_events","type":"User","site_admin":false},"body":"Implemented two scheme primitives for the next version of SuReal: `sureal-match` and `sureal-get-mapping`.  These primitives are for SuReal's internal usage in the next stage, so probably will not be used by others.\r\n\r\n* `(sureal-match ...)` accepts a `SetLink` as input and uses the Pattern Matcher to find matching sentences.  Two hypergraph matches iff the structure is the same, and for each pair of matched nodes (ConceptNode/PredicateNode/etc), the corresponding `WordNode` has the same LG grammar dictionary entry.  The WordNode is found by extracting the name from the ConceptNode/PredicateNode and finding a WordNode with the same name.\r\n\r\n  Two words' LG entries matched iff the structure of `(LgWordCset (WordNode \"A\") ...)` `(LgWordCset (WordNode \"B\") ...)` link to same LG hypergraph at \"...\"\r\n\r\n* `(sureal-get-mapping ...)` can be called after running `(sureal-match ...)`.  It accepts an `InterpretationNode` returned by `sureal-match` as input, and returns a list of node-to-node mapping.\r\n\r\n## Example\r\n\r\nHere's a basic example:\r\n```\r\n(lg-get-dict-entry (WordNode \"he\"))\r\n(lg-get-dict-entry (WordNode \"she\"))\r\n(lg-get-dict-entry (WordNode \"runs\"))\r\n(lg-get-dict-entry (WordNode \"walks\"))\r\n(r2l \"He runs.\")\r\n(r2l \"He runs quickly.\")\r\n(sureal-match (SetLink (EvaluationLink (PredicateNode \"walks\") (ListLink (ConceptNode \"she\")))))\r\n```\r\nThis will returns two `InterpretationNode` like\r\n```\r\n((InterpretationNode \"sentence@d6f3a339-c2db-457a-b320-d3cf60aef6ce_parse_0_interpretation_$X\")\r\n (InterpretationNode \"sentence@eb8cb479-c2d6-4bcb-bc64-9973d5d083c8_parse_0_interpretation_$X\")\r\n)\r\n```\r\nranked.  In this case, the InterpretationNode for \"He runs\" rank higher than \"He runs quickly\" because there's less left-over unmatched links.\r\n\r\nRunning the following\r\n```\r\n(sureal-get-mapping (InterpretationNode \"sentence@d6f3a339-c2db-457a-b320-d3cf60aef6ce_parse_0_interpretation_$X\"))\r\n```\r\nreturns\r\n```\r\n(((PredicateNode \"walks\")\r\n (ConceptNode \"she\")\r\n) ((PredicateNode \"runs@2ed03b71-2cdf-4cd7-bd3b-384e1ab8b16b\" (stv 0.001 0.99000001))\r\n (ConceptNode \"he@4a160823-df3e-447b-b6eb-085609e4960b\" (stv 0.001 0.99000001))\r\n))\r\n```\r\nwhich is a list mapping \"walks\" to \"runs\", and \"she\" to \"he\" of the R2L output.\r\n\r\n## Longer Example\r\nFor testing `SetLink` with multiple clauses for PM query\r\n```\r\n(lg-get-dict-entry (WordNode \"dog\"))\r\n(lg-get-dict-entry (WordNode \"yellow\"))\r\n(lg-get-dict-entry (WordNode \"green\"))\r\n(lg-get-dict-entry (WordNode \"cat\"))\r\n(lg-get-dict-entry (WordNode \"hates\"))\r\n(lg-get-dict-entry (WordNode \"loves\"))\r\n(r2l \"The yellow dog hates the cat.\")\r\n(sureal-match\r\n\t(SetLink\r\n\t\t(EvaluationLink\r\n\t\t\t(PredicateNode \"loves\")\r\n\t\t\t(ListLink (ConceptNode \"cat\") (ConceptNode \"dog\")))\r\n\t\t(InheritanceLink (ConceptNode \"cat\") (ConceptNode \"green\"))))\r\n```\r\n\r\n## Harder-stuff\r\nCurrently, the LG dictionary matching is very strict, ie, we can match\r\n```\r\nhe <-> she\r\nruns <-> walks\r\neats <-> drinks\r\ngreen <-> yellow\r\n```\r\nbut not\r\n```\r\nI <-> you\r\nruns <-> eats\r\n```\r\nsince the LG entry is not 100% the same.  In some future version partial LG dict entry match will be needed (for some of the cases... It is good to match I <-> you, but not runs <-> eats).\r\n\r\n\r\n## TODO\r\nActually plug these primitives into the SuReal pipeline to produce sentences.","created_at":"2015-01-08T09:25:58Z","updated_at":"2015-01-08T09:25:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opencog/opencog/pulls/1187/commits","review_comments_url":"https://api.github.com/repos/opencog/opencog/pulls/1187/comments","review_comment_url":"https://api.github.com/repos/opencog/opencog/pulls/comments/{number}","comments_url":"https://api.github.com/repos/opencog/opencog/issues/1187/comments","statuses_url":"https://api.github.com/repos/opencog/opencog/statuses/49541262c7208e3d70669557320c9d1144aa51cb","head":{"label":"williampma:SuReal","ref":"SuReal","sha":"49541262c7208e3d70669557320c9d1144aa51cb","user":{"login":"williampma","id":7298267,"avatar_url":"https://avatars.githubusercontent.com/u/7298267?v=3","gravatar_id":"","url":"https://api.github.com/users/williampma","html_url":"https://github.com/williampma","followers_url":"https://api.github.com/users/williampma/followers","following_url":"https://api.github.com/users/williampma/following{/other_user}","gists_url":"https://api.github.com/users/williampma/gists{/gist_id}","starred_url":"https://api.github.com/users/williampma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williampma/subscriptions","organizations_url":"https://api.github.com/users/williampma/orgs","repos_url":"https://api.github.com/users/williampma/repos","events_url":"https://api.github.com/users/williampma/events{/privacy}","received_events_url":"https://api.github.com/users/williampma/received_events","type":"User","site_admin":false},"repo":{"id":18792330,"name":"opencog","full_name":"williampma/opencog","owner":{"login":"williampma","id":7298267,"avatar_url":"https://avatars.githubusercontent.com/u/7298267?v=3","gravatar_id":"","url":"https://api.github.com/users/williampma","html_url":"https://github.com/williampma","followers_url":"https://api.github.com/users/williampma/followers","following_url":"https://api.github.com/users/williampma/following{/other_user}","gists_url":"https://api.github.com/users/williampma/gists{/gist_id}","starred_url":"https://api.github.com/users/williampma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williampma/subscriptions","organizations_url":"https://api.github.com/users/williampma/orgs","repos_url":"https://api.github.com/users/williampma/repos","events_url":"https://api.github.com/users/williampma/events{/privacy}","received_events_url":"https://api.github.com/users/williampma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/williampma/opencog","description":"A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)","fork":true,"url":"https://api.github.com/repos/williampma/opencog","forks_url":"https://api.github.com/repos/williampma/opencog/forks","keys_url":"https://api.github.com/repos/williampma/opencog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/williampma/opencog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/williampma/opencog/teams","hooks_url":"https://api.github.com/repos/williampma/opencog/hooks","issue_events_url":"https://api.github.com/repos/williampma/opencog/issues/events{/number}","events_url":"https://api.github.com/repos/williampma/opencog/events","assignees_url":"https://api.github.com/repos/williampma/opencog/assignees{/user}","branches_url":"https://api.github.com/repos/williampma/opencog/branches{/branch}","tags_url":"https://api.github.com/repos/williampma/opencog/tags","blobs_url":"https://api.github.com/repos/williampma/opencog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/williampma/opencog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/williampma/opencog/git/refs{/sha}","trees_url":"https://api.github.com/repos/williampma/opencog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/williampma/opencog/statuses/{sha}","languages_url":"https://api.github.com/repos/williampma/opencog/languages","stargazers_url":"https://api.github.com/repos/williampma/opencog/stargazers","contributors_url":"https://api.github.com/repos/williampma/opencog/contributors","subscribers_url":"https://api.github.com/repos/williampma/opencog/subscribers","subscription_url":"https://api.github.com/repos/williampma/opencog/subscription","commits_url":"https://api.github.com/repos/williampma/opencog/commits{/sha}","git_commits_url":"https://api.github.com/repos/williampma/opencog/git/commits{/sha}","comments_url":"https://api.github.com/repos/williampma/opencog/comments{/number}","issue_comment_url":"https://api.github.com/repos/williampma/opencog/issues/comments/{number}","contents_url":"https://api.github.com/repos/williampma/opencog/contents/{+path}","compare_url":"https://api.github.com/repos/williampma/opencog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/williampma/opencog/merges","archive_url":"https://api.github.com/repos/williampma/opencog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/williampma/opencog/downloads","issues_url":"https://api.github.com/repos/williampma/opencog/issues{/number}","pulls_url":"https://api.github.com/repos/williampma/opencog/pulls{/number}","milestones_url":"https://api.github.com/repos/williampma/opencog/milestones{/number}","notifications_url":"https://api.github.com/repos/williampma/opencog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/williampma/opencog/labels{/name}","releases_url":"https://api.github.com/repos/williampma/opencog/releases{/id}","created_at":"2014-04-15T08:10:05Z","updated_at":"2014-12-31T06:40:25Z","pushed_at":"2015-01-08T08:39:19Z","git_url":"git://github.com/williampma/opencog.git","ssh_url":"git@github.com:williampma/opencog.git","clone_url":"https://github.com/williampma/opencog.git","svn_url":"https://github.com/williampma/opencog","homepage":"http://wiki.opencog.org/w/Development","size":134981,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencog:master","ref":"master","sha":"7e8302176e26a1d5ba3f7033ebf2e161c4aa8dfd","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}","created_at":"2012-10-24T06:10:15Z","updated_at":"2015-01-08T04:45:39Z","pushed_at":"2015-01-08T04:45:38Z","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":143728,"stargazers_count":478,"watchers_count":478,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":222,"mirror_url":null,"open_issues_count":56,"forks":222,"open_issues":56,"watchers":478,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencog/opencog/pulls/1187"},"html":{"href":"https://github.com/opencog/opencog/pull/1187"},"issue":{"href":"https://api.github.com/repos/opencog/opencog/issues/1187"},"comments":{"href":"https://api.github.com/repos/opencog/opencog/issues/1187/comments"},"review_comments":{"href":"https://api.github.com/repos/opencog/opencog/pulls/1187/comments"},"review_comment":{"href":"https://api.github.com/repos/opencog/opencog/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/opencog/opencog/pulls/1187/commits"},"statuses":{"href":"https://api.github.com/repos/opencog/opencog/statuses/49541262c7208e3d70669557320c9d1144aa51cb"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":12,"additions":965,"deletions":50,"changed_files":18}}