{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/contrib/pulls/comments/73090390","id":73090390,"diff_hunk":"@@ -0,0 +1,125 @@\n+import os\n+import simplejson\n+import logging\n+from logging.handlers import RotatingFileHandler\n+\n+import numpy as np\n+from flask import Flask, request\n+from sklearn.feature_extraction import FeatureHasher\n+from sklearn.externals import joblib\n+from sklearn.linear_model import SGDClassifier\n+from nltk.tokenize import RegexpTokenizer\n+from nltk.stem.porter import PorterStemmer\n+app = Flask(__name__)\n+\n+#Parameters\n+team_fn= \"./models/trained_teams_model.pkl\"\n+component_fn= \"./models/trained_components_model.pkl\"\n+logFile = \"/tmp/issue-labeler.log\"\n+logSize = 1024*1024*100\n+numFeatures = 262144\n+myLoss = 'hinge'\n+myAlpha = .1\n+myPenalty = 'l2'\n+myHasher = FeatureHasher(input_type=\"string\", n_features= numFeatures, non_negative=True)\n+myStemmer = PorterStemmer()\n+tokenizer = RegexpTokenizer(r'\\w+')\n+\n+\n+try:\n+  stop_words = []\n+  if not stopwords:\n+    stop_fn = \"./data/stopwords.txt\"\n+  with open(stop_fn, 'r') as f:\n+    stopwords = [word.strip() for word in f]\n+except:\n+  #don't remove any stopwords\n+  stopwords = []\n+\n+@app.errorhandler(500)\n+def internal_error(exception):\n+  app.logger.error(exception)\n+  return \"Internal Server Error-> Check the Logs\"\n+\n+@app.route(\"/\", methods = [\"POST\"])\n+def get_labels():\n+    title = request.form.get('title', \"\")\n+    body = request.form.get('body', \"\")\n+    tokens = tokenize_stem_stop(\" \".join([title, body]))\n+    team_mod = joblib.load(team_fn)\n+    comp_mod = joblib.load(component_fn)\n+    vec = myHasher.transform([tokens])\n+    tlabel = team_mod.predict(vec)[0]\n+    clabel = comp_mod.predict(vec)[0]\n+    return \",\".join([tlabel, clabel])\n+\n+\n+def tokenize_stem_stop(inputString):\n+    curTitleBody = tokenizer.tokenize(inputString.decode('utf-8').lower())\n+    return map(myStemmer.stem, filter(lambda x: x not in stopwords, curTitleBody))","path":"mungegithub/issue-labeler/simple_app.py","position":59,"original_position":59,"commit_id":"fe8426bd0ecfe3d6fe555b048a9f52c18b010077","original_commit_id":"fe8426bd0ecfe3d6fe555b048a9f52c18b010077","user":{"login":"apelisse","id":1929644,"avatar_url":"https://avatars.githubusercontent.com/u/1929644?v=3","gravatar_id":"","url":"https://api.github.com/users/apelisse","html_url":"https://github.com/apelisse","followers_url":"https://api.github.com/users/apelisse/followers","following_url":"https://api.github.com/users/apelisse/following{/other_user}","gists_url":"https://api.github.com/users/apelisse/gists{/gist_id}","starred_url":"https://api.github.com/users/apelisse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apelisse/subscriptions","organizations_url":"https://api.github.com/users/apelisse/orgs","repos_url":"https://api.github.com/users/apelisse/repos","events_url":"https://api.github.com/users/apelisse/events{/privacy}","received_events_url":"https://api.github.com/users/apelisse/received_events","type":"User","site_admin":false},"body":"how many stopwords do you have? Maybe you should use a `set` instead","created_at":"2016-08-02T03:43:44Z","updated_at":"2016-08-02T03:43:44Z","html_url":"https://github.com/kubernetes/contrib/pull/1437#discussion_r73090390","pull_request_url":"https://api.github.com/repos/kubernetes/contrib/pulls/1437","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/comments/73090390"},"html":{"href":"https://github.com/kubernetes/contrib/pull/1437#discussion_r73090390"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1437"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/contrib/pulls/1437","id":78774190,"html_url":"https://github.com/kubernetes/contrib/pull/1437","diff_url":"https://github.com/kubernetes/contrib/pull/1437.diff","patch_url":"https://github.com/kubernetes/contrib/pull/1437.patch","issue_url":"https://api.github.com/repos/kubernetes/contrib/issues/1437","number":1437,"state":"open","locked":false,"title":"Add automatic issue labeler","user":{"login":"grodrigues3","id":4854198,"avatar_url":"https://avatars.githubusercontent.com/u/4854198?v=3","gravatar_id":"","url":"https://api.github.com/users/grodrigues3","html_url":"https://github.com/grodrigues3","followers_url":"https://api.github.com/users/grodrigues3/followers","following_url":"https://api.github.com/users/grodrigues3/following{/other_user}","gists_url":"https://api.github.com/users/grodrigues3/gists{/gist_id}","starred_url":"https://api.github.com/users/grodrigues3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grodrigues3/subscriptions","organizations_url":"https://api.github.com/users/grodrigues3/orgs","repos_url":"https://api.github.com/users/grodrigues3/repos","events_url":"https://api.github.com/users/grodrigues3/events{/privacy}","received_events_url":"https://api.github.com/users/grodrigues3/received_events","type":"User","site_admin":false},"body":"Resolves #1432\r\n\r\nThe simple_app.py file loads 2 pretrained machine learning models that have learned patterns on existing issues.  For new issues, the munger file will send a request to the webapp with the new issue's title and body, and the webapp will respond with the team and component labels that it thinks are appropriate. ","created_at":"2016-07-26T00:26:42Z","updated_at":"2016-08-02T03:43:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f815d2d2cf33c295a43732b32b823608f1f0c5a9","assignee":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"assignees":[{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},{"login":"apelisse","id":1929644,"avatar_url":"https://avatars.githubusercontent.com/u/1929644?v=3","gravatar_id":"","url":"https://api.github.com/users/apelisse","html_url":"https://github.com/apelisse","followers_url":"https://api.github.com/users/apelisse/followers","following_url":"https://api.github.com/users/apelisse/following{/other_user}","gists_url":"https://api.github.com/users/apelisse/gists{/gist_id}","starred_url":"https://api.github.com/users/apelisse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apelisse/subscriptions","organizations_url":"https://api.github.com/users/apelisse/orgs","repos_url":"https://api.github.com/users/apelisse/repos","events_url":"https://api.github.com/users/apelisse/events{/privacy}","received_events_url":"https://api.github.com/users/apelisse/received_events","type":"User","site_admin":false},{"login":"grodrigues3","id":4854198,"avatar_url":"https://avatars.githubusercontent.com/u/4854198?v=3","gravatar_id":"","url":"https://api.github.com/users/grodrigues3","html_url":"https://github.com/grodrigues3","followers_url":"https://api.github.com/users/grodrigues3/followers","following_url":"https://api.github.com/users/grodrigues3/following{/other_user}","gists_url":"https://api.github.com/users/grodrigues3/gists{/gist_id}","starred_url":"https://api.github.com/users/grodrigues3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grodrigues3/subscriptions","organizations_url":"https://api.github.com/users/grodrigues3/orgs","repos_url":"https://api.github.com/users/grodrigues3/repos","events_url":"https://api.github.com/users/grodrigues3/events{/privacy}","received_events_url":"https://api.github.com/users/grodrigues3/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/contrib/pulls/1437/commits","review_comments_url":"https://api.github.com/repos/kubernetes/contrib/pulls/1437/comments","review_comment_url":"https://api.github.com/repos/kubernetes/contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/contrib/issues/1437/comments","statuses_url":"https://api.github.com/repos/kubernetes/contrib/statuses/fe8426bd0ecfe3d6fe555b048a9f52c18b010077","head":{"label":"grodrigues3:add-automatic-issue-labeler","ref":"add-automatic-issue-labeler","sha":"fe8426bd0ecfe3d6fe555b048a9f52c18b010077","user":{"login":"grodrigues3","id":4854198,"avatar_url":"https://avatars.githubusercontent.com/u/4854198?v=3","gravatar_id":"","url":"https://api.github.com/users/grodrigues3","html_url":"https://github.com/grodrigues3","followers_url":"https://api.github.com/users/grodrigues3/followers","following_url":"https://api.github.com/users/grodrigues3/following{/other_user}","gists_url":"https://api.github.com/users/grodrigues3/gists{/gist_id}","starred_url":"https://api.github.com/users/grodrigues3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grodrigues3/subscriptions","organizations_url":"https://api.github.com/users/grodrigues3/orgs","repos_url":"https://api.github.com/users/grodrigues3/repos","events_url":"https://api.github.com/users/grodrigues3/events{/privacy}","received_events_url":"https://api.github.com/users/grodrigues3/received_events","type":"User","site_admin":false},"repo":{"id":64148560,"name":"contrib","full_name":"grodrigues3/contrib","owner":{"login":"grodrigues3","id":4854198,"avatar_url":"https://avatars.githubusercontent.com/u/4854198?v=3","gravatar_id":"","url":"https://api.github.com/users/grodrigues3","html_url":"https://github.com/grodrigues3","followers_url":"https://api.github.com/users/grodrigues3/followers","following_url":"https://api.github.com/users/grodrigues3/following{/other_user}","gists_url":"https://api.github.com/users/grodrigues3/gists{/gist_id}","starred_url":"https://api.github.com/users/grodrigues3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grodrigues3/subscriptions","organizations_url":"https://api.github.com/users/grodrigues3/orgs","repos_url":"https://api.github.com/users/grodrigues3/repos","events_url":"https://api.github.com/users/grodrigues3/events{/privacy}","received_events_url":"https://api.github.com/users/grodrigues3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grodrigues3/contrib","description":"This is a place for various components in the Kubernetes ecosystem that aren't part of the Kubernetes core. Consider creating a new repo instead.","fork":true,"url":"https://api.github.com/repos/grodrigues3/contrib","forks_url":"https://api.github.com/repos/grodrigues3/contrib/forks","keys_url":"https://api.github.com/repos/grodrigues3/contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grodrigues3/contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grodrigues3/contrib/teams","hooks_url":"https://api.github.com/repos/grodrigues3/contrib/hooks","issue_events_url":"https://api.github.com/repos/grodrigues3/contrib/issues/events{/number}","events_url":"https://api.github.com/repos/grodrigues3/contrib/events","assignees_url":"https://api.github.com/repos/grodrigues3/contrib/assignees{/user}","branches_url":"https://api.github.com/repos/grodrigues3/contrib/branches{/branch}","tags_url":"https://api.github.com/repos/grodrigues3/contrib/tags","blobs_url":"https://api.github.com/repos/grodrigues3/contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grodrigues3/contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grodrigues3/contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/grodrigues3/contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grodrigues3/contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/grodrigues3/contrib/languages","stargazers_url":"https://api.github.com/repos/grodrigues3/contrib/stargazers","contributors_url":"https://api.github.com/repos/grodrigues3/contrib/contributors","subscribers_url":"https://api.github.com/repos/grodrigues3/contrib/subscribers","subscription_url":"https://api.github.com/repos/grodrigues3/contrib/subscription","commits_url":"https://api.github.com/repos/grodrigues3/contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/grodrigues3/contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/grodrigues3/contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/grodrigues3/contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/grodrigues3/contrib/contents/{+path}","compare_url":"https://api.github.com/repos/grodrigues3/contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grodrigues3/contrib/merges","archive_url":"https://api.github.com/repos/grodrigues3/contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grodrigues3/contrib/downloads","issues_url":"https://api.github.com/repos/grodrigues3/contrib/issues{/number}","pulls_url":"https://api.github.com/repos/grodrigues3/contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/grodrigues3/contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/grodrigues3/contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grodrigues3/contrib/labels{/name}","releases_url":"https://api.github.com/repos/grodrigues3/contrib/releases{/id}","deployments_url":"https://api.github.com/repos/grodrigues3/contrib/deployments","created_at":"2016-07-25T15:59:50Z","updated_at":"2016-07-25T15:59:55Z","pushed_at":"2016-08-02T00:59:24Z","git_url":"git://github.com/grodrigues3/contrib.git","ssh_url":"git@github.com:grodrigues3/contrib.git","clone_url":"https://github.com/grodrigues3/contrib.git","svn_url":"https://github.com/grodrigues3/contrib","homepage":"","size":32186,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"b8b55aa9d55936327e78357f8ca4b52a4258a6ff","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":40686014,"name":"contrib","full_name":"kubernetes/contrib","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/contrib","description":"This is a place for various components in the Kubernetes ecosystem that aren't part of the Kubernetes core. Consider creating a new repo instead.","fork":false,"url":"https://api.github.com/repos/kubernetes/contrib","forks_url":"https://api.github.com/repos/kubernetes/contrib/forks","keys_url":"https://api.github.com/repos/kubernetes/contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/contrib/teams","hooks_url":"https://api.github.com/repos/kubernetes/contrib/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/contrib/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/contrib/events","assignees_url":"https://api.github.com/repos/kubernetes/contrib/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/contrib/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/contrib/tags","blobs_url":"https://api.github.com/repos/kubernetes/contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/contrib/languages","stargazers_url":"https://api.github.com/repos/kubernetes/contrib/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/contrib/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/contrib/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/contrib/subscription","commits_url":"https://api.github.com/repos/kubernetes/contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/contrib/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/contrib/merges","archive_url":"https://api.github.com/repos/kubernetes/contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/contrib/downloads","issues_url":"https://api.github.com/repos/kubernetes/contrib/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/contrib/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/contrib/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/contrib/deployments","created_at":"2015-08-13T23:18:26Z","updated_at":"2016-08-02T03:01:38Z","pushed_at":"2016-08-02T00:59:25Z","git_url":"git://github.com/kubernetes/contrib.git","ssh_url":"git@github.com:kubernetes/contrib.git","clone_url":"https://github.com/kubernetes/contrib.git","svn_url":"https://github.com/kubernetes/contrib","homepage":"","size":71024,"stargazers_count":408,"watchers_count":408,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":394,"mirror_url":null,"open_issues_count":275,"forks":394,"open_issues":275,"watchers":408,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1437"},"html":{"href":"https://github.com/kubernetes/contrib/pull/1437"},"issue":{"href":"https://api.github.com/repos/kubernetes/contrib/issues/1437"},"comments":{"href":"https://api.github.com/repos/kubernetes/contrib/issues/1437/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1437/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1437/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/contrib/statuses/fe8426bd0ecfe3d6fe555b048a9f52c18b010077"}}}}
{"actor":{"display_login":"apelisse"}}