User:Mack Coster/voteanalyzer

From RationalWiki
Jump to navigation Jump to search
#!/usr/bin/perl

use strict;
use warnings;

use Time::ParseDate;
use MediaWiki::API;
use JSON;

binmode STDOUT, ':utf8:';

if (@ARGV != 4) {
    print STDERR "usage: voteanalyzer voting-page-title first-vote-section"
	. " last-vote-section time-range\n";
    exit -1;
}

my $votepage = $ARGV[0];
my @votesections = $ARGV[1]..$ARGV[2];
my $range = parsedate($ARGV[3]) or die "could not parse time-range: $!";

my $mw = MediaWiki::API->new({api_url => 'http://rationalwiki.org/w/api.php',
			      use_http_get => 1});

my $newpages = $mw->list({action => 'query',
			  list => 'recentchanges',
			  rcprop => 'user|title',
			  rcshow => '!redirect',
			  rctype => 'new',
			  rcnamespace => '0',
			  rcend => $range})
    or die "could not connect to rationalwiki: $!";

{
    my $now = localtime;
    my $past = localtime $range;
    print "Looking at new mainspace non-redirect pages "
	. "from now ($now) to $past.\n";
    print "From http://rationalwiki.org/w/api.php:\n";
}
my %newcount;
my %titles;

for my $page (@$newpages) {
    my $creator = $page->{user};
    $newcount{$creator}++;
    $titles{$creator} = [] unless $titles{$creator};
    push @{$titles{$creator}}, $page->{title};
}

my @rank = sort { $newcount{$b} <=> $newcount{$a} } keys %newcount;

for my $user (@rank) {
    print "$user created $newcount{$user} article";
    print "s" if $newcount{$user} != 1;
    print ":\n";
    for my $title (@{$titles{$user}}) {
	print "\t$title\n";
    }
}

my %voters;

for my $section (@votesections) {
    print "----\nFrom $votepage, section $section:\n";
    my $response = $mw->api({action => 'query',
			     prop => 'revisions',
			     titles => $votepage,
			     rvprop => 'content',
			     rvexpandtemplates => '1',
			     rvsection => $section}) or die $!;
    my @content;

    {
	my @values = values %{$response->{query}->{pages}};
	my $text = $values[0]->{revisions}->[0]->{'*'};
	@content = split("\n", $text);
    }

    my $option = shift @content;
    $option =~ s/^\s*=*\s*([^=]+).*$/$1/;
    $option =~ s/\s+$//;
    $voters{$option} = [];

    print "The following users voted for $option:\n";

    my $user = 'johnny';

    for my $line (@content) {
	$user = '' if $line =~ /^\s*#/;

	if (!$user) {
	    $line =~ m@User(( |_)talk)?:([^/|\]]+)@;
	    $user = $3;
	    next unless $user;
	    $user =~ s/_/ /g;
	    print "\t$user, rank: " . ($newcount{$user} or 0) . "\n";
	    push @{$voters{$option}}, $user;
	}
    }
}

print "----\nWeighed on this data the results would be:\n";

for my $option (keys %voters) {
    my $votes = 0;

    for my $user (@{$voters{$option}}) {
	$votes += $newcount{$user} if $newcount{$user};
    }

    print "\t$option received $votes vote";
    print 's' if $votes != 1;
    print "\n";
}
> ./voteanalyzer 'RationalWiki Talk:Community Standards' 16 21 '-  1 year'
Looking at new mainspace non-redirect pages from now (Wed Sep 21 03:33:25 2011) to Tue Sep 21 03:33:20 2010.
From http://rationalwiki.org/w/api.php:
Balaam created 27 articles:
	Ron McVan
	David Lane
	New Communist Party of Britain
	Palestine Solidarity Campaign
	The Unhived Mind
	Youngy
	Andrew Neather
	Communist Party of Great Britain (Marxist–Leninist)
	Respect Party
	One Law for All
	John Jay
	UK Indymedia
	Alan Lake
	Abdel Bari Atwan
	Conspiracy theories surrounding the Oslo attacks
	Lee Ingram
	Abdullah Yusuf Azzam
	Illuminati (game)
	Cutting Edge Ministries
	Joseph "Doc" Marquis
	New Right
	Johann Hari
	Woden's Folk
	Nation of Yahweh
	Muslim Council of Britain
	Raed Salah
	Might is Right
Maratrean created 26 articles:
	Great Apostasy
	Schism
	Eastern Churches
	Waldensians
	Duns Scotus
	Vetus Latina
	Polygenesis
	Independent Catholic churches
	Hyper-Calvinism
	Preterism
	Douay-Rheims
	One world religion
	One world government
	Council of Europe
	Christology
	Bible translation
	Antipope
	Annihilationism
	Pesher
	Habakkuk
	Sappho
	4 Maccabees
	3 Maccabees
	2 Maccabees
	Pseudepigrapha
	Cosmodicy
Nebuchadnezzar created 21 articles:
	Eurabia
	Frank Gaffney
	Americans for Truth About Homosexuality
	Michael Crichton
	Racial realism
	Zionist Occupation Government
	Chlorella
	Sam Francis
	Anti-Catholicism
	Heteronormativity
	Chuck Baldwin
	Anti-relativity
	Bourgeois pseudoscience
	Gerson Therapy
	States' Rights Democratic Party
	Armenian Genocide denial
	Alan Caruba
	Canada Free Press
	Acid rain
	Investor's Business Daily
	James Hansen
ZooGuard created 13 articles:
	Xenoglossy
	Alphabiotics
	Consegrity
	Hale crater
	Zetetic
	Zener cards
	Cupping
	Tasseography
	Ignatius L. Donnelly
	Jacques Vallée
	James Oberg
	Black triangle
	Bradley Monton
Socal212 created 12 articles:
	Sierra Club
	Warren Jeffs
	Berkeley Free Speech Movement
	Affordable Care Act
	Timothy Geithner
	Jesse Jackson
	Al Sharpton
	Boson
	Gretchen Carlson
	Lou Dobbs
	Last Supper
	Jan Brewer
WaitingforGodot created 8 articles:
	Dialectics
	Very special episode
	Summary of the Book of Genesis
	Handkerchief code
	RU-486
	History of abortion
	Embryo
	Evidence linking abortion to breast cancer
Ty created 7 articles:
	Bolivia
	King David
	Laura Knight Jadczyk
	Giordano Bruno
	Haikouichthys
	Indulgence
	Mary Celeste
Feredir28 created 5 articles:
	Christopher Langan
	Kent Hovind's Creation Seminar: The Hovind Theory
	Kent Hovind's Creation Seminar: The Dangers of Evolution
	Creation Today
	Native Americans and Christianity
Osaka Sun created 4 articles:
	Futurama
	Stephen Harper
	2001 Clear Channel memorandum
	CBC
Chaosof99 created 4 articles:
	The Periodic Table of Videos
	Sixty Symbols
	Ask an Atheist
	QualiaSoup
AD created 4 articles:
	Spurious rigor
	Shaming
	Biological determinism
	Catcher in the Rye
Danfly created 4 articles:
	Sanal Edamaruku
	Tantra
	Crackpot index
	Hilton Ratcliffe
Winttrix created 3 articles:
	Americans Elect
	Waffen-SS
	Puppet state
184.19.143.18 created 3 articles:
	Model legislation
	VDARE
	Manhattan Institute
P-Foster created 3 articles:
	Vietnam syndrome
	Template Meh
	Israel Defence Force
Cacterpus created 3 articles:
	The Blaze
	Virtual particles
	In vitro meat
UHM created 3 articles:
	Americentrism
	Pirate Party
	Political Parties of Germany
ListenerX created 3 articles:
	Systems thinking
	John Calvin
	American Legislative Exchange Council
LucidFox created 3 articles:
	Viktor Petrik
	Gender binary
	Athorism
Human created 3 articles:
	Chick-fil-A
	Texas v. Johnson
	AARP
Tom Morris created 3 articles:
	Steve Pavlina
	Andrea Minichiello Williams
	Nadine Dorries
Proxima Centauri created 2 articles:
	Army of God
	Menstruation
Bob M created 2 articles:
	Maratreanism
	Prince Charles
Earth created 2 articles:
	Childfree movement
	Extinctionism
Thorvelden created 2 articles:
	Anders Behring Breivik
	John Eidsmoe
Genghis Khant created 2 articles:
	Lights in the night
	Council of Ex-Muslims of Britain
75.87.146.9 created 2 articles:
	Victor J. Stenger
	Miracle Detectives
Armondikov created 2 articles:
	Dogma (film)
	Mensur Omerbashich
CopernicustheYounger created 2 articles:
	Francis Schaeffer
	Plague
Subsound created 2 articles:
	Doug Rokke
	Rooibos tea
PeterL created 2 articles:
	Brian Thomas
	John Morris
Lawnmower Joe created 2 articles:
	The Mysterious Origins of Man
	Tiwanaku
Gomer created 2 articles:
	Ted Holden
	Christopher Booker
I'm not Jesus created 2 articles:
	National Secular Society
	John Paul II
DasRationalpersone created 2 articles:
	Zmago Jelinčič Plemeniti
	Jesusophile
82.44.143.26 created 2 articles:
	Fifth column
	News of the World
Crundy created 2 articles:
	Joe Power
	Melatonin
184.19.136.63 created 2 articles:
	Technocracy movement
	Chemurgy movement
The Anti-Conservapedia created 1 article:
	RW:Free Marcus Now!
194.217.113.187 created 1 article:
	Drum and Bass
193.200.150.125 created 1 article:
	Matthew Bracken
Natman created 1 article:
	Fukushima One
ZILtoid1991 created 1 article:
	Ateizmus
Hamster created 1 article:
	Thailand
74.89.192.173 created 1 article:
	Addicted to Hate
Rsia08 created 1 article:
	Science (TV channel)
193.200.150.137 created 1 article:
	Francis Parker Yockey
50.39.195.3 created 1 article:
	Richard Kent
Rationalizer created 1 article:
	Rick Perry
Reckless Noise Symphony created 1 article:
	Bradlee Dean
Tetronian created 1 article:
	Absence of evidence
110.32.84.125 created 1 article:
	Ethnic Cleansing (video game)
David Gerard created 1 article:
	Bitcoin
Rabbitxhampster created 1 article:
	Alberto Gonzales
Real first name and last initial created 1 article:
	President
BruceGrubb created 1 article:
	Weston Price
Brendiggg created 1 article:
	The Day After Tomorrow
JzG created 1 article:
	Jeremy Sherr
Nasreddin created 1 article:
	Bit
KevinR1990 created 1 article:
	Contagion
JimJast created 1 article:
	Spacetime
DevilishlyHandsome created 1 article:
	Atheism 3.0
MDB created 1 article:
	Bryan Fischer
EauDeCologne created 1 article:
	Anthony Weiner
Amateur scientician created 1 article:
	Web Bot Project
Lpetrich created 1 article:
	Politicized pseudosciences
Mectrixctic created 1 article:
	Here be Dragons
Klaus Vos created 1 article:
	Cyber-bullying
184.19.204.155 created 1 article:
	James McKeever
Dr.Smart created 1 article:
	Buzz Aldrin
Doctor Dark created 1 article:
	Prevention (magazine)
193.200.150.82 created 1 article:
	Revolutionary Communist Party
Thunderkatz created 1 article:
	Akashic Records
110.32.76.10 created 1 article:
	Big Bad Chinese Mama
50.39.205.254 created 1 article:
	IBGYBG
KrissAkabusiAwoogar created 1 article:
	What proof or evidence do you have that atheism is true and correct?
Abadidea created 1 article:
	Asherah
Sprocket J Cogswell created 1 article:
	Conservation of government
Scream!! created 1 article:
	Freethought blogs
The Anti-Christ created 1 article:
	We don't need a God anymore if he even did exist
----
From RationalWiki Talk:Community Standards, section 16:
The following users voted for Option Zero: Status Quo:
	LArron, rank: 0
	Filby, rank: 0
	Tielec01, rank: 0
	TheEgyptian, rank: 0
	Blue, rank: 0
	Night Jaguar, rank: 0
	Kupochama, rank: 0
	Ironclad, rank: 0
	Nutty Roux, rank: 0
	Reckless Noise Symphony, rank: 1
	Senator Harrison, rank: 0
	Hamster, rank: 1
	Sterile, rank: 0
	Tmtoulouse, rank: 0
	MarkGall, rank: 0
	Maratrean, rank: 26
	Ty, rank: 7
	Eira, rank: 0
	Human, rank: 3
	Stabby the Misanthrope, rank: 0
	AD, rank: 4
----
From RationalWiki Talk:Community Standards, section 17:
The following users voted for Option One: Wild West:
	Icewedge, rank: 0
----
From RationalWiki Talk:Community Standards, section 18:
The following users voted for Option Two: Community Property:
	Nx, rank: 0
	nickheer, rank: 0
	Röstigraben, rank: 0
	SuspectedReplicant, rank: 0
	brxbrx, rank: 0
	Iscariot, rank: 0
	Damo, rank: 0
	Alain, rank: 0
	Noodledicksissypants, rank: 0
----
From RationalWiki Talk:Community Standards, section 19:
The following users voted for Option Three: User's Castle:
	π, rank: 0
	Bob M, rank: 2
	Oldusgitus, rank: 0
	LowKey, rank: 0
	Crundy, rank: 2
	UHM, rank: 3
	Theemperor, rank: 0
	Psygremlin, rank: 0
	RobSmith, rank: 0
	I fucked the girl in Hanson, rank: 0
	WaitingforGodot, rank: 8
	DickTurpis, rank: 0
	Socal212, rank: 12
	Genghis Khant, rank: 2
	Rursus, rank: 0
	Mack Coster, rank: 0
	Eyeonicr, rank: 0
	Secret Squirrel, rank: 0
	ListenerX, rank: 3
----
From RationalWiki Talk:Community Standards, section 20:
The following users voted for Option Four: Moderation:
----
From RationalWiki Talk:Community Standards, section 21:
The following users voted for Goat:
	Ajkgordon, rank: 0
	Tetronian, rank: 1
	Durbinator, rank: 0
	ArchieGoodwin, rank: 0
----
Weighed on this data the results would be:
	Goat received 1 vote
	Option Zero: Status Quo received 42 votes
	Option Four: Moderation received 0 votes
	Option Two: Community Property received 0 votes
	Option One: Wild West received 0 votes
	Option Three: User's Castle received 32 votes