{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/30873118","id":30873118,"diff_hunk":"@@ -762,6 +762,52 @@\n       return;\n     }\n \n+    //\n+    // If there was an exact match for the user input in the suggestions\n+    // it has already been removed. Now we need to loop through again\n+    // looking for approximate matches and bump those to the start of the\n+    // list. A word is an approximate match if all the letters match\n+    // when we ignore case, apostrophes and hyphens. The assumption here\n+    // is that the user is not expected to have to use the shift key or\n+    // the alternate forms menu or the punctuation menus. If they type all\n+    // the right letters, a matching word should have higher priority than\n+    // a non-matching word. In particular this code ensures that \"im\" gets\n+    // autocorrected to \"I'm\" instead of \"in\" and \"id\" gets autocorrected to\n+    // \"I'd\" instead of \"is\". (Bug 1164421)\n+    //\n+    // XXX In Engish, apostrohes and hypens are the only punctuation that\n+    // commonly occurs within words. If other wordlists include other\n+    // punctuation, we may need to add them to the regular expression below.\n+    //\n+    // XXX In the future, we might want to generalize this to consider\n+    // accented forms when looking for approximate matches. If \"jose\"\n+    // was autocorrecting to \"hose\" instead of \"José\", for example, then\n+    // we might need to extend the definition of an approximate match here.\n+    // For now, I don't have any examples of corrections that are coming\n+    // out incorrectly for accented letters, though, so am keeping this\n+    // simple.\n+    //\n+    // We loop backward through the suggestions, bumping any approximate\n+    // match to the start of the list. This ensures that the highest ranked\n+    // approximate match comes before lower ranked approximate matches,\n+    // and all approximate matches come before non-matching suggestions.\n+    //\n+    var i = suggestions.length - 1;\n+    var approximateMatches = 0;  // how many approximate matches we've bumped\n+    var lcinput = input.toLowerCase();","path":"apps/keyboard/js/imes/latin/latin.js","position":36,"original_position":36,"commit_id":"649026cb72aa899a99e8eef5d2336e104f37708e","original_commit_id":"649026cb72aa899a99e8eef5d2336e104f37708e","user":{"login":"RudyLu","id":1704629,"avatar_url":"https://avatars.githubusercontent.com/u/1704629?v=3","gravatar_id":"","url":"https://api.github.com/users/RudyLu","html_url":"https://github.com/RudyLu","followers_url":"https://api.github.com/users/RudyLu/followers","following_url":"https://api.github.com/users/RudyLu/following{/other_user}","gists_url":"https://api.github.com/users/RudyLu/gists{/gist_id}","starred_url":"https://api.github.com/users/RudyLu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RudyLu/subscriptions","organizations_url":"https://api.github.com/users/RudyLu/orgs","repos_url":"https://api.github.com/users/RudyLu/repos","events_url":"https://api.github.com/users/RudyLu/events{/privacy}","received_events_url":"https://api.github.com/users/RudyLu/received_events","type":"User","site_admin":false},"body":"`lcInput`, or `lowerCaseInput`","created_at":"2015-05-22T07:03:41Z","updated_at":"2015-05-22T07:03:41Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/30186#discussion_r30873118","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/30873118"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/30186#discussion_r30873118"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186","id":35980018,"html_url":"https://github.com/mozilla-b2g/gaia/pull/30186","diff_url":"https://github.com/mozilla-b2g/gaia/pull/30186.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/30186.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30186","number":30186,"state":"open","locked":false,"title":"Bug 1164421 - autocorrect \"im\" to \"I'm\" not \"in\"","user":{"login":"davidflanagan","id":516914,"avatar_url":"https://avatars.githubusercontent.com/u/516914?v=3","gravatar_id":"","url":"https://api.github.com/users/davidflanagan","html_url":"https://github.com/davidflanagan","followers_url":"https://api.github.com/users/davidflanagan/followers","following_url":"https://api.github.com/users/davidflanagan/following{/other_user}","gists_url":"https://api.github.com/users/davidflanagan/gists{/gist_id}","starred_url":"https://api.github.com/users/davidflanagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidflanagan/subscriptions","organizations_url":"https://api.github.com/users/davidflanagan/orgs","repos_url":"https://api.github.com/users/davidflanagan/repos","events_url":"https://api.github.com/users/davidflanagan/events{/privacy}","received_events_url":"https://api.github.com/users/davidflanagan/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-21T21:33:38Z","updated_at":"2015-05-22T07:03:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"821037a47dd2d450f10d038b2cdfd5426d998155","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186/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/30186/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/649026cb72aa899a99e8eef5d2336e104f37708e","head":{"label":"davidflanagan:1164421","ref":"1164421","sha":"649026cb72aa899a99e8eef5d2336e104f37708e","user":{"login":"davidflanagan","id":516914,"avatar_url":"https://avatars.githubusercontent.com/u/516914?v=3","gravatar_id":"","url":"https://api.github.com/users/davidflanagan","html_url":"https://github.com/davidflanagan","followers_url":"https://api.github.com/users/davidflanagan/followers","following_url":"https://api.github.com/users/davidflanagan/following{/other_user}","gists_url":"https://api.github.com/users/davidflanagan/gists{/gist_id}","starred_url":"https://api.github.com/users/davidflanagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidflanagan/subscriptions","organizations_url":"https://api.github.com/users/davidflanagan/orgs","repos_url":"https://api.github.com/users/davidflanagan/repos","events_url":"https://api.github.com/users/davidflanagan/events{/privacy}","received_events_url":"https://api.github.com/users/davidflanagan/received_events","type":"User","site_admin":false},"repo":{"id":5606914,"name":"gaia","full_name":"davidflanagan/gaia","owner":{"login":"davidflanagan","id":516914,"avatar_url":"https://avatars.githubusercontent.com/u/516914?v=3","gravatar_id":"","url":"https://api.github.com/users/davidflanagan","html_url":"https://github.com/davidflanagan","followers_url":"https://api.github.com/users/davidflanagan/followers","following_url":"https://api.github.com/users/davidflanagan/following{/other_user}","gists_url":"https://api.github.com/users/davidflanagan/gists{/gist_id}","starred_url":"https://api.github.com/users/davidflanagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidflanagan/subscriptions","organizations_url":"https://api.github.com/users/davidflanagan/orgs","repos_url":"https://api.github.com/users/davidflanagan/repos","events_url":"https://api.github.com/users/davidflanagan/events{/privacy}","received_events_url":"https://api.github.com/users/davidflanagan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davidflanagan/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project","fork":true,"url":"https://api.github.com/repos/davidflanagan/gaia","forks_url":"https://api.github.com/repos/davidflanagan/gaia/forks","keys_url":"https://api.github.com/repos/davidflanagan/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidflanagan/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidflanagan/gaia/teams","hooks_url":"https://api.github.com/repos/davidflanagan/gaia/hooks","issue_events_url":"https://api.github.com/repos/davidflanagan/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/davidflanagan/gaia/events","assignees_url":"https://api.github.com/repos/davidflanagan/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/davidflanagan/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/davidflanagan/gaia/tags","blobs_url":"https://api.github.com/repos/davidflanagan/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidflanagan/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidflanagan/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidflanagan/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidflanagan/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/davidflanagan/gaia/languages","stargazers_url":"https://api.github.com/repos/davidflanagan/gaia/stargazers","contributors_url":"https://api.github.com/repos/davidflanagan/gaia/contributors","subscribers_url":"https://api.github.com/repos/davidflanagan/gaia/subscribers","subscription_url":"https://api.github.com/repos/davidflanagan/gaia/subscription","commits_url":"https://api.github.com/repos/davidflanagan/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidflanagan/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidflanagan/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidflanagan/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidflanagan/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/davidflanagan/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidflanagan/gaia/merges","archive_url":"https://api.github.com/repos/davidflanagan/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidflanagan/gaia/downloads","issues_url":"https://api.github.com/repos/davidflanagan/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/davidflanagan/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/davidflanagan/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/davidflanagan/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidflanagan/gaia/labels{/name}","releases_url":"https://api.github.com/repos/davidflanagan/gaia/releases{/id}","created_at":"2012-08-29T21:29:12Z","updated_at":"2015-02-19T00:39:14Z","pushed_at":"2015-05-21T21:32:20Z","git_url":"git://github.com/davidflanagan/gaia.git","ssh_url":"git@github.com:davidflanagan/gaia.git","clone_url":"https://github.com/davidflanagan/gaia.git","svn_url":"https://github.com/davidflanagan/gaia","homepage":"https://wiki.mozilla.org/B2G","size":965462,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"1126d8bee559f7cde675df2fcc6c196da9cfeba1","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","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=3","gravatar_id":"","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":"2015-05-21T02:40:44Z","pushed_at":"2015-05-22T06:36:27Z","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":1662347,"stargazers_count":1930,"watchers_count":1930,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2307,"mirror_url":null,"open_issues_count":984,"forks":2307,"open_issues":984,"watchers":1930,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/30186"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30186"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30186/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30186/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/30186/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/649026cb72aa899a99e8eef5d2336e104f37708e"}}}}