{"action":"created","comment":{"url":"https://api.github.com/repos/inaka/sheldon/pulls/comments/76815021","id":76815021,"diff_hunk":"@@ -0,0 +1,156 @@\n+%%% @doc This gen_server only creates the ets for the dictionary and\n+%%%      ets for bazingas.\n+%%%\n+%%% Copyright 2016 Inaka &lt;hello@inaka.net&gt;\n+%%%\n+%%% Licensed under the Apache License, Version 2.0 (the \"License\");\n+%%% you may not use this file except in compliance with the License.\n+%%% You may obtain a copy of the License at\n+%%%\n+%%%     http://www.apache.org/licenses/LICENSE-2.0\n+%%%\n+%%% Unless required by applicable law or agreed to in writing, software\n+%%% distributed under the License is distributed on an \"AS IS\" BASIS,\n+%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+%%% See the License for the specific language governing permissions and\n+%%% limitations under the License.\n+%%% @end\n+%%% @copyright Inaka <hello@inaka.net>\n+%%%\n+-module(sheldon_dictionary).\n+-author(\"Felipe Ripoll <ferigis@gmail.com>\").\n+\n+-behaviour(gen_server).\n+\n+%% API\n+-export([\n+          start_link/1\n+        , exist_in_dictionary/2\n+        , dictionary_name/1\n+        , get_bazinga/1\n+        ]).\n+\n+%% gen_server callbacks\n+-export([\n+          init/1\n+        , handle_call/3\n+        , handle_cast/2\n+        , handle_info/2\n+        , terminate/2\n+        , code_change/3\n+        ]).\n+\n+\n+-export_type([\n+                language/0\n+             ]).\n+\n+-type language() :: eng.\n+\n+%%%===================================================================\n+%%% API\n+%%%===================================================================\n+\n+-spec(start_link(language()) ->\n+  {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).\n+start_link(Lang) ->\n+  gen_server:start_link({local, ?MODULE}, ?MODULE, [Lang], []).\n+\n+-spec exist_in_dictionary(language(), string()) -> boolean().\n+exist_in_dictionary(Lang, Word) ->\n+  DictName = dictionary_name(Lang),\n+  LowerWord = string:to_lower(Word),\n+  case ets:lookup(DictName, LowerWord) of\n+    [] -> false;\n+    _  -> true\n+  end.\n+\n+-spec get_bazinga(language()) -> string().\n+get_bazinga(Lang) ->\n+  BazingaName = bazinga_name(Lang),\n+  Keys = ets:tab2list(BazingaName),\n+  {Bazinga} = lists:nth(random:uniform(length(Keys)), Keys),\n+  Bazinga.\n+\n+-spec dictionary_name(language()) -> atom().\n+dictionary_name(Lang) ->\n+  Bin = <<(atom_to_binary(sheldon, utf8))/binary, \"_\",\n+  (atom_to_binary(Lang, utf8))/binary>>,\n+  binary_to_atom(Bin, utf8).\n+\n+%%%===================================================================\n+%%% gen_server callbacks\n+%%%===================================================================\n+\n+-spec(init([language()]) -> {ok, State :: map()}).\n+init([Lang]) ->\n+  ok = learn_language(Lang),\n+  ok = set_bazingas(Lang),\n+  {ok, #{}}.\n+\n+-spec(  handle_call(Request :: term()\n+      , From :: {pid()\n+      , Tag :: term()}\n+      , State) -> {reply, ok, State}).\n+handle_call(_Request, _From, State) ->\n+  {reply, ok, State}.\n+\n+-spec(handle_cast(Request :: term(), State) ->\n+  {noreply, State}).\n+handle_cast(_Request, State) ->\n+  {noreply, State}.\n+\n+-spec(handle_info(Info :: timeout() | term(), State) ->","path":"src/sheldon_dictionary.erl","position":103,"original_position":103,"commit_id":"841a1bc9e473ed67f8443b33d10f64a28da0dee4","original_commit_id":"841a1bc9e473ed67f8443b33d10f64a28da0dee4","user":{"login":"harenson","id":216031,"avatar_url":"https://avatars.githubusercontent.com/u/216031?v=3","gravatar_id":"","url":"https://api.github.com/users/harenson","html_url":"https://github.com/harenson","followers_url":"https://api.github.com/users/harenson/followers","following_url":"https://api.github.com/users/harenson/following{/other_user}","gists_url":"https://api.github.com/users/harenson/gists{/gist_id}","starred_url":"https://api.github.com/users/harenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harenson/subscriptions","organizations_url":"https://api.github.com/users/harenson/orgs","repos_url":"https://api.github.com/users/harenson/repos","events_url":"https://api.github.com/users/harenson/events{/privacy}","received_events_url":"https://api.github.com/users/harenson/received_events","type":"User","site_admin":false},"body":"Same as above.","created_at":"2016-08-30T15:10:15Z","updated_at":"2016-08-30T15:10:15Z","html_url":"https://github.com/inaka/sheldon/pull/3#discussion_r76815021","pull_request_url":"https://api.github.com/repos/inaka/sheldon/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/inaka/sheldon/pulls/comments/76815021"},"html":{"href":"https://github.com/inaka/sheldon/pull/3#discussion_r76815021"},"pull_request":{"href":"https://api.github.com/repos/inaka/sheldon/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/inaka/sheldon/pulls/3","id":83168856,"html_url":"https://github.com/inaka/sheldon/pull/3","diff_url":"https://github.com/inaka/sheldon/pull/3.diff","patch_url":"https://github.com/inaka/sheldon/pull/3.patch","issue_url":"https://api.github.com/repos/inaka/sheldon/issues/3","number":3,"state":"open","locked":false,"title":"[#129082831] added main feature for check spelling","user":{"login":"ferigis","id":7842646,"avatar_url":"https://avatars.githubusercontent.com/u/7842646?v=3","gravatar_id":"","url":"https://api.github.com/users/ferigis","html_url":"https://github.com/ferigis","followers_url":"https://api.github.com/users/ferigis/followers","following_url":"https://api.github.com/users/ferigis/following{/other_user}","gists_url":"https://api.github.com/users/ferigis/gists{/gist_id}","starred_url":"https://api.github.com/users/ferigis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferigis/subscriptions","organizations_url":"https://api.github.com/users/ferigis/orgs","repos_url":"https://api.github.com/users/ferigis/repos","events_url":"https://api.github.com/users/ferigis/events{/privacy}","received_events_url":"https://api.github.com/users/ferigis/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-29T21:14:19Z","updated_at":"2016-08-30T15:10:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0dcd37ee430dd653ec56be98431ecfe12902d59b","assignee":{"login":"harenson","id":216031,"avatar_url":"https://avatars.githubusercontent.com/u/216031?v=3","gravatar_id":"","url":"https://api.github.com/users/harenson","html_url":"https://github.com/harenson","followers_url":"https://api.github.com/users/harenson/followers","following_url":"https://api.github.com/users/harenson/following{/other_user}","gists_url":"https://api.github.com/users/harenson/gists{/gist_id}","starred_url":"https://api.github.com/users/harenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harenson/subscriptions","organizations_url":"https://api.github.com/users/harenson/orgs","repos_url":"https://api.github.com/users/harenson/repos","events_url":"https://api.github.com/users/harenson/events{/privacy}","received_events_url":"https://api.github.com/users/harenson/received_events","type":"User","site_admin":false},"assignees":[{"login":"harenson","id":216031,"avatar_url":"https://avatars.githubusercontent.com/u/216031?v=3","gravatar_id":"","url":"https://api.github.com/users/harenson","html_url":"https://github.com/harenson","followers_url":"https://api.github.com/users/harenson/followers","following_url":"https://api.github.com/users/harenson/following{/other_user}","gists_url":"https://api.github.com/users/harenson/gists{/gist_id}","starred_url":"https://api.github.com/users/harenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harenson/subscriptions","organizations_url":"https://api.github.com/users/harenson/orgs","repos_url":"https://api.github.com/users/harenson/repos","events_url":"https://api.github.com/users/harenson/events{/privacy}","received_events_url":"https://api.github.com/users/harenson/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/inaka/sheldon/pulls/3/commits","review_comments_url":"https://api.github.com/repos/inaka/sheldon/pulls/3/comments","review_comment_url":"https://api.github.com/repos/inaka/sheldon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inaka/sheldon/issues/3/comments","statuses_url":"https://api.github.com/repos/inaka/sheldon/statuses/841a1bc9e473ed67f8443b33d10f64a28da0dee4","head":{"label":"inaka:ferigis.129082831.check_spelling","ref":"ferigis.129082831.check_spelling","sha":"841a1bc9e473ed67f8443b33d10f64a28da0dee4","user":{"login":"inaka","id":867053,"avatar_url":"https://avatars.githubusercontent.com/u/867053?v=3","gravatar_id":"","url":"https://api.github.com/users/inaka","html_url":"https://github.com/inaka","followers_url":"https://api.github.com/users/inaka/followers","following_url":"https://api.github.com/users/inaka/following{/other_user}","gists_url":"https://api.github.com/users/inaka/gists{/gist_id}","starred_url":"https://api.github.com/users/inaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inaka/subscriptions","organizations_url":"https://api.github.com/users/inaka/orgs","repos_url":"https://api.github.com/users/inaka/repos","events_url":"https://api.github.com/users/inaka/events{/privacy}","received_events_url":"https://api.github.com/users/inaka/received_events","type":"Organization","site_admin":false},"repo":{"id":66585214,"name":"sheldon","full_name":"inaka/sheldon","owner":{"login":"inaka","id":867053,"avatar_url":"https://avatars.githubusercontent.com/u/867053?v=3","gravatar_id":"","url":"https://api.github.com/users/inaka","html_url":"https://github.com/inaka","followers_url":"https://api.github.com/users/inaka/followers","following_url":"https://api.github.com/users/inaka/following{/other_user}","gists_url":"https://api.github.com/users/inaka/gists{/gist_id}","starred_url":"https://api.github.com/users/inaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inaka/subscriptions","organizations_url":"https://api.github.com/users/inaka/orgs","repos_url":"https://api.github.com/users/inaka/repos","events_url":"https://api.github.com/users/inaka/events{/privacy}","received_events_url":"https://api.github.com/users/inaka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inaka/sheldon","description":"Very Simple Erlang Spell Checker","fork":false,"url":"https://api.github.com/repos/inaka/sheldon","forks_url":"https://api.github.com/repos/inaka/sheldon/forks","keys_url":"https://api.github.com/repos/inaka/sheldon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inaka/sheldon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inaka/sheldon/teams","hooks_url":"https://api.github.com/repos/inaka/sheldon/hooks","issue_events_url":"https://api.github.com/repos/inaka/sheldon/issues/events{/number}","events_url":"https://api.github.com/repos/inaka/sheldon/events","assignees_url":"https://api.github.com/repos/inaka/sheldon/assignees{/user}","branches_url":"https://api.github.com/repos/inaka/sheldon/branches{/branch}","tags_url":"https://api.github.com/repos/inaka/sheldon/tags","blobs_url":"https://api.github.com/repos/inaka/sheldon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inaka/sheldon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inaka/sheldon/git/refs{/sha}","trees_url":"https://api.github.com/repos/inaka/sheldon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inaka/sheldon/statuses/{sha}","languages_url":"https://api.github.com/repos/inaka/sheldon/languages","stargazers_url":"https://api.github.com/repos/inaka/sheldon/stargazers","contributors_url":"https://api.github.com/repos/inaka/sheldon/contributors","subscribers_url":"https://api.github.com/repos/inaka/sheldon/subscribers","subscription_url":"https://api.github.com/repos/inaka/sheldon/subscription","commits_url":"https://api.github.com/repos/inaka/sheldon/commits{/sha}","git_commits_url":"https://api.github.com/repos/inaka/sheldon/git/commits{/sha}","comments_url":"https://api.github.com/repos/inaka/sheldon/comments{/number}","issue_comment_url":"https://api.github.com/repos/inaka/sheldon/issues/comments{/number}","contents_url":"https://api.github.com/repos/inaka/sheldon/contents/{+path}","compare_url":"https://api.github.com/repos/inaka/sheldon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inaka/sheldon/merges","archive_url":"https://api.github.com/repos/inaka/sheldon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inaka/sheldon/downloads","issues_url":"https://api.github.com/repos/inaka/sheldon/issues{/number}","pulls_url":"https://api.github.com/repos/inaka/sheldon/pulls{/number}","milestones_url":"https://api.github.com/repos/inaka/sheldon/milestones{/number}","notifications_url":"https://api.github.com/repos/inaka/sheldon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inaka/sheldon/labels{/name}","releases_url":"https://api.github.com/repos/inaka/sheldon/releases{/id}","deployments_url":"https://api.github.com/repos/inaka/sheldon/deployments","created_at":"2016-08-25T19:03:27Z","updated_at":"2016-08-26T20:19:11Z","pushed_at":"2016-08-30T11:14:20Z","git_url":"git://github.com/inaka/sheldon.git","ssh_url":"git@github.com:inaka/sheldon.git","clone_url":"https://github.com/inaka/sheldon.git","svn_url":"https://github.com/inaka/sheldon","homepage":null,"size":1461,"stargazers_count":1,"watchers_count":1,"language":"Erlang","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":"inaka:master","ref":"master","sha":"f99ff4a64c95ed7953684edca42e4c7be1526276","user":{"login":"inaka","id":867053,"avatar_url":"https://avatars.githubusercontent.com/u/867053?v=3","gravatar_id":"","url":"https://api.github.com/users/inaka","html_url":"https://github.com/inaka","followers_url":"https://api.github.com/users/inaka/followers","following_url":"https://api.github.com/users/inaka/following{/other_user}","gists_url":"https://api.github.com/users/inaka/gists{/gist_id}","starred_url":"https://api.github.com/users/inaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inaka/subscriptions","organizations_url":"https://api.github.com/users/inaka/orgs","repos_url":"https://api.github.com/users/inaka/repos","events_url":"https://api.github.com/users/inaka/events{/privacy}","received_events_url":"https://api.github.com/users/inaka/received_events","type":"Organization","site_admin":false},"repo":{"id":66585214,"name":"sheldon","full_name":"inaka/sheldon","owner":{"login":"inaka","id":867053,"avatar_url":"https://avatars.githubusercontent.com/u/867053?v=3","gravatar_id":"","url":"https://api.github.com/users/inaka","html_url":"https://github.com/inaka","followers_url":"https://api.github.com/users/inaka/followers","following_url":"https://api.github.com/users/inaka/following{/other_user}","gists_url":"https://api.github.com/users/inaka/gists{/gist_id}","starred_url":"https://api.github.com/users/inaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inaka/subscriptions","organizations_url":"https://api.github.com/users/inaka/orgs","repos_url":"https://api.github.com/users/inaka/repos","events_url":"https://api.github.com/users/inaka/events{/privacy}","received_events_url":"https://api.github.com/users/inaka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inaka/sheldon","description":"Very Simple Erlang Spell Checker","fork":false,"url":"https://api.github.com/repos/inaka/sheldon","forks_url":"https://api.github.com/repos/inaka/sheldon/forks","keys_url":"https://api.github.com/repos/inaka/sheldon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inaka/sheldon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inaka/sheldon/teams","hooks_url":"https://api.github.com/repos/inaka/sheldon/hooks","issue_events_url":"https://api.github.com/repos/inaka/sheldon/issues/events{/number}","events_url":"https://api.github.com/repos/inaka/sheldon/events","assignees_url":"https://api.github.com/repos/inaka/sheldon/assignees{/user}","branches_url":"https://api.github.com/repos/inaka/sheldon/branches{/branch}","tags_url":"https://api.github.com/repos/inaka/sheldon/tags","blobs_url":"https://api.github.com/repos/inaka/sheldon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inaka/sheldon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inaka/sheldon/git/refs{/sha}","trees_url":"https://api.github.com/repos/inaka/sheldon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inaka/sheldon/statuses/{sha}","languages_url":"https://api.github.com/repos/inaka/sheldon/languages","stargazers_url":"https://api.github.com/repos/inaka/sheldon/stargazers","contributors_url":"https://api.github.com/repos/inaka/sheldon/contributors","subscribers_url":"https://api.github.com/repos/inaka/sheldon/subscribers","subscription_url":"https://api.github.com/repos/inaka/sheldon/subscription","commits_url":"https://api.github.com/repos/inaka/sheldon/commits{/sha}","git_commits_url":"https://api.github.com/repos/inaka/sheldon/git/commits{/sha}","comments_url":"https://api.github.com/repos/inaka/sheldon/comments{/number}","issue_comment_url":"https://api.github.com/repos/inaka/sheldon/issues/comments{/number}","contents_url":"https://api.github.com/repos/inaka/sheldon/contents/{+path}","compare_url":"https://api.github.com/repos/inaka/sheldon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inaka/sheldon/merges","archive_url":"https://api.github.com/repos/inaka/sheldon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inaka/sheldon/downloads","issues_url":"https://api.github.com/repos/inaka/sheldon/issues{/number}","pulls_url":"https://api.github.com/repos/inaka/sheldon/pulls{/number}","milestones_url":"https://api.github.com/repos/inaka/sheldon/milestones{/number}","notifications_url":"https://api.github.com/repos/inaka/sheldon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inaka/sheldon/labels{/name}","releases_url":"https://api.github.com/repos/inaka/sheldon/releases{/id}","deployments_url":"https://api.github.com/repos/inaka/sheldon/deployments","created_at":"2016-08-25T19:03:27Z","updated_at":"2016-08-26T20:19:11Z","pushed_at":"2016-08-30T11:14:20Z","git_url":"git://github.com/inaka/sheldon.git","ssh_url":"git@github.com:inaka/sheldon.git","clone_url":"https://github.com/inaka/sheldon.git","svn_url":"https://github.com/inaka/sheldon","homepage":null,"size":1461,"stargazers_count":1,"watchers_count":1,"language":"Erlang","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/inaka/sheldon/pulls/3"},"html":{"href":"https://github.com/inaka/sheldon/pull/3"},"issue":{"href":"https://api.github.com/repos/inaka/sheldon/issues/3"},"comments":{"href":"https://api.github.com/repos/inaka/sheldon/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/inaka/sheldon/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/inaka/sheldon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inaka/sheldon/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/inaka/sheldon/statuses/841a1bc9e473ed67f8443b33d10f64a28da0dee4"}}}}
{"actor":{"display_login":"harenson"}}