http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94941
Revision: 94941 Author: giovanni Date: 2011-08-18 20:58:24 +0000 (Thu, 18 Aug 2011) Log Message: ----------- added .gitignore to contribution_inequality, added list of pages, renamed query.py -> query_top100.py + fixed queryall.sh Modified Paths: -------------- trunk/tools/wsor/contribution_inequality/queryall.sh Added Paths: ----------- trunk/tools/wsor/contribution_inequality/.gitignore trunk/tools/wsor/contribution_inequality/pages.txt trunk/tools/wsor/contribution_inequality/query_top100.py Removed Paths: ------------- trunk/tools/wsor/contribution_inequality/query.py Added: trunk/tools/wsor/contribution_inequality/.gitignore =================================================================== --- trunk/tools/wsor/contribution_inequality/.gitignore (rev 0) +++ trunk/tools/wsor/contribution_inequality/.gitignore 2011-08-18 20:58:24 UTC (rev 94941) @@ -0,0 +1,6 @@ +.*.swp +*.pyc +data/* +dist/* +MANIFEST +build Added: trunk/tools/wsor/contribution_inequality/pages.txt =================================================================== --- trunk/tools/wsor/contribution_inequality/pages.txt (rev 0) +++ trunk/tools/wsor/contribution_inequality/pages.txt 2011-08-18 20:58:24 UTC (rev 94941) @@ -0,0 +1,118 @@ +Notability +Verifiability +No_original_research +Neutral_point_of_view +Article_titles +What_Wikipedia_is_not +Wikipedia_is_not_a_dictionary +Biographies_of_living_persons +Consensus +Ignore_all_rules +Deletion_policy +Criteria_for_speedy_deletion +Proposed_deletion +Editing_policy +Citing_sources +Disambiguation +Edit_warring +Civility +No_legal_threats +No_personal_attacks +Ownership_of_articles +Sock_puppetry +Conflict_of_interest +Do_not_disrupt_Wikipedia_to_illustrate_a_point +Etiquette +Gaming_the_system +Manual_of_Style +Manual_of_Style_(abbreviations) +Manual_of_Style_(accessibility) +Manual_of_Style_(article_message_boxes) +Manual_of_Style_(biographies) +Manual_of_Style_(capital_letters) +Manual_of_Style_(captions) +Manual_of_Style_(dates_and_numbers) +Manual_of_Style_(disambiguation_pages) +Manual_of_Style_(embedded_lists) +Manual_of_Style_(footnotes) +Manual_of_Style_(icons) +Manual_of_Style_(infoboxes) +Manual_of_Style_(layout) +Manual_of_Style_(lead_section) +Manual_of_Style_(linking) +Manual_of_Style_(lists) +Manual_of_Style_(lists_of_works) +Manual_of_Style_(pronunciation) +Manual_of_Style_(proper_names) +Manual_of_Style_(self-references_to_avoid) +Manual_of_Style_(spelling) +Manual_of_Style_(summary_style) +Manual_of_Style_(tables) +Manual_of_Style_(text_formatting) +Manual_of_Style_(titles) +Manual_of_Style_(trademarks) +Manual_of_Style_(trivia_sections) +Manual_of_Style_(words_to_watch) +Help_desk +Reference_desk/Computing +Reference_desk/Entertainment +Reference_desk/Humanities +Reference_desk/Language +Reference_desk/Mathematics +Reference_desk/Science +Reference_desk/Miscellaneous +Editor%27s_index_to_Wikipedia +Copyright_problems +Contributor_copyright_investigations +External_links/Noticeboard +Fringe_theories/Noticeboard +Neutral_point_of_view/Noticeboard +Reliable_sources/Noticeboard +Administrator_intervention_against_vandalism +Arbitration_Committee/Noticeboard +Arbitration/Requests/Enforcement +Arbitration/Requests +Editor_review +Dispute_resolution_noticeboard +Wikiquette_assistance +Requests_for_mediation +Notability_(academics) +Notability_(books) +Notability_(events) +Notability_(films) +Notability_(music) +Notability_(numbers) +Notability_(people) +Notability_(sports) +Notability_(web) +Notability_(organizations_and_companies) +No_original_research/Noticeboard +Fiction/Noticeboard +Content_forking +Autobiography +Non-free_content_review +Bureaucrats%27_noticeboard +External_links +Fringe_theories +No_disclaimers_in_articles +Offensive_material +Patent_nonsense +Plagiarism +Spam +Wikipedia_is_not_for_things_made_up_one_day +Sexual_content +Vandalism +Please_do_not_bite_the_newcomers +Arbitration/Policy +Banning_policy +Blocking_policy +Administrators +Bot_policy +Copyright_violations +Image_use_policy +Non-free_content_criteria +Be_bold +Categorization/Ethnicity,_gender,_religion_and_sexuality +Categorization_of_people +Categorization +Citing_sources Deleted: trunk/tools/wsor/contribution_inequality/query.py =================================================================== --- trunk/tools/wsor/contribution_inequality/query.py 2011-08-18 20:56:57 UTC (rev 94940) +++ trunk/tools/wsor/contribution_inequality/query.py 2011-08-18 20:58:24 UTC (rev 94941) @@ -1,28 +0,0 @@ -#!/usr/bin/python -from argparse import ArgumentParser -import os -from oursql import connect - -parser = ArgumentParser() -parser.add_argument('page') -parser.add_argument('year') -parser.add_argument('ns') - -query=""" -select - user_name, editcount -from giovanni.policy_contributors -where title = ? and year = ? and namespace = ? -order by editcount desc limit 100; -""" - -if __name__ == '__main__': - ns = parser.parse_args() - db = connect(read_default_file=os.path.expanduser('~/.my.cnf')) - cursor = db.cursor() - cursor.execute(query, (ns.page, ns.year, ns.ns)) - f = open('%s-%s-%s.tsv' % (ns.page, ns.year, ns.ns), 'w') - for row in cursor: - print >> f, '%s\t%d' % row - print 'results printed to %s' % f.name - Copied: trunk/tools/wsor/contribution_inequality/query_top100.py (from rev 94910, trunk/tools/wsor/contribution_inequality/query.py) =================================================================== --- trunk/tools/wsor/contribution_inequality/query_top100.py (rev 0) +++ trunk/tools/wsor/contribution_inequality/query_top100.py 2011-08-18 20:58:24 UTC (rev 94941) @@ -0,0 +1,31 @@ +#!/usr/bin/python + +''' returns the top 100 contributors to a given page ''' + +from argparse import ArgumentParser +import os +from oursql import connect + +parser = ArgumentParser() +parser.add_argument('page') +parser.add_argument('year') +parser.add_argument('ns') + +query=""" +select + user_name, editcount +from giovanni.policy_contributors +where title = ? and year = ? and namespace = ? +order by editcount desc limit 100; +""" + +if __name__ == '__main__': + ns = parser.parse_args() + db = connect(read_default_file=os.path.expanduser('~/.my.cnf')) + cursor = db.cursor() + cursor.execute(query, (ns.page, ns.year, ns.ns)) + f = open('%s-%s-%s.tsv' % (ns.page, ns.year, ns.ns), 'w') + for row in cursor: + print >> f, '%s\t%d' % row + print 'results printed to %s' % f.name + Modified: trunk/tools/wsor/contribution_inequality/queryall.sh =================================================================== --- trunk/tools/wsor/contribution_inequality/queryall.sh 2011-08-18 20:56:57 UTC (rev 94940) +++ trunk/tools/wsor/contribution_inequality/queryall.sh 2011-08-18 20:58:24 UTC (rev 94941) @@ -4,5 +4,5 @@ mkdir results pushd results for args in {2001..2010}' '{4..5}; do - xargs -I {} $wd/query.py {} $args < $wd/pages.txt + xargs -I {} $wd/query_top100.py {} $args < $wd/pages.txt done _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs