GitHub PullRequestReviewCommentEvent at 2014-08-06 09:03:53
Repository: gaia
Actor: janjongboom
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/15863048","id":15863048,"diff_hunk":"@@ -0,0 +1,190 @@\n+// This script contains the TST structure, methods to predict words\n+// The TST will be serialized into the same indexedDB as\n+// the word container by the userWorker.js script\n+// The maximum predictions from this script is limited to 2\n+// since only a maximum of 3 suggestions are displayed, we don't want to \n+// remove the correct suggestions altogether\n+// The maximum number of corrections from input is limted to 10\n+// \n+// The control flow is marked as follows:\n+// 1. The latin.js script requests the userWorker.js script to\n+//    provide suggestions\n+// \t  It passes the words in the indexedDB to the worker\n+//    It also passes a hasVersionChanged flag\n+//    This flag determines if a new TST is to be generated\n+// \t  The worker then fetches (or generates) a TST, \n+//    balances it, passes it back to latin.js which puts it back in the iDB\n+// 2. If a new TST is to be generated, the worker will make a new one \n+//    using this script\n+//    Or it will ask this script for predictions\n+// 3. Once the worker has predictions ready, \n+//    it will transfer the iDB and the predictions to latin.js\n+//\n+\n+\"use strict\";\n+\n+// This TST script is taken from \n+// https://github.com/jandre/js-ternary-tree/blob/master/ternary-tree.js\n+// The search function in the original script has been removed\n+// A new predict function has been made to cater to the needs\n+var Node = function() {\n+    function Node(character, is_word_end) {\n+        var self = this;\n+        self.character = character;\n+        self.left_node = null;\n+        self.right_node = null;\n+        self.center_node = null;\n+        self.is_word_end = is_word_end;\n+        self.count = 0;\n+        return self;\n+    };\n+    Node.prototype = {\n+        set_word_end: function() {\n+            var self = this;\n+            self.is_word_end = true;\n+        },\n+        left: function(node) {\n+            var self = this;\n+            if (node != undefined && node != null) {\n+                self.left_node = node;\n+            }\n+            return self.left_node;\n+        },\n+        right: function(node) {\n+            var self = this;\n+            if (node != undefined && node != null) {\n+                self.right_node = node;\n+            }\n+            return self.right_node;\n+        },\n+        center: function(node) {\n+            var self = this;\n+            if (node != undefined && node != null) {\n+                self.center_node = node;\n+            }\n+            return self.center_node;\n+        }\n+    };\n+    return Node;\n+}();\n+\n+\n+var TernaryTree = function() {\n+    function TernaryTree() {\n+        var self = this;\n+        self.root = null;\n+        return self;\n+    };\n+    TernaryTree.prototype = {\n+        _add: function(word, position, node_accessor) {\n+            var self = this;\n+            if (word == null || word == \"\")\n+                return;\n+            var node = node_accessor();\n+            if (node == null) {\n+                node = new Node(word[position], false);\n+                node_accessor(node);\n+                \n+            }\n+            var char = node.character;\n+            if (word[position] < char) {\n+                self._add(word, position, function(n) { \n+                    return node.left(n); } );\n+            } else if (word[position] > char) {\n+                self._add(word, position, function(n) { \n+                    return node.right(n); } );\n+            } else {\n+                if (position == (word.length - 1)) {\n+                    node.set_word_end();\n+                    /* node.is_word_end = true;*/\n+                } else {\n+                    self._add(word, position + 1, \n+                        function(n) { return node.center(n); } );\n+                }\n+            }\n+        },\n+\n+        add: function(word) {\n+            /* add a string to the tree */\n+            var self = this;\n+            var node_accessor = function(node) {\n+                if (node != undefined && node != null)\n+                    self.root = node;\n+                return self.root;\n+            };\n+            self._add(word, 0, node_accessor);\n+            self.setCount(self.root);\n+            return self;\n+        },\n+\n+        setCount: function(node) {\n+            var self = this;\n+            if(!node)\n+                return 0;\n+            node.count = self.setCount(node.left_node) + \n+                         self.setCount(node.right_node) + 1;\n+            self.setCount(node.center_node);\n+            return node.count;\n+        }\n+    }\n+    return TernaryTree;\n+}();\n+\n+var UserPrediction = function() {\n+\tconst maxCandidates = 10; // limit number of candidates to consider\n+\n+\tconst maxNumberOfSuggestions = 2; // One does not make many mistakes\n+\tconst maxDistance = 3; // Levenshtein distance of 3","path":"apps/keyboard/js/imes/latin/userPredictions.js","position":137,"original_position":137,"commit_id":"aa9d0773be6cbae3b7d3cd24b2d66759c8d81ce4","original_commit_id":"aa9d0773be6cbae3b7d3cd24b2d66759c8d81ce4","user":{"login":"janjongboom","id":816856,"avatar_url":"https://avatars.githubusercontent.com/u/816856?v=2","gravatar_id":"672b033bf66f18d40cff3278f12f8f90","url":"https://api.github.com/users/janjongboom","html_url":"https://github.com/janjongboom","followers_url":"https://api.github.com/users/janjongboom/followers","following_url":"https://api.github.com/users/janjongboom/following{/other_user}","gists_url":"https://api.github.com/users/janjongboom/gists{/gist_id}","starred_url":"https://api.github.com/users/janjongboom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janjongboom/subscriptions","organizations_url":"https://api.github.com/users/janjongboom/orgs","repos_url":"https://api.github.com/users/janjongboom/repos","events_url":"https://api.github.com/users/janjongboom/events{/privacy}","received_events_url":"https://api.github.com/users/janjongboom/received_events","type":"User","site_admin":false},"body":"Levenshtein distance of 3 is going to be pretty bad for performance on a bigger tree I think. We have any numbers on this?","created_at":"2014-08-06T09:03:53Z","updated_at":"2014-08-06T09:03:53Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/22535#discussion_r15863048","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/15863048"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/22535#discussion_r15863048"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535","id":19364537,"html_url":"https://github.com/mozilla-b2g/gaia/pull/22535","diff_url":"https://github.com/mozilla-b2g/gaia/pull/22535.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/22535.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/22535","number":22535,"state":"open","title":"GSoC'14 Keyboard project","user":{"login":"gargsms","id":5238955,"avatar_url":"https://avatars.githubusercontent.com/u/5238955?v=2","gravatar_id":"87d07270d6716c47db019139601e85ca","url":"https://api.github.com/users/gargsms","html_url":"https://github.com/gargsms","followers_url":"https://api.github.com/users/gargsms/followers","following_url":"https://api.github.com/users/gargsms/following{/other_user}","gists_url":"https://api.github.com/users/gargsms/gists{/gist_id}","starred_url":"https://api.github.com/users/gargsms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gargsms/subscriptions","organizations_url":"https://api.github.com/users/gargsms/orgs","repos_url":"https://api.github.com/users/gargsms/repos","events_url":"https://api.github.com/users/gargsms/events{/privacy}","received_events_url":"https://api.github.com/users/gargsms/received_events","type":"User","site_admin":false},"body":"Added support for a user dictionary.\r\n\r\nRemaining:\r\n1. Correct predictions for the input\r\n2. Merging the default predictions and new predictions\r\n3. Balancing the TST\r\n4. Tests\r\n5. Keyboard settings additions\r\n\r\nProbable support for:\r\n1. Export and import of dictionary for future use","created_at":"2014-08-05T19:42:17Z","updated_at":"2014-08-06T09:03:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ed9bb6b461406b0598370c83ada87b28488bf36","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/22535/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/aa9d0773be6cbae3b7d3cd24b2d66759c8d81ce4","head":{"label":"gargsms:master","ref":"master","sha":"aa9d0773be6cbae3b7d3cd24b2d66759c8d81ce4","user":{"login":"gargsms","id":5238955,"avatar_url":"https://avatars.githubusercontent.com/u/5238955?v=2","gravatar_id":"87d07270d6716c47db019139601e85ca","url":"https://api.github.com/users/gargsms","html_url":"https://github.com/gargsms","followers_url":"https://api.github.com/users/gargsms/followers","following_url":"https://api.github.com/users/gargsms/following{/other_user}","gists_url":"https://api.github.com/users/gargsms/gists{/gist_id}","starred_url":"https://api.github.com/users/gargsms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gargsms/subscriptions","organizations_url":"https://api.github.com/users/gargsms/orgs","repos_url":"https://api.github.com/users/gargsms/repos","events_url":"https://api.github.com/users/gargsms/events{/privacy}","received_events_url":"https://api.github.com/users/gargsms/received_events","type":"User","site_admin":false},"repo":{"id":22650112,"name":"gaia","full_name":"gargsms/gaia","owner":{"login":"gargsms","id":5238955,"avatar_url":"https://avatars.githubusercontent.com/u/5238955?v=2","gravatar_id":"87d07270d6716c47db019139601e85ca","url":"https://api.github.com/users/gargsms","html_url":"https://github.com/gargsms","followers_url":"https://api.github.com/users/gargsms/followers","following_url":"https://api.github.com/users/gargsms/following{/other_user}","gists_url":"https://api.github.com/users/gargsms/gists{/gist_id}","starred_url":"https://api.github.com/users/gargsms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gargsms/subscriptions","organizations_url":"https://api.github.com/users/gargsms/orgs","repos_url":"https://api.github.com/users/gargsms/repos","events_url":"https://api.github.com/users/gargsms/events{/privacy}","received_events_url":"https://api.github.com/users/gargsms/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gargsms/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":true,"url":"https://api.github.com/repos/gargsms/gaia","forks_url":"https://api.github.com/repos/gargsms/gaia/forks","keys_url":"https://api.github.com/repos/gargsms/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gargsms/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gargsms/gaia/teams","hooks_url":"https://api.github.com/repos/gargsms/gaia/hooks","issue_events_url":"https://api.github.com/repos/gargsms/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/gargsms/gaia/events","assignees_url":"https://api.github.com/repos/gargsms/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/gargsms/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/gargsms/gaia/tags","blobs_url":"https://api.github.com/repos/gargsms/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gargsms/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gargsms/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/gargsms/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gargsms/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/gargsms/gaia/languages","stargazers_url":"https://api.github.com/repos/gargsms/gaia/stargazers","contributors_url":"https://api.github.com/repos/gargsms/gaia/contributors","subscribers_url":"https://api.github.com/repos/gargsms/gaia/subscribers","subscription_url":"https://api.github.com/repos/gargsms/gaia/subscription","commits_url":"https://api.github.com/repos/gargsms/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/gargsms/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/gargsms/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/gargsms/gaia/issues/comments/{number}","contents_url":"https://api.github.com/repos/gargsms/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/gargsms/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gargsms/gaia/merges","archive_url":"https://api.github.com/repos/gargsms/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gargsms/gaia/downloads","issues_url":"https://api.github.com/repos/gargsms/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/gargsms/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/gargsms/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/gargsms/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gargsms/gaia/labels{/name}","releases_url":"https://api.github.com/repos/gargsms/gaia/releases{/id}","created_at":"2014-08-05T16:10:42Z","updated_at":"2014-08-05T18:44:15Z","pushed_at":"2014-08-05T19:34:21Z","git_url":"git://github.com/gargsms/gaia.git","ssh_url":"git@github.com:gargsms/gaia.git","clone_url":"https://github.com/gargsms/gaia.git","svn_url":"https://github.com/gargsms/gaia","homepage":"https://wiki.mozilla.org/B2G","size":810040,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"e2d1ed0f0be087a36ff4ad76a303de805d71591c","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=2","gravatar_id":"b1de11f7d6ddaf7b9d527281297c2ee1","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=2","gravatar_id":"b1de11f7d6ddaf7b9d527281297c2ee1","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","created_at":"2011-09-03T01:38:46Z","updated_at":"2014-08-06T08:19:00Z","pushed_at":"2014-08-06T07:55:43Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1340054,"stargazers_count":1678,"watchers_count":1678,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":1763,"mirror_url":null,"open_issues_count":1889,"forks":1763,"open_issues":1889,"watchers":1678,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/22535"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/22535"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/22535/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/22535/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/aa9d0773be6cbae3b7d3cd24b2d66759c8d81ce4"}}}}