{"action":"created","comment":{"url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/comments/34298519","id":34298519,"diff_hunk":"@@ -4,89 +4,74 @@\n from pkg_resources import resource_filename\n \n \n+CATEGORIES = [unicodedata.category(chr(i)) for i in range(0x110000)]\n DATA_PATH = pathlib.Path(resource_filename('wordfreq', 'data'))\n \n \n+def func_to_regex(func):\n+    \"\"\"\n+    Given a function that returns True or False for a numerical codepoint,\n+    return a regex character class accepting the characters resulting in True.\n+    Ranges separated only by unassigned characters are merged for efficiency.\n+    \"\"\"\n+    # A list of [start, end (accepted), end (accepted or unassigned)] lists\n+    ranges = []\n+\n+    for i, cat in enumerate(CATEGORIES):\n+        if func(i):\n+            # If the last range can be extended, do so; else start a new one\n+            if ranges and ranges[-1][2] == i - 1:\n+                ranges[-1][1] = i\n+                ranges[-1][2] = i\n+            else:\n+                ranges.append([i, i, i])\n+        elif cat == 'Cn':\n+            # If the last range can be extended, do so\n+            if ranges and ranges[-1][2] == i - 1:\n+                ranges[-1][2] = i\n+\n+    return '[%s]' % ''.join(chr(r[0]) + '-' + chr(r[1]) for r in ranges)\n+\n+\n def cache_regex_from_func(filename, func):\n     \"\"\"\n     Generates a regex from a function that accepts a single unicode character,\n     and caches it in the data path at filename.\n     \"\"\"\n-    with (DATA_PATH / filename).open(mode='w') as file:\n-        file.write(func_to_regex(func))\n+    with (DATA_PATH / filename).open(mode='w') as f:\n+        f.write(func_to_regex(func))","path":"scripts/gen_regex.py","position":41,"original_position":41,"commit_id":"32b4033d6399f10e10dd3f1c9194847a7f01f302","original_commit_id":"32b4033d6399f10e10dd3f1c9194847a7f01f302","user":{"login":"alin-luminoso","id":4227833,"avatar_url":"https://avatars.githubusercontent.com/u/4227833?v=3","gravatar_id":"","url":"https://api.github.com/users/alin-luminoso","html_url":"https://github.com/alin-luminoso","followers_url":"https://api.github.com/users/alin-luminoso/followers","following_url":"https://api.github.com/users/alin-luminoso/following{/other_user}","gists_url":"https://api.github.com/users/alin-luminoso/gists{/gist_id}","starred_url":"https://api.github.com/users/alin-luminoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alin-luminoso/subscriptions","organizations_url":"https://api.github.com/users/alin-luminoso/orgs","repos_url":"https://api.github.com/users/alin-luminoso/repos","events_url":"https://api.github.com/users/alin-luminoso/events{/privacy}","received_events_url":"https://api.github.com/users/alin-luminoso/received_events","type":"User","site_admin":false},"body":"Gosh, I don't know.  I mostly noticed (because of syntax highlighting) that `file` was shadowing a builtin.","created_at":"2015-07-09T20:16:34Z","updated_at":"2015-07-09T20:16:34Z","html_url":"https://github.com/LuminosoInsight/wordfreq/pull/16#discussion_r34298519","pull_request_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/comments/34298519"},"html":{"href":"https://github.com/LuminosoInsight/wordfreq/pull/16#discussion_r34298519"},"pull_request":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16","id":39622165,"html_url":"https://github.com/LuminosoInsight/wordfreq/pull/16","diff_url":"https://github.com/LuminosoInsight/wordfreq/pull/16.diff","patch_url":"https://github.com/LuminosoInsight/wordfreq/pull/16.patch","issue_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/16","number":16,"state":"open","locked":false,"title":"More tweaking","user":{"login":"alin-luminoso","id":4227833,"avatar_url":"https://avatars.githubusercontent.com/u/4227833?v=3","gravatar_id":"","url":"https://api.github.com/users/alin-luminoso","html_url":"https://github.com/alin-luminoso","followers_url":"https://api.github.com/users/alin-luminoso/followers","following_url":"https://api.github.com/users/alin-luminoso/following{/other_user}","gists_url":"https://api.github.com/users/alin-luminoso/gists{/gist_id}","starred_url":"https://api.github.com/users/alin-luminoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alin-luminoso/subscriptions","organizations_url":"https://api.github.com/users/alin-luminoso/orgs","repos_url":"https://api.github.com/users/alin-luminoso/repos","events_url":"https://api.github.com/users/alin-luminoso/events{/privacy}","received_events_url":"https://api.github.com/users/alin-luminoso/received_events","type":"User","site_admin":false},"body":"Mostly these are things I noticed during code review that I couldn't express easily as a review item.  There is really only one substantive change, which is the change to the `word_frequency()` cache.","created_at":"2015-07-09T20:00:42Z","updated_at":"2015-07-09T20:16:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae3265274af17a4998ca889220da70eadc27bd2b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16/commits","review_comments_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16/comments","review_comment_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/16/comments","statuses_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/statuses/32b4033d6399f10e10dd3f1c9194847a7f01f302","head":{"label":"LuminosoInsight:more-tweaking","ref":"more-tweaking","sha":"32b4033d6399f10e10dd3f1c9194847a7f01f302","user":{"login":"LuminosoInsight","id":1036291,"avatar_url":"https://avatars.githubusercontent.com/u/1036291?v=3","gravatar_id":"","url":"https://api.github.com/users/LuminosoInsight","html_url":"https://github.com/LuminosoInsight","followers_url":"https://api.github.com/users/LuminosoInsight/followers","following_url":"https://api.github.com/users/LuminosoInsight/following{/other_user}","gists_url":"https://api.github.com/users/LuminosoInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/LuminosoInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuminosoInsight/subscriptions","organizations_url":"https://api.github.com/users/LuminosoInsight/orgs","repos_url":"https://api.github.com/users/LuminosoInsight/repos","events_url":"https://api.github.com/users/LuminosoInsight/events{/privacy}","received_events_url":"https://api.github.com/users/LuminosoInsight/received_events","type":"Organization","site_admin":false},"repo":{"id":13941524,"name":"wordfreq","full_name":"LuminosoInsight/wordfreq","owner":{"login":"LuminosoInsight","id":1036291,"avatar_url":"https://avatars.githubusercontent.com/u/1036291?v=3","gravatar_id":"","url":"https://api.github.com/users/LuminosoInsight","html_url":"https://github.com/LuminosoInsight","followers_url":"https://api.github.com/users/LuminosoInsight/followers","following_url":"https://api.github.com/users/LuminosoInsight/following{/other_user}","gists_url":"https://api.github.com/users/LuminosoInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/LuminosoInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuminosoInsight/subscriptions","organizations_url":"https://api.github.com/users/LuminosoInsight/orgs","repos_url":"https://api.github.com/users/LuminosoInsight/repos","events_url":"https://api.github.com/users/LuminosoInsight/events{/privacy}","received_events_url":"https://api.github.com/users/LuminosoInsight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LuminosoInsight/wordfreq","description":"Access a database of word frequencies, in various natural languages.","fork":false,"url":"https://api.github.com/repos/LuminosoInsight/wordfreq","forks_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/forks","keys_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/teams","hooks_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/hooks","issue_events_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/events{/number}","events_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/events","assignees_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/assignees{/user}","branches_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/branches{/branch}","tags_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/tags","blobs_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/refs{/sha}","trees_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/statuses/{sha}","languages_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/languages","stargazers_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/stargazers","contributors_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/contributors","subscribers_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/subscribers","subscription_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/subscription","commits_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/commits{/sha}","git_commits_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/commits{/sha}","comments_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/comments{/number}","issue_comment_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/comments{/number}","contents_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/contents/{+path}","compare_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/merges","archive_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/downloads","issues_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues{/number}","pulls_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls{/number}","milestones_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/milestones{/number}","notifications_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/labels{/name}","releases_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/releases{/id}","created_at":"2013-10-28T23:28:12Z","updated_at":"2015-07-01T20:51:41Z","pushed_at":"2015-07-09T20:00:43Z","git_url":"git://github.com/LuminosoInsight/wordfreq.git","ssh_url":"git@github.com:LuminosoInsight/wordfreq.git","clone_url":"https://github.com/LuminosoInsight/wordfreq.git","svn_url":"https://github.com/LuminosoInsight/wordfreq","homepage":null,"size":128935,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":7,"default_branch":"master"}},"base":{"label":"LuminosoInsight:master","ref":"master","sha":"d4d7b2f72e95cc7fcd3209434b33dfafb10d2528","user":{"login":"LuminosoInsight","id":1036291,"avatar_url":"https://avatars.githubusercontent.com/u/1036291?v=3","gravatar_id":"","url":"https://api.github.com/users/LuminosoInsight","html_url":"https://github.com/LuminosoInsight","followers_url":"https://api.github.com/users/LuminosoInsight/followers","following_url":"https://api.github.com/users/LuminosoInsight/following{/other_user}","gists_url":"https://api.github.com/users/LuminosoInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/LuminosoInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuminosoInsight/subscriptions","organizations_url":"https://api.github.com/users/LuminosoInsight/orgs","repos_url":"https://api.github.com/users/LuminosoInsight/repos","events_url":"https://api.github.com/users/LuminosoInsight/events{/privacy}","received_events_url":"https://api.github.com/users/LuminosoInsight/received_events","type":"Organization","site_admin":false},"repo":{"id":13941524,"name":"wordfreq","full_name":"LuminosoInsight/wordfreq","owner":{"login":"LuminosoInsight","id":1036291,"avatar_url":"https://avatars.githubusercontent.com/u/1036291?v=3","gravatar_id":"","url":"https://api.github.com/users/LuminosoInsight","html_url":"https://github.com/LuminosoInsight","followers_url":"https://api.github.com/users/LuminosoInsight/followers","following_url":"https://api.github.com/users/LuminosoInsight/following{/other_user}","gists_url":"https://api.github.com/users/LuminosoInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/LuminosoInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuminosoInsight/subscriptions","organizations_url":"https://api.github.com/users/LuminosoInsight/orgs","repos_url":"https://api.github.com/users/LuminosoInsight/repos","events_url":"https://api.github.com/users/LuminosoInsight/events{/privacy}","received_events_url":"https://api.github.com/users/LuminosoInsight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LuminosoInsight/wordfreq","description":"Access a database of word frequencies, in various natural languages.","fork":false,"url":"https://api.github.com/repos/LuminosoInsight/wordfreq","forks_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/forks","keys_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/teams","hooks_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/hooks","issue_events_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/events{/number}","events_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/events","assignees_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/assignees{/user}","branches_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/branches{/branch}","tags_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/tags","blobs_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/refs{/sha}","trees_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/statuses/{sha}","languages_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/languages","stargazers_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/stargazers","contributors_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/contributors","subscribers_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/subscribers","subscription_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/subscription","commits_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/commits{/sha}","git_commits_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/git/commits{/sha}","comments_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/comments{/number}","issue_comment_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/comments{/number}","contents_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/contents/{+path}","compare_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/merges","archive_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/downloads","issues_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues{/number}","pulls_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls{/number}","milestones_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/milestones{/number}","notifications_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/labels{/name}","releases_url":"https://api.github.com/repos/LuminosoInsight/wordfreq/releases{/id}","created_at":"2013-10-28T23:28:12Z","updated_at":"2015-07-01T20:51:41Z","pushed_at":"2015-07-09T20:00:43Z","git_url":"git://github.com/LuminosoInsight/wordfreq.git","ssh_url":"git@github.com:LuminosoInsight/wordfreq.git","clone_url":"https://github.com/LuminosoInsight/wordfreq.git","svn_url":"https://github.com/LuminosoInsight/wordfreq","homepage":null,"size":128935,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16"},"html":{"href":"https://github.com/LuminosoInsight/wordfreq/pull/16"},"issue":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/16"},"comments":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/LuminosoInsight/wordfreq/statuses/32b4033d6399f10e10dd3f1c9194847a7f01f302"}}}}