{"action":"created","comment":{"url":"https://api.github.com/repos/seedco/megophone/pulls/comments/30748243","id":30748243,"diff_hunk":"@@ -0,0 +1,696 @@\n+package megophone\n+\n+/*\n+The original Metaphone algorithm was published in 1990 as an improvement over\n+the Soundex algorithm. Like Soundex, it was limited to English-only use. The\n+Metaphone algorithm does not produce phonetic representations of an input word\n+or name; rather, the output is an intentionally approximate phonetic\n+representation. The approximate encoding is necessary to account for the way\n+speakers vary their pronunciations and misspell or otherwise vary words and\n+names they are trying to spell.\n+The Double Metaphone phonetic encoding algorithm is the second generation of\n+the Metaphone algorithm. Its implementation was described in the June 2000\n+issue of C/C++ Users Journal. It makes a number of fundamental design\n+improvements over the original Metaphone algorithm.\n+It is called \"Double\" because it can return both a primary and a secondary code\n+for a string; this accounts for some ambiguous cases as well as for multiple\n+variants of surnames with common ancestry. For example, encoding the name\n+\"Smith\" yields a primary code of SM0 and a secondary code of XMT, while the\n+name \"Schmidt\" yields a primary code of XMT and a secondary code of SMT--both\n+have XMT in common.\n+Double Metaphone tries to account for myriad irregularities in English of\n+Slavic, Germanic, Celtic, Greek, French, Italian, Spanish, Chinese, and other\n+origin. Thus it uses a much more complex ruleset for coding than its\n+predecessor; for example, it tests for approximately 100 different contexts of\n+the use of the letter C alone.\n+This script implements the Double Metaphone algorithm (c) 1998, 1999 originally\n+implemented by Lawrence Philips in C++. It was further modified in C++ by Kevin\n+Atkinson (http {//aspell.net/metaphone/). It was translated to C by Maurice\n+Aubrey <maurice@hevanet.com> for use in a Perl extension. A Python version was\n+created by Andrew Collins on January 12, 2007, using the C source\n+(http {//www.atomodo.com/code/double-metaphone/metaphone.py/view). It was also\n+translated to Go by Adele Dewey-Lopez <adele@seed.co> using Atkinson's C++ source,\n+with some further revisions.\n+  Updated 2007-02-14 - Found a typo in the 'gh' section (0.1.1)\n+  Updated 2007-12-17 - Bugs fixed in 'S', 'Z', and 'J' sections (0.2;\n+                       Chris Leong)\n+  Updated 2009-03-05 - Various bug fixes against the reference C++\n+                       implementation (0.3; Matthew Somerville)\n+  Updated 2012-07    - Fixed long lines, added more docs, changed names,\n+                       reformulated as objects, fixed a bug in 'G'\n+                       (0.4; Duncan McGreggor)\n+  Updated 2013-06    - Enforced unicode literals (0.5; Ian Beaver)\n+  Updated 2015-05\t - // TODO: Write out all the changes I've made\n+*/\n+\n+import (\n+\t\"fmt\"\n+\t\"strings\"\n+)\n+\n+type phoneticData struct {\n+\tword            string\n+\tcur             int\n+\tisSlavoGermanic bool\n+\tmetaphone1      string\n+\tmetaphone2      string\n+}\n+\n+func (p *phoneticData) endsWith(matches ...string) bool {\n+\tend := strings.Index(p.word[p.cur:], \" \")\n+\tif end != -1 {\n+\t\tfor _, str := range matches {\n+\n+\t\t\tif strings.Contains(p.word[p.cur:p.cur+end+1], str+\" \") {\n+\t\t\t\treturn true\n+\t\t\t}\n+\t\t}\n+\t}\n+\treturn false\n+}\n+\n+func (p *phoneticData) beginsWith(matches ...string) bool {\n+\tstart := strings.LastIndex(p.word[:p.cur], \" \")\n+\tif start != -1 {\n+\t\tfor _, str := range matches {\n+\n+\t\t\tif strings.Contains(p.word[start:p.cur], \" \"+str) {\n+\t\t\t\treturn true\n+\t\t\t}\n+\t\t}\n+\t}\n+\treturn false\n+}\n+\n+func (p *phoneticData) containsAny(matches ...string) bool {\n+\tfor _, str := range matches {\n+\n+\t\tif strings.Contains(p.word, str) {\n+\t\t\treturn true\n+\t\t}\n+\t}\n+\n+\treturn false\n+}\n+\n+func (p *phoneticData) matchesAny(pos int, matches ...string) bool {\n+\tif len(matches) == 0 {\n+\t\treturn true\n+\t}\n+\t// out of bounds\n+\tif p.cur+pos < 0 {\n+\t\treturn false\n+\t}\n+\n+\tfor i, str := range matches {\n+\t\tsize := len(matches[i])\n+\t\t// bounds check\n+\t\tif p.cur+pos+size <= len(p.word) {\n+\t\t\tif p.word[p.cur+pos:p.cur+size+pos] == str {\n+\t\t\t\treturn true\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn false\n+}\n+\n+func (p *phoneticData) add(phoneme ...string) {\n+\tif len(phoneme) > 0 {\n+\t\tp.metaphone1 += phoneme[0]\n+\t\tif len(phoneme) > 1 {\n+\t\t\tp.metaphone2 += phoneme[1]\n+\t\t} else {\n+\t\t\tp.metaphone2 += phoneme[0]\n+\t\t}\n+\t}\n+}\n+\n+func (p *phoneticData) skip(skipBy int) {\n+\tp.cur += skipBy\n+}\n+\n+func (p *phoneticData) isVowel(pos int) bool {\n+\treturn p.matchesAny(pos, \"a\", \"e\", \"i\", \"o\", \"u\", \"y\")\n+}\n+\n+func (p *phoneticData) b() {\n+\tp.add(\"p\")\n+\t// skip double b\n+\tif p.matchesAny(1, \"b\") {\n+\t\tp.skip(1)\n+\t}\n+}\n+\n+func (p *phoneticData) ç() {\n+\tp.add(\"s\")\n+\tp.skip(1) // because this character is two bytes","path":"metaphone.go","position":147,"original_position":147,"commit_id":"c2397d66ea03d3ca19b695968ff75c9981764f9b","original_commit_id":"c2397d66ea03d3ca19b695968ff75c9981764f9b","user":{"login":"swenson","id":33404,"avatar_url":"https://avatars.githubusercontent.com/u/33404?v=3","gravatar_id":"","url":"https://api.github.com/users/swenson","html_url":"https://github.com/swenson","followers_url":"https://api.github.com/users/swenson/followers","following_url":"https://api.github.com/users/swenson/following{/other_user}","gists_url":"https://api.github.com/users/swenson/gists{/gist_id}","starred_url":"https://api.github.com/users/swenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swenson/subscriptions","organizations_url":"https://api.github.com/users/swenson/orgs","repos_url":"https://api.github.com/users/swenson/repos","events_url":"https://api.github.com/users/swenson/events{/privacy}","received_events_url":"https://api.github.com/users/swenson/received_events","type":"User","site_admin":false},"body":"Well, that way is  hardly nice. But `[]rune` probably is. :)","created_at":"2015-05-20T20:54:54Z","updated_at":"2015-05-20T20:54:54Z","html_url":"https://github.com/seedco/megophone/pull/1#discussion_r30748243","pull_request_url":"https://api.github.com/repos/seedco/megophone/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/seedco/megophone/pulls/comments/30748243"},"html":{"href":"https://github.com/seedco/megophone/pull/1#discussion_r30748243"},"pull_request":{"href":"https://api.github.com/repos/seedco/megophone/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/seedco/megophone/pulls/1","id":35873470,"html_url":"https://github.com/seedco/megophone/pull/1","diff_url":"https://github.com/seedco/megophone/pull/1.diff","patch_url":"https://github.com/seedco/megophone/pull/1.patch","issue_url":"https://api.github.com/repos/seedco/megophone/issues/1","number":1,"state":"open","locked":false,"title":"First pr","user":{"login":"adeledeweylopez","id":6953640,"avatar_url":"https://avatars.githubusercontent.com/u/6953640?v=3","gravatar_id":"","url":"https://api.github.com/users/adeledeweylopez","html_url":"https://github.com/adeledeweylopez","followers_url":"https://api.github.com/users/adeledeweylopez/followers","following_url":"https://api.github.com/users/adeledeweylopez/following{/other_user}","gists_url":"https://api.github.com/users/adeledeweylopez/gists{/gist_id}","starred_url":"https://api.github.com/users/adeledeweylopez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adeledeweylopez/subscriptions","organizations_url":"https://api.github.com/users/adeledeweylopez/orgs","repos_url":"https://api.github.com/users/adeledeweylopez/repos","events_url":"https://api.github.com/users/adeledeweylopez/events{/privacy}","received_events_url":"https://api.github.com/users/adeledeweylopez/received_events","type":"User","site_admin":false},"body":"Implement the Double-Metaphone algorithm, making several improvements along the way. ","created_at":"2015-05-20T20:39:33Z","updated_at":"2015-05-20T20:54:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cdea0b20a5b046f6481f92c806c411aef1a5514","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/seedco/megophone/pulls/1/commits","review_comments_url":"https://api.github.com/repos/seedco/megophone/pulls/1/comments","review_comment_url":"https://api.github.com/repos/seedco/megophone/pulls/comments{/number}","comments_url":"https://api.github.com/repos/seedco/megophone/issues/1/comments","statuses_url":"https://api.github.com/repos/seedco/megophone/statuses/c2397d66ea03d3ca19b695968ff75c9981764f9b","head":{"label":"seedco:first-pr","ref":"first-pr","sha":"c2397d66ea03d3ca19b695968ff75c9981764f9b","user":{"login":"seedco","id":8824986,"avatar_url":"https://avatars.githubusercontent.com/u/8824986?v=3","gravatar_id":"","url":"https://api.github.com/users/seedco","html_url":"https://github.com/seedco","followers_url":"https://api.github.com/users/seedco/followers","following_url":"https://api.github.com/users/seedco/following{/other_user}","gists_url":"https://api.github.com/users/seedco/gists{/gist_id}","starred_url":"https://api.github.com/users/seedco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seedco/subscriptions","organizations_url":"https://api.github.com/users/seedco/orgs","repos_url":"https://api.github.com/users/seedco/repos","events_url":"https://api.github.com/users/seedco/events{/privacy}","received_events_url":"https://api.github.com/users/seedco/received_events","type":"Organization","site_admin":false},"repo":{"id":35302151,"name":"megophone","full_name":"seedco/megophone","owner":{"login":"seedco","id":8824986,"avatar_url":"https://avatars.githubusercontent.com/u/8824986?v=3","gravatar_id":"","url":"https://api.github.com/users/seedco","html_url":"https://github.com/seedco","followers_url":"https://api.github.com/users/seedco/followers","following_url":"https://api.github.com/users/seedco/following{/other_user}","gists_url":"https://api.github.com/users/seedco/gists{/gist_id}","starred_url":"https://api.github.com/users/seedco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seedco/subscriptions","organizations_url":"https://api.github.com/users/seedco/orgs","repos_url":"https://api.github.com/users/seedco/repos","events_url":"https://api.github.com/users/seedco/events{/privacy}","received_events_url":"https://api.github.com/users/seedco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seedco/megophone","description":"The Double-Metaphone algorithm in Go.","fork":false,"url":"https://api.github.com/repos/seedco/megophone","forks_url":"https://api.github.com/repos/seedco/megophone/forks","keys_url":"https://api.github.com/repos/seedco/megophone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seedco/megophone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seedco/megophone/teams","hooks_url":"https://api.github.com/repos/seedco/megophone/hooks","issue_events_url":"https://api.github.com/repos/seedco/megophone/issues/events{/number}","events_url":"https://api.github.com/repos/seedco/megophone/events","assignees_url":"https://api.github.com/repos/seedco/megophone/assignees{/user}","branches_url":"https://api.github.com/repos/seedco/megophone/branches{/branch}","tags_url":"https://api.github.com/repos/seedco/megophone/tags","blobs_url":"https://api.github.com/repos/seedco/megophone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seedco/megophone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seedco/megophone/git/refs{/sha}","trees_url":"https://api.github.com/repos/seedco/megophone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seedco/megophone/statuses/{sha}","languages_url":"https://api.github.com/repos/seedco/megophone/languages","stargazers_url":"https://api.github.com/repos/seedco/megophone/stargazers","contributors_url":"https://api.github.com/repos/seedco/megophone/contributors","subscribers_url":"https://api.github.com/repos/seedco/megophone/subscribers","subscription_url":"https://api.github.com/repos/seedco/megophone/subscription","commits_url":"https://api.github.com/repos/seedco/megophone/commits{/sha}","git_commits_url":"https://api.github.com/repos/seedco/megophone/git/commits{/sha}","comments_url":"https://api.github.com/repos/seedco/megophone/comments{/number}","issue_comment_url":"https://api.github.com/repos/seedco/megophone/issues/comments{/number}","contents_url":"https://api.github.com/repos/seedco/megophone/contents/{+path}","compare_url":"https://api.github.com/repos/seedco/megophone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seedco/megophone/merges","archive_url":"https://api.github.com/repos/seedco/megophone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seedco/megophone/downloads","issues_url":"https://api.github.com/repos/seedco/megophone/issues{/number}","pulls_url":"https://api.github.com/repos/seedco/megophone/pulls{/number}","milestones_url":"https://api.github.com/repos/seedco/megophone/milestones{/number}","notifications_url":"https://api.github.com/repos/seedco/megophone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seedco/megophone/labels{/name}","releases_url":"https://api.github.com/repos/seedco/megophone/releases{/id}","created_at":"2015-05-08T21:16:19Z","updated_at":"2015-05-20T20:38:54Z","pushed_at":"2015-05-20T20:39:34Z","git_url":"git://github.com/seedco/megophone.git","ssh_url":"git@github.com:seedco/megophone.git","clone_url":"https://github.com/seedco/megophone.git","svn_url":"https://github.com/seedco/megophone","homepage":null,"size":132,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"seedco:master","ref":"master","sha":"b97b2197e1c1f6d0a650e9ac96a32a18754f6c18","user":{"login":"seedco","id":8824986,"avatar_url":"https://avatars.githubusercontent.com/u/8824986?v=3","gravatar_id":"","url":"https://api.github.com/users/seedco","html_url":"https://github.com/seedco","followers_url":"https://api.github.com/users/seedco/followers","following_url":"https://api.github.com/users/seedco/following{/other_user}","gists_url":"https://api.github.com/users/seedco/gists{/gist_id}","starred_url":"https://api.github.com/users/seedco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seedco/subscriptions","organizations_url":"https://api.github.com/users/seedco/orgs","repos_url":"https://api.github.com/users/seedco/repos","events_url":"https://api.github.com/users/seedco/events{/privacy}","received_events_url":"https://api.github.com/users/seedco/received_events","type":"Organization","site_admin":false},"repo":{"id":35302151,"name":"megophone","full_name":"seedco/megophone","owner":{"login":"seedco","id":8824986,"avatar_url":"https://avatars.githubusercontent.com/u/8824986?v=3","gravatar_id":"","url":"https://api.github.com/users/seedco","html_url":"https://github.com/seedco","followers_url":"https://api.github.com/users/seedco/followers","following_url":"https://api.github.com/users/seedco/following{/other_user}","gists_url":"https://api.github.com/users/seedco/gists{/gist_id}","starred_url":"https://api.github.com/users/seedco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seedco/subscriptions","organizations_url":"https://api.github.com/users/seedco/orgs","repos_url":"https://api.github.com/users/seedco/repos","events_url":"https://api.github.com/users/seedco/events{/privacy}","received_events_url":"https://api.github.com/users/seedco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seedco/megophone","description":"The Double-Metaphone algorithm in Go.","fork":false,"url":"https://api.github.com/repos/seedco/megophone","forks_url":"https://api.github.com/repos/seedco/megophone/forks","keys_url":"https://api.github.com/repos/seedco/megophone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seedco/megophone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seedco/megophone/teams","hooks_url":"https://api.github.com/repos/seedco/megophone/hooks","issue_events_url":"https://api.github.com/repos/seedco/megophone/issues/events{/number}","events_url":"https://api.github.com/repos/seedco/megophone/events","assignees_url":"https://api.github.com/repos/seedco/megophone/assignees{/user}","branches_url":"https://api.github.com/repos/seedco/megophone/branches{/branch}","tags_url":"https://api.github.com/repos/seedco/megophone/tags","blobs_url":"https://api.github.com/repos/seedco/megophone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seedco/megophone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seedco/megophone/git/refs{/sha}","trees_url":"https://api.github.com/repos/seedco/megophone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seedco/megophone/statuses/{sha}","languages_url":"https://api.github.com/repos/seedco/megophone/languages","stargazers_url":"https://api.github.com/repos/seedco/megophone/stargazers","contributors_url":"https://api.github.com/repos/seedco/megophone/contributors","subscribers_url":"https://api.github.com/repos/seedco/megophone/subscribers","subscription_url":"https://api.github.com/repos/seedco/megophone/subscription","commits_url":"https://api.github.com/repos/seedco/megophone/commits{/sha}","git_commits_url":"https://api.github.com/repos/seedco/megophone/git/commits{/sha}","comments_url":"https://api.github.com/repos/seedco/megophone/comments{/number}","issue_comment_url":"https://api.github.com/repos/seedco/megophone/issues/comments{/number}","contents_url":"https://api.github.com/repos/seedco/megophone/contents/{+path}","compare_url":"https://api.github.com/repos/seedco/megophone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seedco/megophone/merges","archive_url":"https://api.github.com/repos/seedco/megophone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seedco/megophone/downloads","issues_url":"https://api.github.com/repos/seedco/megophone/issues{/number}","pulls_url":"https://api.github.com/repos/seedco/megophone/pulls{/number}","milestones_url":"https://api.github.com/repos/seedco/megophone/milestones{/number}","notifications_url":"https://api.github.com/repos/seedco/megophone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seedco/megophone/labels{/name}","releases_url":"https://api.github.com/repos/seedco/megophone/releases{/id}","created_at":"2015-05-08T21:16:19Z","updated_at":"2015-05-20T20:38:54Z","pushed_at":"2015-05-20T20:39:34Z","git_url":"git://github.com/seedco/megophone.git","ssh_url":"git@github.com:seedco/megophone.git","clone_url":"https://github.com/seedco/megophone.git","svn_url":"https://github.com/seedco/megophone","homepage":null,"size":132,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/seedco/megophone/pulls/1"},"html":{"href":"https://github.com/seedco/megophone/pull/1"},"issue":{"href":"https://api.github.com/repos/seedco/megophone/issues/1"},"comments":{"href":"https://api.github.com/repos/seedco/megophone/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/seedco/megophone/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/seedco/megophone/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/seedco/megophone/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/seedco/megophone/statuses/c2397d66ea03d3ca19b695968ff75c9981764f9b"}}}}