Toward More Flexible Education Programs in the Middle East

Welcome by DADD-INITIATIVE e.V.

On this page, you find some details and the code used to analyze the data and prepare the results presented at Wikimania 2023 in Singapore (link to the poster).  This work is based on discussions and contributions between DADD-INITIATIVE e.V. in Germany and Wikimedia Levant.

Code used

 
 
 
”’
 Given an excel file with a one-column sheet, with column header name “username” and with rows containing
Wikipedia usernames, the following code connects to the arwiki (can be modified to any other wiki) and applied the method
contributions_by_year” for each user and print the results.
”’
 
from pywikibot import Site, User
import pandas as pd
from collections import defaultdict
def contributions_by_year(username,searched_year):
    site = Site(‘ar’, ‘wikipedia’)  # specify the Arabic Wikipedia
    contributions_by_year = 0
    try:
        user = User(site, username)
        for page, oldid, ts, comment in user.contributions():
            year = ts.year  # get year directly from Timestamp object
            if year == searched_year:
                contributions_by_year += 1
    except: pass
    return contributions_by_year
df = pd.read_excel(‘G:\My Drive\wiki_users.xlsx’,sheet_name=‘2020’)  # replace with your Excel file path
all_contributions = defaultdict(lambda: defaultdict(int))
 
# the list “years” can be modified to include more or less years to consider, for simplicity and to be aligned with
# the analysis below, only 2 years are considered.
years = [2020,2021]
for i, user in enumerate(df[‘username’]):
    for year in years:
        contributions =  contributions_by_year(user,year)
        all_contributions[user][year] = contributions
        print(user,year,contributions)
 
”’ In this method, and for any two years to be selected below, the change of contributions from one year to the other (next)
is analyzed, e.g. given that a user had contributions done in an education program in 2020, we are interested on his

contributions in 2021.

In this example we define 3 classes to monitor the sustainability by looking at the contributions in the following year

as follows:

* 0-10 edits (almost no activity)

* 11 – 50 edits (moderate activity)

* 100+ edits (high activity)

”’

def evaluation(years):

 

    import matplotlib.pyplot as plt

 

    first_year = years[0]
    second_year = years[1]
    categories = {‘0-10’: 0, ’11-50′: 0, ‘>100’: 0}

 

    # Calculate contributions for each category
    for user, contributions in all_contributions.items():
        if contributions[first_year] > 0:
            if 0 <= contributions[second_year] <= 10:
                categories[‘0-10’] += 1
            elif 11 <= contributions[second_year] <= 50:
                categories[’11-50′] += 1
            elif contributions[second_year] > 100:
                categories[‘>100’] += 1

 

    # Prepare data for the pie chart
    labels = categories.keys()
    sizes = categories.values()

 

    plt.figure(figsize=(10, 10))
    # Create a pie chart
    plt.pie(sizes, labels=labels, autopct=%1.1f%%, startangle=140)

 

    # Ensure that pie is drawn as a circle.
    plt.axis(‘equal’)

 

    #plt.title(‘User\’s Contributions to Arabic Wikipedia in ‘ + str(first_year) + ‘ and  ‘ +  str(second_year))
    plt.legend(labels, loc=‘best’)
           
    plt.show()

# Run the method “evaluation”, which also plots the results as a pie-chart.

evaluation(years)