{"action":"created","comment":{"url":"https://api.github.com/repos/wiki-ai/editquality/pulls/comments/48276545","id":48276545,"diff_hunk":"@@ -0,0 +1,174 @@\n+r\"\"\"\n+Gathers the reverted status for a set of revisions and\n+prints a TSV to stdout of the format:\n+\n+<rev_id>\\t<reverted>\\t<reason>\n+\n+Usage:\n+    extract_balanced_sample -h | --help\n+    extract_balanced_sample <dump-file> ...\n+                                    [--host=<url>]\n+                                    [--start=<date>]\n+                                    [--end=<date>]\n+                                    [--trusted-groups=<groups>]\n+                                    [--trusted-edits=<num>]\n+                                    [--revert-radius=<revs>]\n+                                    [--revert-window=<hrs>]\n+                                    [--reverted-only]\n+                                    [--verbose]\n+                                    [--rev-reverteds=<path>]\n+\n+Options:\n+    -h --help                   Prints out this documentation.\n+    <dump-file>                 Path to dump file.\n+    --host=<url>                The host URL of the MediaWiki install where an\n+                                API can be found.\n+    --start=<timestamp>         Start time.\n+    --end=<timestamp>           End time.\n+    --reverted-only             Only mark reverted edits as potentially\n+                                damaging [default: False]\n+    --revert-radius=<revs>      The maximum amount of revisions that a\n+                                reverting edit can revert [default: 15]\n+    --revert-window=<secs>      The maximum amount of time to wait for a\n+                                revision to be reverted [default: 172800]\n+    --rev-reverteds=<path>      The location to write output to.\n+                                [default: <stdout>]\n+    --trusted-groups=<groups>   User groups that should be considered trusted.\n+    --trusted-edits=<num>       Minimum number of edits to be considered\n+                                trusted.\n+    --verbose                   Prints dots and stuff to stderr\n+\"\"\"\n+import sys\n+import docopt\n+import mysqltsv\n+\n+import mwapi\n+import mwreverts\n+import mwxml\n+from mwtypes import Timestamp\n+\n+\n+class Revision(object):\n+    \"\"\"Placeholder\"\"\"\n+    def __init__(self, id):\n+        self.id = id\n+        self.status = False\n+        self.reason = []\n+\n+\n+class User(object):\n+    \"\"\"Placeholder\"\"\"\n+    def __init__(self, id, editcount=0, groups=[]):\n+        self.id = id\n+        self.editcount = editcount\n+        self.usergroups = groups\n+\n+\n+def load_user_info(user_name, session):\n+    res = session.get(action='query', list='users', ususers=user_name,\n+                       usprop='groups|editcount')\n+    user_data = res[\"query\"][\"users\"][0]\n+    if 'userid' not in user_data:\n+        return User(user_name, 0, [])\n+    user = User(user_data[\"userid\"], user_data['editcount'],\n+                user_data[\"groups\"])\n+    return user\n+\n+\n+def page_data(dump, path):\n+    for page in dump:\n+        yield page\n+\n+\n+def main(argv=None):\n+    args = docopt.docopt(__doc__, argv=argv)\n+\n+    if args['--rev-reverteds'] == \"<stdout>\":\n+        rev_reverteds = mysqltsv.Writer(sys.stdout)\n+    else:\n+        rev_reverteds = mysqltsv.Writer(open(args['--rev-reverteds'], \"w\"))\n+\n+    revert_radius = int(args['--revert-radius'])\n+    revert_window = int(args['--revert-window'])\n+\n+    if args['--host']:\n+        session = mwapi.Session(\n+            args['--host'], user_agent=\"ORES revert labeling utility\")\n+    else:\n+        session = None\n+    dumps = args['<dump-file>']\n+\n+    verbose = args['--verbose']\n+    start = args['--start']\n+    if start:\n+        start = Timestamp(start)\n+    end = args['--end']\n+    if end:\n+        end = Timestamp(end)\n+    reverted_only = args['--reverted-only']\n+    trusted_groups = args['--trusted-groups']\n+    if trusted_groups:\n+        trusted_groups = trusted_groups.split(',')\n+    min_editcount = args['--trusted-edits']\n+    if min_editcount:\n+        min_editcount = int(min_editcount)\n+\n+    run(dumps, session, start, end, revert_radius, revert_window,\n+        reverted_only, trusted_groups, min_editcount, rev_reverteds,\n+        verbose=verbose)\n+\n+\n+def run(dumps, session, start, end, revert_radius, revert_window,\n+        reverted_only, trusted_groups, min_editcount, rev_reverteds,\n+        verbose=False):\n+\n+    user_data = {}\n+    for page in mwxml.map(page_data, dumps):\n+        detector = mwreverts.Detector()","path":"editquality/utilities/extract_balanced_sample.py","position":127,"original_position":127,"commit_id":"e8d1b111552051d7f25a6669dca2fb45e16cebe3","original_commit_id":"e8d1b111552051d7f25a6669dca2fb45e16cebe3","user":{"login":"halfak","id":984301,"avatar_url":"https://avatars.githubusercontent.com/u/984301?v=3","gravatar_id":"","url":"https://api.github.com/users/halfak","html_url":"https://github.com/halfak","followers_url":"https://api.github.com/users/halfak/followers","following_url":"https://api.github.com/users/halfak/following{/other_user}","gists_url":"https://api.github.com/users/halfak/gists{/gist_id}","starred_url":"https://api.github.com/users/halfak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halfak/subscriptions","organizations_url":"https://api.github.com/users/halfak/orgs","repos_url":"https://api.github.com/users/halfak/repos","events_url":"https://api.github.com/users/halfak/events{/privacy}","received_events_url":"https://api.github.com/users/halfak/received_events","type":"User","site_admin":false},"body":"Did you test this?  It looks like it won't work.  You need to iterate through the page in the dump_processor function.  ","created_at":"2015-12-22T17:28:43Z","updated_at":"2015-12-22T17:28:43Z","html_url":"https://github.com/wiki-ai/editquality/pull/4#discussion_r48276545","pull_request_url":"https://api.github.com/repos/wiki-ai/editquality/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/wiki-ai/editquality/pulls/comments/48276545"},"html":{"href":"https://github.com/wiki-ai/editquality/pull/4#discussion_r48276545"},"pull_request":{"href":"https://api.github.com/repos/wiki-ai/editquality/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/wiki-ai/editquality/pulls/4","id":54372217,"html_url":"https://github.com/wiki-ai/editquality/pull/4","diff_url":"https://github.com/wiki-ai/editquality/pull/4.diff","patch_url":"https://github.com/wiki-ai/editquality/pull/4.patch","issue_url":"https://api.github.com/repos/wiki-ai/editquality/issues/4","number":4,"state":"open","locked":false,"title":"Add the dump reader","user":{"login":"Ladsgroup","id":5351225,"avatar_url":"https://avatars.githubusercontent.com/u/5351225?v=3","gravatar_id":"","url":"https://api.github.com/users/Ladsgroup","html_url":"https://github.com/Ladsgroup","followers_url":"https://api.github.com/users/Ladsgroup/followers","following_url":"https://api.github.com/users/Ladsgroup/following{/other_user}","gists_url":"https://api.github.com/users/Ladsgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/Ladsgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ladsgroup/subscriptions","organizations_url":"https://api.github.com/users/Ladsgroup/orgs","repos_url":"https://api.github.com/users/Ladsgroup/repos","events_url":"https://api.github.com/users/Ladsgroup/events{/privacy}","received_events_url":"https://api.github.com/users/Ladsgroup/received_events","type":"User","site_admin":false},"body":"I tested some parts but it would be good if we test it more.","created_at":"2015-12-22T14:00:28Z","updated_at":"2015-12-22T17:28:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc83b96f8a0498a7e3cd7041027c5c4b8a98efa5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wiki-ai/editquality/pulls/4/commits","review_comments_url":"https://api.github.com/repos/wiki-ai/editquality/pulls/4/comments","review_comment_url":"https://api.github.com/repos/wiki-ai/editquality/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wiki-ai/editquality/issues/4/comments","statuses_url":"https://api.github.com/repos/wiki-ai/editquality/statuses/e8d1b111552051d7f25a6669dca2fb45e16cebe3","head":{"label":"wiki-ai:dump_reader","ref":"dump_reader","sha":"e8d1b111552051d7f25a6669dca2fb45e16cebe3","user":{"login":"wiki-ai","id":12821767,"avatar_url":"https://avatars.githubusercontent.com/u/12821767?v=3","gravatar_id":"","url":"https://api.github.com/users/wiki-ai","html_url":"https://github.com/wiki-ai","followers_url":"https://api.github.com/users/wiki-ai/followers","following_url":"https://api.github.com/users/wiki-ai/following{/other_user}","gists_url":"https://api.github.com/users/wiki-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/wiki-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiki-ai/subscriptions","organizations_url":"https://api.github.com/users/wiki-ai/orgs","repos_url":"https://api.github.com/users/wiki-ai/repos","events_url":"https://api.github.com/users/wiki-ai/events{/privacy}","received_events_url":"https://api.github.com/users/wiki-ai/received_events","type":"Organization","site_admin":false},"repo":{"id":42016242,"name":"editquality","full_name":"wiki-ai/editquality","owner":{"login":"wiki-ai","id":12821767,"avatar_url":"https://avatars.githubusercontent.com/u/12821767?v=3","gravatar_id":"","url":"https://api.github.com/users/wiki-ai","html_url":"https://github.com/wiki-ai","followers_url":"https://api.github.com/users/wiki-ai/followers","following_url":"https://api.github.com/users/wiki-ai/following{/other_user}","gists_url":"https://api.github.com/users/wiki-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/wiki-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiki-ai/subscriptions","organizations_url":"https://api.github.com/users/wiki-ai/orgs","repos_url":"https://api.github.com/users/wiki-ai/repos","events_url":"https://api.github.com/users/wiki-ai/events{/privacy}","received_events_url":"https://api.github.com/users/wiki-ai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wiki-ai/editquality","description":"Supervised learning approach to determining the quality of edits in Wikipedia","fork":false,"url":"https://api.github.com/repos/wiki-ai/editquality","forks_url":"https://api.github.com/repos/wiki-ai/editquality/forks","keys_url":"https://api.github.com/repos/wiki-ai/editquality/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wiki-ai/editquality/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wiki-ai/editquality/teams","hooks_url":"https://api.github.com/repos/wiki-ai/editquality/hooks","issue_events_url":"https://api.github.com/repos/wiki-ai/editquality/issues/events{/number}","events_url":"https://api.github.com/repos/wiki-ai/editquality/events","assignees_url":"https://api.github.com/repos/wiki-ai/editquality/assignees{/user}","branches_url":"https://api.github.com/repos/wiki-ai/editquality/branches{/branch}","tags_url":"https://api.github.com/repos/wiki-ai/editquality/tags","blobs_url":"https://api.github.com/repos/wiki-ai/editquality/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wiki-ai/editquality/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wiki-ai/editquality/git/refs{/sha}","trees_url":"https://api.github.com/repos/wiki-ai/editquality/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wiki-ai/editquality/statuses/{sha}","languages_url":"https://api.github.com/repos/wiki-ai/editquality/languages","stargazers_url":"https://api.github.com/repos/wiki-ai/editquality/stargazers","contributors_url":"https://api.github.com/repos/wiki-ai/editquality/contributors","subscribers_url":"https://api.github.com/repos/wiki-ai/editquality/subscribers","subscription_url":"https://api.github.com/repos/wiki-ai/editquality/subscription","commits_url":"https://api.github.com/repos/wiki-ai/editquality/commits{/sha}","git_commits_url":"https://api.github.com/repos/wiki-ai/editquality/git/commits{/sha}","comments_url":"https://api.github.com/repos/wiki-ai/editquality/comments{/number}","issue_comment_url":"https://api.github.com/repos/wiki-ai/editquality/issues/comments{/number}","contents_url":"https://api.github.com/repos/wiki-ai/editquality/contents/{+path}","compare_url":"https://api.github.com/repos/wiki-ai/editquality/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wiki-ai/editquality/merges","archive_url":"https://api.github.com/repos/wiki-ai/editquality/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wiki-ai/editquality/downloads","issues_url":"https://api.github.com/repos/wiki-ai/editquality/issues{/number}","pulls_url":"https://api.github.com/repos/wiki-ai/editquality/pulls{/number}","milestones_url":"https://api.github.com/repos/wiki-ai/editquality/milestones{/number}","notifications_url":"https://api.github.com/repos/wiki-ai/editquality/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wiki-ai/editquality/labels{/name}","releases_url":"https://api.github.com/repos/wiki-ai/editquality/releases{/id}","created_at":"2015-09-06T19:33:21Z","updated_at":"2015-12-14T17:00:10Z","pushed_at":"2015-12-22T16:52:35Z","git_url":"git://github.com/wiki-ai/editquality.git","ssh_url":"git@github.com:wiki-ai/editquality.git","clone_url":"https://github.com/wiki-ai/editquality.git","svn_url":"https://github.com/wiki-ai/editquality","homepage":null,"size":93733,"stargazers_count":4,"watchers_count":4,"language":"Makefile","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":4,"default_branch":"master"}},"base":{"label":"wiki-ai:master","ref":"master","sha":"5e084f21342c5a9d9e76afa77c3f9f41e96cf012","user":{"login":"wiki-ai","id":12821767,"avatar_url":"https://avatars.githubusercontent.com/u/12821767?v=3","gravatar_id":"","url":"https://api.github.com/users/wiki-ai","html_url":"https://github.com/wiki-ai","followers_url":"https://api.github.com/users/wiki-ai/followers","following_url":"https://api.github.com/users/wiki-ai/following{/other_user}","gists_url":"https://api.github.com/users/wiki-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/wiki-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiki-ai/subscriptions","organizations_url":"https://api.github.com/users/wiki-ai/orgs","repos_url":"https://api.github.com/users/wiki-ai/repos","events_url":"https://api.github.com/users/wiki-ai/events{/privacy}","received_events_url":"https://api.github.com/users/wiki-ai/received_events","type":"Organization","site_admin":false},"repo":{"id":42016242,"name":"editquality","full_name":"wiki-ai/editquality","owner":{"login":"wiki-ai","id":12821767,"avatar_url":"https://avatars.githubusercontent.com/u/12821767?v=3","gravatar_id":"","url":"https://api.github.com/users/wiki-ai","html_url":"https://github.com/wiki-ai","followers_url":"https://api.github.com/users/wiki-ai/followers","following_url":"https://api.github.com/users/wiki-ai/following{/other_user}","gists_url":"https://api.github.com/users/wiki-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/wiki-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiki-ai/subscriptions","organizations_url":"https://api.github.com/users/wiki-ai/orgs","repos_url":"https://api.github.com/users/wiki-ai/repos","events_url":"https://api.github.com/users/wiki-ai/events{/privacy}","received_events_url":"https://api.github.com/users/wiki-ai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wiki-ai/editquality","description":"Supervised learning approach to determining the quality of edits in Wikipedia","fork":false,"url":"https://api.github.com/repos/wiki-ai/editquality","forks_url":"https://api.github.com/repos/wiki-ai/editquality/forks","keys_url":"https://api.github.com/repos/wiki-ai/editquality/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wiki-ai/editquality/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wiki-ai/editquality/teams","hooks_url":"https://api.github.com/repos/wiki-ai/editquality/hooks","issue_events_url":"https://api.github.com/repos/wiki-ai/editquality/issues/events{/number}","events_url":"https://api.github.com/repos/wiki-ai/editquality/events","assignees_url":"https://api.github.com/repos/wiki-ai/editquality/assignees{/user}","branches_url":"https://api.github.com/repos/wiki-ai/editquality/branches{/branch}","tags_url":"https://api.github.com/repos/wiki-ai/editquality/tags","blobs_url":"https://api.github.com/repos/wiki-ai/editquality/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wiki-ai/editquality/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wiki-ai/editquality/git/refs{/sha}","trees_url":"https://api.github.com/repos/wiki-ai/editquality/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wiki-ai/editquality/statuses/{sha}","languages_url":"https://api.github.com/repos/wiki-ai/editquality/languages","stargazers_url":"https://api.github.com/repos/wiki-ai/editquality/stargazers","contributors_url":"https://api.github.com/repos/wiki-ai/editquality/contributors","subscribers_url":"https://api.github.com/repos/wiki-ai/editquality/subscribers","subscription_url":"https://api.github.com/repos/wiki-ai/editquality/subscription","commits_url":"https://api.github.com/repos/wiki-ai/editquality/commits{/sha}","git_commits_url":"https://api.github.com/repos/wiki-ai/editquality/git/commits{/sha}","comments_url":"https://api.github.com/repos/wiki-ai/editquality/comments{/number}","issue_comment_url":"https://api.github.com/repos/wiki-ai/editquality/issues/comments{/number}","contents_url":"https://api.github.com/repos/wiki-ai/editquality/contents/{+path}","compare_url":"https://api.github.com/repos/wiki-ai/editquality/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wiki-ai/editquality/merges","archive_url":"https://api.github.com/repos/wiki-ai/editquality/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wiki-ai/editquality/downloads","issues_url":"https://api.github.com/repos/wiki-ai/editquality/issues{/number}","pulls_url":"https://api.github.com/repos/wiki-ai/editquality/pulls{/number}","milestones_url":"https://api.github.com/repos/wiki-ai/editquality/milestones{/number}","notifications_url":"https://api.github.com/repos/wiki-ai/editquality/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wiki-ai/editquality/labels{/name}","releases_url":"https://api.github.com/repos/wiki-ai/editquality/releases{/id}","created_at":"2015-09-06T19:33:21Z","updated_at":"2015-12-14T17:00:10Z","pushed_at":"2015-12-22T16:52:35Z","git_url":"git://github.com/wiki-ai/editquality.git","ssh_url":"git@github.com:wiki-ai/editquality.git","clone_url":"https://github.com/wiki-ai/editquality.git","svn_url":"https://github.com/wiki-ai/editquality","homepage":null,"size":93733,"stargazers_count":4,"watchers_count":4,"language":"Makefile","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wiki-ai/editquality/pulls/4"},"html":{"href":"https://github.com/wiki-ai/editquality/pull/4"},"issue":{"href":"https://api.github.com/repos/wiki-ai/editquality/issues/4"},"comments":{"href":"https://api.github.com/repos/wiki-ai/editquality/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/wiki-ai/editquality/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/wiki-ai/editquality/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wiki-ai/editquality/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/wiki-ai/editquality/statuses/e8d1b111552051d7f25a6669dca2fb45e16cebe3"}}}}