{"action":"created","comment":{"url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/comments/154404936","pull_request_review_id":80569198,"id":154404936,"diff_hunk":"@@ -36,97 +36,87 @@ def on_status(self, status):\n         tweet_text = str(status.text.encode('utf_8'))\n         tweet_id = status.id\n \n+        frequency = defaultdict(int)\n+\n         query = tweet_text.split(\" \", tweet_text.count(\"@\"))[-1]\n-        query_encoded = urllib.quote_plus(query)\n \n-        frequency = defaultdict(int)\n+        max_tweets = 500\n \n-        MAX_TWEETS = 500\n-\n-        while True:\n-          try:\n-            LOGGER.info('Searching \"%s\"...', query)\n-            searched_tweets = [status for status in tweepy.Cursor(\n-                api.search, q=query_encoded, lang=\"ja\").items(MAX_TWEETS)]\n-            break\n-          except Exception as e:\n-            is_429_too_many_requests_error = str(e).find(\"429\") != -1\n-            if is_429_too_many_requests_error:\n-              LOGGER.warning(\"429 Too Many Requests. Waiting 1 minute...\")\n-              time.sleep(60)\n-            else:\n-              raise Exception(\"[line {0}] {1}\".format(sys.exc_info()[-1].tb_lineno, e))\n+        searched_tweets = search_tweets(\n+          twi_api=api, query=query, max_tweets=max_tweets)\n+        if searched_tweets == \"Error\":\n+          raise Exception(\"Failed to search tweets.\")\n \n         LOGGER.info('-> %s tweets were found.', str(len(searched_tweets)))\n \n-        no_hit = len(searched_tweets) == 0\n-        if no_hit:\n+        # If the search didn't match any tweets, then tweeting that.\n+        if len(searched_tweets) == 0:\n           my_reply = \"@{0} Your search - {1} - did not match any tweets. Try different keywords.\".format(tweet_username, query)\n \n           res = reply(twi_api=api, in_reply_to_status_id=tweet_id, status=my_reply)\n           if res == \"Error\":\n             raise Exception(\"Failed to tweet.\")\n+          return\n \n-        else:\n-          stop_words = ['てる', 'いる', 'なる', 'れる', 'する', 'ある',\n-                        'こと', 'これ', 'さん', 'して', 'くれる', 'やる',\n-                        'くださる', 'そう', 'せる', 'した', '思う', 'それ',\n-                        'ここ', 'ちゃん', 'くん', '', 'て', 'に', 'を',\n-                        'は', 'の', 'が', 'と', 'た', 'し', 'で', 'ない',\n-                        'も', 'な', 'い', 'か', 'ので', 'よう', '', 'RT',\n-                        '@', 'http', 'https', '.', ':', '/', '//', '://']\n+        stop_words = ['てる', 'いる', 'なる', 'れる', 'する', 'ある',\n+                      'こと', 'これ', 'さん', 'して', 'くれる', 'やる',\n+                      'くださる', 'そう', 'せる', 'した', '思う', 'それ',\n+                      'ここ', 'ちゃん', 'くん', '', 'て', 'に', 'を',\n+                      'は', 'の', 'が', 'と', 'た', 'し', 'で', 'ない',\n+                      'も', 'な', 'い', 'か', 'ので', 'よう', '', 'RT',\n+                      '@', 'http', 'https', '.', ':', '/', '//', '://']\n \n-          with MeCab() as nm:\n-            for node in nm.parse(query, as_nodes=True):\n-              word = node.surface\n-              stop_words.append(word)\n+        with MeCab() as nm:\n+          for node in nm.parse(query, as_nodes=True):\n+            word = node.surface\n+            stop_words.append(word)\n \n-          LOGGER.info(\"Doing morphological analysis using MeCab...\")\n+        LOGGER.info(\"Doing morphological analysis using MeCab...\")\n \n-          for tweet in searched_tweets:\n-            text = str(tweet.text.encode(\"utf-8\"))\n+        for tweet in searched_tweets:\n+          text = str(tweet.text.encode(\"utf-8\"))\n \n-            with MeCab() as nm:\n-              for node in nm.parse(text, as_nodes=True):\n-                word = node.surface\n+          with MeCab() as nm:\n+            for node in nm.parse(text, as_nodes=True):\n+              word = node.surface\n \n-                is_not_stop_word = word not in stop_words\n-                if is_not_stop_word:\n-                  word_type = node.feature.split(\",\")[0]\n-                  word_decoded = node.surface.decode('utf-8')\n-                  word_original_form_decoded = node.feature.split(\n-                    \",\")[6].decode('utf-8')\n-                  if word_type == \"形容詞\":\n-                    frequency[word_original_form_decoded] += 100\n-                  elif word_type == \"動詞\":\n-                    frequency[word_original_form_decoded] += 1\n-                  elif word_type in [\"名詞\", \"副詞\"]:\n-                    frequency[word_decoded] += 1\n+              is_not_stop_word = word not in stop_words\n+              if is_not_stop_word:\n+                word_type = node.feature.split(\",\")[0]\n+                word_decoded = node.surface.decode('utf-8')\n+                word_original_form_decoded = node.feature.split(\n+                  \",\")[6].decode('utf-8')\n+                if word_type == \"形容詞\":\n+                  frequency[word_original_form_decoded] += 100","path":"main.py","position":104,"original_position":104,"commit_id":"cc800cf67075258510798ca598617aefa598c1b3","original_commit_id":"cc800cf67075258510798ca598617aefa598c1b3","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"indentation is not a multiple of four","created_at":"2017-12-01T17:44:49Z","updated_at":"2017-12-01T17:44:50Z","html_url":"https://github.com/cygnan/twitter-wordcloud-bot/pull/29#discussion_r154404936","pull_request_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/comments/154404936"},"html":{"href":"https://github.com/cygnan/twitter-wordcloud-bot/pull/29#discussion_r154404936"},"pull_request":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29","id":155918792,"html_url":"https://github.com/cygnan/twitter-wordcloud-bot/pull/29","diff_url":"https://github.com/cygnan/twitter-wordcloud-bot/pull/29.diff","patch_url":"https://github.com/cygnan/twitter-wordcloud-bot/pull/29.patch","issue_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/29","number":29,"state":"open","locked":false,"title":"Refactor searching tweets function","user":{"login":"cygnan","id":25865313,"avatar_url":"https://avatars3.githubusercontent.com/u/25865313?v=4","gravatar_id":"","url":"https://api.github.com/users/cygnan","html_url":"https://github.com/cygnan","followers_url":"https://api.github.com/users/cygnan/followers","following_url":"https://api.github.com/users/cygnan/following{/other_user}","gists_url":"https://api.github.com/users/cygnan/gists{/gist_id}","starred_url":"https://api.github.com/users/cygnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygnan/subscriptions","organizations_url":"https://api.github.com/users/cygnan/orgs","repos_url":"https://api.github.com/users/cygnan/repos","events_url":"https://api.github.com/users/cygnan/events{/privacy}","received_events_url":"https://api.github.com/users/cygnan/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-01T17:44:40Z","updated_at":"2017-12-01T17:44:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6db1f85026cf8a8706caca7f79a02e2253a43e58","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29/commits","review_comments_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29/comments","review_comment_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/29/comments","statuses_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/statuses/cc800cf67075258510798ca598617aefa598c1b3","head":{"label":"cygnan:refactor-searching-tweets","ref":"refactor-searching-tweets","sha":"cc800cf67075258510798ca598617aefa598c1b3","user":{"login":"cygnan","id":25865313,"avatar_url":"https://avatars3.githubusercontent.com/u/25865313?v=4","gravatar_id":"","url":"https://api.github.com/users/cygnan","html_url":"https://github.com/cygnan","followers_url":"https://api.github.com/users/cygnan/followers","following_url":"https://api.github.com/users/cygnan/following{/other_user}","gists_url":"https://api.github.com/users/cygnan/gists{/gist_id}","starred_url":"https://api.github.com/users/cygnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygnan/subscriptions","organizations_url":"https://api.github.com/users/cygnan/orgs","repos_url":"https://api.github.com/users/cygnan/repos","events_url":"https://api.github.com/users/cygnan/events{/privacy}","received_events_url":"https://api.github.com/users/cygnan/received_events","type":"User","site_admin":false},"repo":{"id":107878403,"name":"twitter-wordcloud-bot","full_name":"cygnan/twitter-wordcloud-bot","owner":{"login":"cygnan","id":25865313,"avatar_url":"https://avatars3.githubusercontent.com/u/25865313?v=4","gravatar_id":"","url":"https://api.github.com/users/cygnan","html_url":"https://github.com/cygnan","followers_url":"https://api.github.com/users/cygnan/followers","following_url":"https://api.github.com/users/cygnan/following{/other_user}","gists_url":"https://api.github.com/users/cygnan/gists{/gist_id}","starred_url":"https://api.github.com/users/cygnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygnan/subscriptions","organizations_url":"https://api.github.com/users/cygnan/orgs","repos_url":"https://api.github.com/users/cygnan/repos","events_url":"https://api.github.com/users/cygnan/events{/privacy}","received_events_url":"https://api.github.com/users/cygnan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cygnan/twitter-wordcloud-bot","description":"A Twitter bot with Python and Heroku to generate a wordcloud from the tweets that match a search query","fork":false,"url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot","forks_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/forks","keys_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/teams","hooks_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/hooks","issue_events_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/events{/number}","events_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/events","assignees_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/assignees{/user}","branches_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/branches{/branch}","tags_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/tags","blobs_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/languages","stargazers_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/stargazers","contributors_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/contributors","subscribers_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/subscribers","subscription_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/subscription","commits_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/contents/{+path}","compare_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/merges","archive_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/downloads","issues_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues{/number}","pulls_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/labels{/name}","releases_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/releases{/id}","deployments_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/deployments","created_at":"2017-10-22T15:30:03Z","updated_at":"2017-11-25T21:16:04Z","pushed_at":"2017-12-01T17:44:41Z","git_url":"git://github.com/cygnan/twitter-wordcloud-bot.git","ssh_url":"git@github.com:cygnan/twitter-wordcloud-bot.git","clone_url":"https://github.com/cygnan/twitter-wordcloud-bot.git","svn_url":"https://github.com/cygnan/twitter-wordcloud-bot","homepage":"http://twitter.com/twiwordcloudbot","size":16350,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":7,"watchers":1,"default_branch":"master"}},"base":{"label":"cygnan:master","ref":"master","sha":"26f8a5fa6f948ad7068fd9a41bf7bc209155544e","user":{"login":"cygnan","id":25865313,"avatar_url":"https://avatars3.githubusercontent.com/u/25865313?v=4","gravatar_id":"","url":"https://api.github.com/users/cygnan","html_url":"https://github.com/cygnan","followers_url":"https://api.github.com/users/cygnan/followers","following_url":"https://api.github.com/users/cygnan/following{/other_user}","gists_url":"https://api.github.com/users/cygnan/gists{/gist_id}","starred_url":"https://api.github.com/users/cygnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygnan/subscriptions","organizations_url":"https://api.github.com/users/cygnan/orgs","repos_url":"https://api.github.com/users/cygnan/repos","events_url":"https://api.github.com/users/cygnan/events{/privacy}","received_events_url":"https://api.github.com/users/cygnan/received_events","type":"User","site_admin":false},"repo":{"id":107878403,"name":"twitter-wordcloud-bot","full_name":"cygnan/twitter-wordcloud-bot","owner":{"login":"cygnan","id":25865313,"avatar_url":"https://avatars3.githubusercontent.com/u/25865313?v=4","gravatar_id":"","url":"https://api.github.com/users/cygnan","html_url":"https://github.com/cygnan","followers_url":"https://api.github.com/users/cygnan/followers","following_url":"https://api.github.com/users/cygnan/following{/other_user}","gists_url":"https://api.github.com/users/cygnan/gists{/gist_id}","starred_url":"https://api.github.com/users/cygnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygnan/subscriptions","organizations_url":"https://api.github.com/users/cygnan/orgs","repos_url":"https://api.github.com/users/cygnan/repos","events_url":"https://api.github.com/users/cygnan/events{/privacy}","received_events_url":"https://api.github.com/users/cygnan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cygnan/twitter-wordcloud-bot","description":"A Twitter bot with Python and Heroku to generate a wordcloud from the tweets that match a search query","fork":false,"url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot","forks_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/forks","keys_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/teams","hooks_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/hooks","issue_events_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/events{/number}","events_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/events","assignees_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/assignees{/user}","branches_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/branches{/branch}","tags_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/tags","blobs_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/languages","stargazers_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/stargazers","contributors_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/contributors","subscribers_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/subscribers","subscription_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/subscription","commits_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/contents/{+path}","compare_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/merges","archive_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/downloads","issues_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues{/number}","pulls_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/labels{/name}","releases_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/releases{/id}","deployments_url":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/deployments","created_at":"2017-10-22T15:30:03Z","updated_at":"2017-11-25T21:16:04Z","pushed_at":"2017-12-01T17:44:41Z","git_url":"git://github.com/cygnan/twitter-wordcloud-bot.git","ssh_url":"git@github.com:cygnan/twitter-wordcloud-bot.git","clone_url":"https://github.com/cygnan/twitter-wordcloud-bot.git","svn_url":"https://github.com/cygnan/twitter-wordcloud-bot","homepage":"http://twitter.com/twiwordcloudbot","size":16350,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":7,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29"},"html":{"href":"https://github.com/cygnan/twitter-wordcloud-bot/pull/29"},"issue":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/29"},"comments":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/cygnan/twitter-wordcloud-bot/statuses/cc800cf67075258510798ca598617aefa598c1b3"}},"author_association":"OWNER"}}
{"actor":{"display_login":"houndci-bot"}}