Jump to content

File:Wikipedia article assessment graph (top decile).svg

From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 720 × 540 pixels, file size: 283 KB)

Summary

[edit]
File information
Description

Graph of the relative rates of each Wikipedia article assessment class over time, as compiled by the Wikipedia 1.0 team's bot, specifically showing the top decile.

Source

Python + matplotlib

Date

2014-04-13

Author

Facing the Sky

Permission
(Reusing this file)

See below.


Other information

Complete script to generate (2-clause BSD-licensed):

#!/usr/bin/python
# Copyright (c) 2014, Facing the Sky
# All rights reserved.

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: 

# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions and the following disclaimer. 
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution. 

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from lxml import etree
import pandas as pd
from matplotlib import pyplot as plt
import re
import numpy as np
import datetime
import requests

#Note order: this goes bottom-to-top.
classes = [('Stub', '#ff6666'),
           ('Start', '#ffaa66'),
           ('C', '#ffff66'),
           ('B', '#b2ff66'),
           ('GA', '#66ff66'),
           ('A', '#66ffff'),
           ('FA', '#6699ff'),
           ]

TOTAL_PAT = re.compile(r"^\|\| '''(\d{1,3}(,\d{3})*)'''")
CLASS_PAT = re.compile(r"^\| \{\{(%s)-Class\}\}" % "|".join(cls for cls, colour in classes))

def munge(text):
    cls = None
    seen = {}
    for line in text.split("\n"):
        if cls is not None:
            m = TOTAL_PAT.match(line)
            if m is not None:
                num = int(m.group(1).replace(",", ""))
                seen[cls] = num
                cls = None
                continue
        m = CLASS_PAT.match(line)
        if m is not None:
            if cls is not None:
                return None
            cls = m.group(1)
            if cls in seen:
                return None
    if set(seen.keys()) != set(cls for cls, colour in classes):
        return None
    tot = float(sum(seen.values()))
    return dict((k, v / tot) for k, v in seen.items())

data = []

buggy_revs = set(['494008070', '494007960'])

last_rev_date = '2010-02-07T23:07:10Z'
while True:
    r = requests.post('http://en.wikipedia.org/w/index.php', params = {'title': 'Special:Export', 'pages': 'User:WP_1.0_bot/Tables/OverallArticles', 'offset': last_rev_date, 'limit': 1000, 'action': 'submit'})
    r.raise_for_status()
    root = etree.fromstring(r.text)
    revs = root.findall("{http://www.mediawiki.org/xml/export-0.8/}page/{http://www.mediawiki.org/xml/export-0.8/}revision")
    for rev in revs:
        if rev.find("{http://www.mediawiki.org/xml/export-0.8/}id").text in buggy_revs:
            continue
        text = rev.find("{http://www.mediawiki.org/xml/export-0.8/}text").text
        row = munge(text)
        if row is None:
            continue
        last_rev_date = rev.find("{http://www.mediawiki.org/xml/export-0.8/}timestamp").text
        date = row['date'] = np.datetime64(pd.datetools.parse(last_rev_date))
        data.append(row)
    if len(revs) < 1000:
        break

df = pd.DataFrame.from_records(data, columns = ["date"] + list(cls for cls, colour in classes))

fig, ax = plt.subplots()

ax.stackplot(df['date'], df[list(cls for cls, colour in classes)].transpose(), colors = [colour for cls, colour in classes], linewidths = 0)
ax.set_ylim(0, 1)

plt.savefig("res_full.svg")

ax.set_ylim(0.9, 1)
plt.savefig("res_top_decile.svg")

See File:Wikipedia article assessment graph.svg for the full graph.

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current08:06, 25 November 2023Thumbnail for version as of 08:06, 25 November 2023720 × 540 (283 KB)Minorax (talk | contribs)fix // Editing SVG source code using c:User:Rillke/SVGedit.js
13:49, 13 April 2014Thumbnail for version as of 13:49, 13 April 2014720 × 540 (283 KB)Facing the Sky (talk | contribs)Uploading a self-made file using File Upload Wizard

The following page uses this file:

Metadata