{"action":"created","comment":{"url":"https://api.github.com/repos/ogify/ogify/pulls/comments/41533935","id":41533935,"diff_hunk":"@@ -0,0 +1,78 @@\n+import json\n+import glob\n+import collections\n+import os\n+import nltk.tokenize\n+import sys\n+\n+MAX_DOCS = 100000\n+\n+\n+def get_word_index(w, word_index, vocab_words):\n+    global n_words\n+    if w not in word_index:\n+        word_index[w] = n_words\n+        vocab_words[n_words] = w\n+        n_words += 1\n+    return word_index[w]\n+        \n+def read_posts(token_path):\n+\tposts = []  \n+    with open(token_path, 'r') as post_output:\n+        for line in post_output:\n+            if len(line.split(' ')) >= 2:\n+                posts.append(line.split(' ')[1])\n+\treturn posts\n+\t\n+def build_docwords(docwords_tail_path, docwords_head_path, posts):\n+\tn_words = 0\n+\tn_entries = 0\n+\tvocab_words = {}\n+\twith open(docwords_tail_path, 'w') as f_docwords_tail:\n+\t\tfor n_doc, post in enumerate(posts):    \n+\n+\t\t\tif n_doc % 1000 == 0:\n+\t\t\t\tprint u'%d post processed' % (n_doc)\n+\n+\t\t\tbag_of_words = collections.Counter()\n+\n+\t\t\tfor word in post.split(',')[:-1]:\n+\t\t\t\t#not necessary when preprocessing was done\n+\t\t\t\t#word = word.lower().replace(u'�', u'�')\n+\t\t\t\tif word != '':\n+\t\t\t\t\tword_idx = get_word_index(word, word_index, vocab_words)\n+\t\t\t\t\tbag_of_words[word_idx] += 1\n+\n+\t\t\tfor word_idx, count in sorted(bag_of_words.iteritems(), key=lambda r: r[0]):\n+\t\t\t\tprint >>f_docwords_tail, n_doc+1, word_idx+1, count\n+\t\t\t\tn_entries += 1\n+\n+\t\t\tif n_doc >= MAX_DOCS:\n+\t\t\t\tbreak\n+\n+\twith open(docwords_head_path, 'w') as f:\n+\t\tprint >>f, n_doc, n_words, n_entries\n+\t\t\n+\treturn vocab_words\n+\t\t\n+def build_vocab(vocab_path, vocab_words):\n+\twith open(vocab_path, 'w') as f:\n+\t\tfor word_idx in xrange(n_words):\n+\t\t\tprint >>f, vocab_words[word_idx]\n+\t\n+\t\n+if __name__ == \"__main__\":\n+    token_path = sys.argv[1] #input path \n+    docwords_tail_path = sys.argv[2]     \n+    docwords_head_path = sys.argv[3] \n+    vocab_path = sys.argv[4]\n+\t\n+\tword_index = {}\n+\tn_words = 0\n+\tn_entries = 0\n+\tvocab_words = {}\n+\n+    posts = read_posts(token_path)\n+\n+\tvocab_words = build_docwords(docwords_tail_path, docwords_head_path, posts)","path":"data_analysis/build_docwords_vocab.py","position":77,"original_position":77,"commit_id":"a3fcb644d5efc6f60707d0573c86af35757b7dee","original_commit_id":"a3fcb644d5efc6f60707d0573c86af35757b7dee","user":{"login":"melges-morgen","id":1835443,"avatar_url":"https://avatars.githubusercontent.com/u/1835443?v=3","gravatar_id":"","url":"https://api.github.com/users/melges-morgen","html_url":"https://github.com/melges-morgen","followers_url":"https://api.github.com/users/melges-morgen/followers","following_url":"https://api.github.com/users/melges-morgen/following{/other_user}","gists_url":"https://api.github.com/users/melges-morgen/gists{/gist_id}","starred_url":"https://api.github.com/users/melges-morgen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melges-morgen/subscriptions","organizations_url":"https://api.github.com/users/melges-morgen/orgs","repos_url":"https://api.github.com/users/melges-morgen/repos","events_url":"https://api.github.com/users/melges-morgen/events{/privacy}","received_events_url":"https://api.github.com/users/melges-morgen/received_events","type":"User","site_admin":false},"body":"Отступы правильны?","created_at":"2015-10-08T16:14:00Z","updated_at":"2015-10-08T16:14:00Z","html_url":"https://github.com/ogify/ogify/pull/41#discussion_r41533935","pull_request_url":"https://api.github.com/repos/ogify/ogify/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/ogify/ogify/pulls/comments/41533935"},"html":{"href":"https://github.com/ogify/ogify/pull/41#discussion_r41533935"},"pull_request":{"href":"https://api.github.com/repos/ogify/ogify/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/ogify/ogify/pulls/41","id":47142028,"html_url":"https://github.com/ogify/ogify/pull/41","diff_url":"https://github.com/ogify/ogify/pull/41.diff","patch_url":"https://github.com/ogify/ogify/pull/41.patch","issue_url":"https://api.github.com/repos/ogify/ogify/issues/41","number":41,"state":"open","locked":false,"title":"DCS-234","user":{"login":"yanina-anastasia","id":5503741,"avatar_url":"https://avatars.githubusercontent.com/u/5503741?v=3","gravatar_id":"","url":"https://api.github.com/users/yanina-anastasia","html_url":"https://github.com/yanina-anastasia","followers_url":"https://api.github.com/users/yanina-anastasia/followers","following_url":"https://api.github.com/users/yanina-anastasia/following{/other_user}","gists_url":"https://api.github.com/users/yanina-anastasia/gists{/gist_id}","starred_url":"https://api.github.com/users/yanina-anastasia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanina-anastasia/subscriptions","organizations_url":"https://api.github.com/users/yanina-anastasia/orgs","repos_url":"https://api.github.com/users/yanina-anastasia/repos","events_url":"https://api.github.com/users/yanina-anastasia/events{/privacy}","received_events_url":"https://api.github.com/users/yanina-anastasia/received_events","type":"User","site_admin":false},"body":"topic model building and training","created_at":"2015-10-08T11:41:47Z","updated_at":"2015-10-08T16:14:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"67c46efb0dce98acd59de78d86e0b63162b2c972","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ogify/ogify/pulls/41/commits","review_comments_url":"https://api.github.com/repos/ogify/ogify/pulls/41/comments","review_comment_url":"https://api.github.com/repos/ogify/ogify/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ogify/ogify/issues/41/comments","statuses_url":"https://api.github.com/repos/ogify/ogify/statuses/a3fcb644d5efc6f60707d0573c86af35757b7dee","head":{"label":"yanina-anastasia:build_0","ref":"build_0","sha":"a3fcb644d5efc6f60707d0573c86af35757b7dee","user":{"login":"yanina-anastasia","id":5503741,"avatar_url":"https://avatars.githubusercontent.com/u/5503741?v=3","gravatar_id":"","url":"https://api.github.com/users/yanina-anastasia","html_url":"https://github.com/yanina-anastasia","followers_url":"https://api.github.com/users/yanina-anastasia/followers","following_url":"https://api.github.com/users/yanina-anastasia/following{/other_user}","gists_url":"https://api.github.com/users/yanina-anastasia/gists{/gist_id}","starred_url":"https://api.github.com/users/yanina-anastasia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanina-anastasia/subscriptions","organizations_url":"https://api.github.com/users/yanina-anastasia/orgs","repos_url":"https://api.github.com/users/yanina-anastasia/repos","events_url":"https://api.github.com/users/yanina-anastasia/events{/privacy}","received_events_url":"https://api.github.com/users/yanina-anastasia/received_events","type":"User","site_admin":false},"repo":{"id":43171959,"name":"ogify","full_name":"yanina-anastasia/ogify","owner":{"login":"yanina-anastasia","id":5503741,"avatar_url":"https://avatars.githubusercontent.com/u/5503741?v=3","gravatar_id":"","url":"https://api.github.com/users/yanina-anastasia","html_url":"https://github.com/yanina-anastasia","followers_url":"https://api.github.com/users/yanina-anastasia/followers","following_url":"https://api.github.com/users/yanina-anastasia/following{/other_user}","gists_url":"https://api.github.com/users/yanina-anastasia/gists{/gist_id}","starred_url":"https://api.github.com/users/yanina-anastasia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanina-anastasia/subscriptions","organizations_url":"https://api.github.com/users/yanina-anastasia/orgs","repos_url":"https://api.github.com/users/yanina-anastasia/repos","events_url":"https://api.github.com/users/yanina-anastasia/events{/privacy}","received_events_url":"https://api.github.com/users/yanina-anastasia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yanina-anastasia/ogify","description":"Eat With Benefit","fork":true,"url":"https://api.github.com/repos/yanina-anastasia/ogify","forks_url":"https://api.github.com/repos/yanina-anastasia/ogify/forks","keys_url":"https://api.github.com/repos/yanina-anastasia/ogify/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yanina-anastasia/ogify/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yanina-anastasia/ogify/teams","hooks_url":"https://api.github.com/repos/yanina-anastasia/ogify/hooks","issue_events_url":"https://api.github.com/repos/yanina-anastasia/ogify/issues/events{/number}","events_url":"https://api.github.com/repos/yanina-anastasia/ogify/events","assignees_url":"https://api.github.com/repos/yanina-anastasia/ogify/assignees{/user}","branches_url":"https://api.github.com/repos/yanina-anastasia/ogify/branches{/branch}","tags_url":"https://api.github.com/repos/yanina-anastasia/ogify/tags","blobs_url":"https://api.github.com/repos/yanina-anastasia/ogify/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yanina-anastasia/ogify/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yanina-anastasia/ogify/git/refs{/sha}","trees_url":"https://api.github.com/repos/yanina-anastasia/ogify/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yanina-anastasia/ogify/statuses/{sha}","languages_url":"https://api.github.com/repos/yanina-anastasia/ogify/languages","stargazers_url":"https://api.github.com/repos/yanina-anastasia/ogify/stargazers","contributors_url":"https://api.github.com/repos/yanina-anastasia/ogify/contributors","subscribers_url":"https://api.github.com/repos/yanina-anastasia/ogify/subscribers","subscription_url":"https://api.github.com/repos/yanina-anastasia/ogify/subscription","commits_url":"https://api.github.com/repos/yanina-anastasia/ogify/commits{/sha}","git_commits_url":"https://api.github.com/repos/yanina-anastasia/ogify/git/commits{/sha}","comments_url":"https://api.github.com/repos/yanina-anastasia/ogify/comments{/number}","issue_comment_url":"https://api.github.com/repos/yanina-anastasia/ogify/issues/comments{/number}","contents_url":"https://api.github.com/repos/yanina-anastasia/ogify/contents/{+path}","compare_url":"https://api.github.com/repos/yanina-anastasia/ogify/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yanina-anastasia/ogify/merges","archive_url":"https://api.github.com/repos/yanina-anastasia/ogify/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yanina-anastasia/ogify/downloads","issues_url":"https://api.github.com/repos/yanina-anastasia/ogify/issues{/number}","pulls_url":"https://api.github.com/repos/yanina-anastasia/ogify/pulls{/number}","milestones_url":"https://api.github.com/repos/yanina-anastasia/ogify/milestones{/number}","notifications_url":"https://api.github.com/repos/yanina-anastasia/ogify/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yanina-anastasia/ogify/labels{/name}","releases_url":"https://api.github.com/repos/yanina-anastasia/ogify/releases{/id}","created_at":"2015-09-25T19:44:35Z","updated_at":"2015-09-25T19:44:38Z","pushed_at":"2015-10-08T11:39:34Z","git_url":"git://github.com/yanina-anastasia/ogify.git","ssh_url":"git@github.com:yanina-anastasia/ogify.git","clone_url":"https://github.com/yanina-anastasia/ogify.git","svn_url":"https://github.com/yanina-anastasia/ogify","homepage":null,"size":30163,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"ogify:build_0","ref":"build_0","sha":"99c1acb2d7e9138cfe0145b54e1500722464e64a","user":{"login":"ogify","id":14138153,"avatar_url":"https://avatars.githubusercontent.com/u/14138153?v=3","gravatar_id":"","url":"https://api.github.com/users/ogify","html_url":"https://github.com/ogify","followers_url":"https://api.github.com/users/ogify/followers","following_url":"https://api.github.com/users/ogify/following{/other_user}","gists_url":"https://api.github.com/users/ogify/gists{/gist_id}","starred_url":"https://api.github.com/users/ogify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogify/subscriptions","organizations_url":"https://api.github.com/users/ogify/orgs","repos_url":"https://api.github.com/users/ogify/repos","events_url":"https://api.github.com/users/ogify/events{/privacy}","received_events_url":"https://api.github.com/users/ogify/received_events","type":"Organization","site_admin":false},"repo":{"id":30619500,"name":"ogify","full_name":"ogify/ogify","owner":{"login":"ogify","id":14138153,"avatar_url":"https://avatars.githubusercontent.com/u/14138153?v=3","gravatar_id":"","url":"https://api.github.com/users/ogify","html_url":"https://github.com/ogify","followers_url":"https://api.github.com/users/ogify/followers","following_url":"https://api.github.com/users/ogify/following{/other_user}","gists_url":"https://api.github.com/users/ogify/gists{/gist_id}","starred_url":"https://api.github.com/users/ogify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogify/subscriptions","organizations_url":"https://api.github.com/users/ogify/orgs","repos_url":"https://api.github.com/users/ogify/repos","events_url":"https://api.github.com/users/ogify/events{/privacy}","received_events_url":"https://api.github.com/users/ogify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ogify/ogify","description":"Eat With Benefit","fork":false,"url":"https://api.github.com/repos/ogify/ogify","forks_url":"https://api.github.com/repos/ogify/ogify/forks","keys_url":"https://api.github.com/repos/ogify/ogify/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ogify/ogify/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ogify/ogify/teams","hooks_url":"https://api.github.com/repos/ogify/ogify/hooks","issue_events_url":"https://api.github.com/repos/ogify/ogify/issues/events{/number}","events_url":"https://api.github.com/repos/ogify/ogify/events","assignees_url":"https://api.github.com/repos/ogify/ogify/assignees{/user}","branches_url":"https://api.github.com/repos/ogify/ogify/branches{/branch}","tags_url":"https://api.github.com/repos/ogify/ogify/tags","blobs_url":"https://api.github.com/repos/ogify/ogify/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ogify/ogify/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ogify/ogify/git/refs{/sha}","trees_url":"https://api.github.com/repos/ogify/ogify/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ogify/ogify/statuses/{sha}","languages_url":"https://api.github.com/repos/ogify/ogify/languages","stargazers_url":"https://api.github.com/repos/ogify/ogify/stargazers","contributors_url":"https://api.github.com/repos/ogify/ogify/contributors","subscribers_url":"https://api.github.com/repos/ogify/ogify/subscribers","subscription_url":"https://api.github.com/repos/ogify/ogify/subscription","commits_url":"https://api.github.com/repos/ogify/ogify/commits{/sha}","git_commits_url":"https://api.github.com/repos/ogify/ogify/git/commits{/sha}","comments_url":"https://api.github.com/repos/ogify/ogify/comments{/number}","issue_comment_url":"https://api.github.com/repos/ogify/ogify/issues/comments{/number}","contents_url":"https://api.github.com/repos/ogify/ogify/contents/{+path}","compare_url":"https://api.github.com/repos/ogify/ogify/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ogify/ogify/merges","archive_url":"https://api.github.com/repos/ogify/ogify/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ogify/ogify/downloads","issues_url":"https://api.github.com/repos/ogify/ogify/issues{/number}","pulls_url":"https://api.github.com/repos/ogify/ogify/pulls{/number}","milestones_url":"https://api.github.com/repos/ogify/ogify/milestones{/number}","notifications_url":"https://api.github.com/repos/ogify/ogify/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ogify/ogify/labels{/name}","releases_url":"https://api.github.com/repos/ogify/ogify/releases{/id}","created_at":"2015-02-10T23:07:28Z","updated_at":"2015-10-01T05:58:37Z","pushed_at":"2015-10-08T11:55:57Z","git_url":"git://github.com/ogify/ogify.git","ssh_url":"git@github.com:ogify/ogify.git","clone_url":"https://github.com/ogify/ogify.git","svn_url":"https://github.com/ogify/ogify","homepage":null,"size":31173,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":7,"forks":6,"open_issues":7,"watchers":1,"default_branch":"build_0"}},"_links":{"self":{"href":"https://api.github.com/repos/ogify/ogify/pulls/41"},"html":{"href":"https://github.com/ogify/ogify/pull/41"},"issue":{"href":"https://api.github.com/repos/ogify/ogify/issues/41"},"comments":{"href":"https://api.github.com/repos/ogify/ogify/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/ogify/ogify/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/ogify/ogify/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ogify/ogify/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/ogify/ogify/statuses/a3fcb644d5efc6f60707d0573c86af35757b7dee"}}}}