Skip to content

Instantly share code, notes, and snippets.

View Ladsgroup's full-sized avatar

Amir Sarabadani Ladsgroup

View GitHub Profile
@Ladsgroup
Ladsgroup / Cluster.py
Created August 27, 2015 18:59
Clustering reverted edits in Wikipedia
import codecs
import math
import sklearn.cluster
import matplotlib.pyplot as plt
x = set()
c = 0
path = '/home/amir/Downloads/featuresetsforclustering/ptwiki.features_reverted.20k.tsv'
with codecs.open(path, 'r', 'utf-8') as f:
for line in f:
@Ladsgroup
Ladsgroup / Link FA
Last active August 29, 2015 14:21
Link FA problem
@Ladsgroup
Ladsgroup / Code
Created June 1, 2015 13:05
Script to fix interwiki of translations
# License: MIT
import pywikibot, codecs, json
site = pywikibot.Site('ca')
offset = 0
cases = []
while True:
req = pywikibot.data.api.Request(site=site, action='query', list='cxpublishedtranslations', limit=500, offset=offset)
offset += 500
res = req.submit()
if not res['result']['translations']:
@Ladsgroup
Ladsgroup / amire80.py
Created August 5, 2015 13:20
Interwiki for CX
GNU nano 2.2.6 File: scripts/amire80.py
# License: MIT
import pywikibot, codecs, json
site = pywikibot.Site('ca')
offset = 0
_base_dir = '/data/project/dexbot/pywikibot-core/'
cases = []
while True:
req = pywikibot.data.api.Request(site=site, action='query', list='cxpublishedtranslations', limit=500, offset=offset)
#MIT license
import pywikibot
import mwparserfromhell
site = pywikibot.Site('meta', fam='meta')
page = pywikibot.Page(site, 'Research:Revision scoring as a service/Word lists')
text = page.get()
wikicode = mwparserfromhell.parse(text)
templates = wikicode.filter_templates()
for template in templates:
if str(template.name).strip() == 'Research:Revision scoring as a service/template/word list item':
@Ladsgroup
Ladsgroup / list.py
Created October 19, 2015 15:53
features extracted from dumps
features = [
wb_diff_f.number_added_sitelinks,
wb_diff_f.number_removed_sitelinks,
wb_diff_f.number_changed_sitelinks,
wb_diff_f.number_added_labels,
wb_diff_f.number_removed_labels,
wb_diff_f.number_changed_labels,
wb_diff_f.number_added_descriptions,
wb_diff_f.number_removed_descriptions,
wb_diff_f.number_changed_descriptions,
@Ladsgroup
Ladsgroup / dump.py
Created October 30, 2015 22:17
Extracting features from dumps
import sys
import time
import codecs
import json
import random
from mw.lib import reverts
from ipaddress import ip_address
from pywikibot import xmlreader
@Ladsgroup
Ladsgroup / result
Created November 2, 2015 13:32
Old k-means algorithm
[0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0
@Ladsgroup
Ladsgroup / res
Created November 3, 2015 10:00
Link FA transclusion count
(1, 'en')
(1, 'sv')
(1, 'nl')
(0, 'de')
(0, 'fr')
(0, 'war')
(0, 'ru')
(0, 'ceb')
(0, 'it')
(0, 'es')
@Ladsgroup
Ladsgroup / meta.py
Created December 29, 2015 21:08
OOP tests
class FeatureTestCase:
"""docstring for FeatureTestCase"""
def __init__(self, name):
super(FeatureTestCase, self).__init__()
self.name = name
def test_pickle(test_case):
return eq_(pickle.loads(pickle.dumps(test_case)), test_case)