{"action":"created","comment":{"url":"https://api.github.com/repos/ogify/ogify/pulls/comments/40940116","id":40940116,"diff_hunk":"@@ -0,0 +1,63 @@\n+import json\n+import bz2\n+import pymorphy2\n+import nltk\n+\n+\n+class SuperTokenizer(object):\n+\n+    #removing punctuation, prepositions, etc.\n+    PYMORPH_BAD_GRAMMEMES = ('PNCT', 'PRCL', 'CONJ', 'PREP', 'NPRO', )\n+    \n+    def __init__(self):\n+        self.morph = pymorphy2.MorphAnalyzer()\n+        self.snowball = nltk.stem.snowball.SnowballStemmer('english')\n+        self.english_stopwords = set(nltk.corpus.stopwords.words('english'))\n+        \n+    def normalize_word(self, word):\n+        lem = self.morph.parse(word)[0]\n+        if 'LATN' in lem.tag:\n+            # latin word: use snowball stemmer\n+            token = self.snowball.stem(word)\n+            if token in self.english_stopwords:\n+                token = None\n+        elif not any(((g in lem.tag) for g in SuperTokenizer.PYMORPH_BAD_GRAMMEMES)):\n+            # good russian word\n+            token = lem.normal_form\n+        else:\n+            token = None\n+        return token\n+        \n+    def tokenize_text(self, text):\n+        words = nltk.wordpunct_tokenize(text)\n+        for word in words:\n+            token = self.normalize_word(word)\n+            if token is not None:\n+                yield token\n+           \n+    def tokenize_html(self, html):\n+        text = BeautifulSoup.BeautifulSoup(html).getText(' ')\n+        return self.tokenize_text(text)\n+\n+\n+#reading jsons\n+with open('vk_posts') as f:\n+    for line in f:\n+        text = line[:(line.rindex(']')+1)]\n+    posts = json.loads(text)\n+\n+#build tokenizer\n+tokenizer = SuperTokenizer()\n+\n+#open file for writing tokens\n+with open('vk_tokens.txt', 'w') as post_output:\n+    for post_index, post in enumerate(posts):\n+        #tokenizing current post\n+        tokens = tokenizer.tokenize_text(post['text'])\n+\n+        #writing tokens frim current post to file\n+        print >> post_output, post_index, ','.join(tokens).encode('utf-8') \n+        \n+        if post_index % 1000 == 0:\n+            print '{0} post processed'.format(post_index)\n+    ","path":"data_analysis/make_tokens.py","position":63,"original_position":63,"commit_id":"5f42475eeadea42e7dbc0870b77b4a139607b1ba","original_commit_id":"5f42475eeadea42e7dbc0870b77b4a139607b1ba","user":{"login":"sergeyshilin","id":5588174,"avatar_url":"https://avatars.githubusercontent.com/u/5588174?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeyshilin","html_url":"https://github.com/sergeyshilin","followers_url":"https://api.github.com/users/sergeyshilin/followers","following_url":"https://api.github.com/users/sergeyshilin/following{/other_user}","gists_url":"https://api.github.com/users/sergeyshilin/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeyshilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeyshilin/subscriptions","organizations_url":"https://api.github.com/users/sergeyshilin/orgs","repos_url":"https://api.github.com/users/sergeyshilin/repos","events_url":"https://api.github.com/users/sergeyshilin/events{/privacy}","received_events_url":"https://api.github.com/users/sergeyshilin/received_events","type":"User","site_admin":false},"body":"Он где лежит-то? как его увидеть?","created_at":"2015-10-01T17:16:41Z","updated_at":"2015-10-01T17:16:41Z","html_url":"https://github.com/ogify/ogify/pull/30#discussion_r40940116","pull_request_url":"https://api.github.com/repos/ogify/ogify/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/ogify/ogify/pulls/comments/40940116"},"html":{"href":"https://github.com/ogify/ogify/pull/30#discussion_r40940116"},"pull_request":{"href":"https://api.github.com/repos/ogify/ogify/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/ogify/ogify/pulls/30","id":46531617,"html_url":"https://github.com/ogify/ogify/pull/30","diff_url":"https://github.com/ogify/ogify/pull/30.diff","patch_url":"https://github.com/ogify/ogify/pull/30.patch","issue_url":"https://api.github.com/repos/ogify/ogify/issues/30","number":30,"state":"open","locked":false,"title":"Adding class for tokenizing","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":"","created_at":"2015-10-01T14:36:48Z","updated_at":"2015-10-01T17:16:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"22a482ae8634b44411b418bafb2d735e64317619","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ogify/ogify/pulls/30/commits","review_comments_url":"https://api.github.com/repos/ogify/ogify/pulls/30/comments","review_comment_url":"https://api.github.com/repos/ogify/ogify/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ogify/ogify/issues/30/comments","statuses_url":"https://api.github.com/repos/ogify/ogify/statuses/5f42475eeadea42e7dbc0870b77b4a139607b1ba","head":{"label":"yanina-anastasia:build_0","ref":"build_0","sha":"5f42475eeadea42e7dbc0870b77b4a139607b1ba","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-01T14:11:09Z","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":30992,"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":"14db01497ce0f3367aa38e2c25680c1944e343f5","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-01T16:45:33Z","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":30992,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":7,"forks":4,"open_issues":7,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ogify/ogify/pulls/30"},"html":{"href":"https://github.com/ogify/ogify/pull/30"},"issue":{"href":"https://api.github.com/repos/ogify/ogify/issues/30"},"comments":{"href":"https://api.github.com/repos/ogify/ogify/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/ogify/ogify/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/ogify/ogify/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ogify/ogify/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/ogify/ogify/statuses/5f42475eeadea42e7dbc0870b77b4a139607b1ba"}}}}