Skip to content

Instantly share code, notes, and snippets.

View Ladsgroup's full-sized avatar

Amir Sarabadani Ladsgroup

View GitHub Profile
from collections import defaultdict
import re
categories = defaultdict(dict)
c = 0
MARKER = '@@@@@@@@@@@@@@@'
# License: MIT
with open('res.tsv', 'r') as f:
for line in f:
c += 1
import sys
import json
import os
import bz2
import gzip
def read_dump(path):
mode = 'r'
file_ = os.path.split(path)[-1]
if file_.endswith('.gz'):
f = gzip.open(path, mode)
import pywikibot
import sys
import re
from pywikibot import editor
import requests
variableName = 'wgGlobalGroups'
def treat_page(page):
print('Checking', page)
try:
@Ladsgroup
Ladsgroup / add_refs.py
Created October 31, 2020 07:01
Adding refs
from collections import defaultdict, OrderedDict
import pywikibot
import json
import sys
site = pywikibot.Site('wikidata', 'wikidata')
repo = site.data_repository()
site.login()
with open(sys.argv[1], 'r') as f:
for line in f:
try:
@Ladsgroup
Ladsgroup / pickle rick.py
Created July 29, 2020 15:03
features based on kmeans clustering of properties
from revscoring import Feature
from revscoring.datasources import \
revision_oriented as revision_oriented_datasources
from revscoring.datasources.datasource import Datasource
from revscoring.features import wikibase as wikibase_
from revscoring.features import modifiers
from revscoring.features.feature_vector import FeatureVector
from revscoring.features.meta import aggregators, bools
from revscoring.features.modifiers import not_
@Ladsgroup
Ladsgroup / deleter.py
Last active October 13, 2021 13:06
Deleting non notable items.
import pywikibot
import re
import random
import sys
from pywikibot.data.api import Request
wikidata = pywikibot.Site('wikidata', 'wikidata')
wikidata.login()
repo = wikidata.data_repository()
report_page = pywikibot.Page(wikidata, 'User:Pasleim/Items for deletion/Page deleted')
["wikibase.experts.Sense", "wikibase.serialization", "wikibase.serialization.SnakListDeserializer", "wikibase.getUserLanguages", "jquery.valueview.experts.MonolingualText", "wikibase.datamodel.SiteLinkSet", "lexeme-header", "jquery.wikibase.entityview", "jquery.wikibase.entityselector", "jquery.ui.unitsuggester", "wikibase.datamodel", "wikibase.lexeme.serialization.LexemeDeserializer", "wikibase.serialization.Deserializer", "wikibase.dataTypes.DataTypeStore", "jquery.valueview.experts.TimeInput", "wikibase.sites", "wikibase.serialization.MultiTermMapDeserializer", "wikibase.lexeme", "wikibase.lexeme.store", "wikibase.client.getMwApiForRepo", "jquery.valueview.experts.QuantityInput", "wikibase.termbox", "wikibase.lexeme.special", "mw.config.values.wbRepo", "wikibase.serialization.MultiTermDeserializer", "wikibase.datamodel.Statement", "wikibase.lexeme.datamodel.Form", "wikibase.mobile", "wikibase.serialization.TermSerializer", "valueParsers.ValueParserStore", "jquery.valueview.ExpertExtender.UnitSelector", "jq
class WbQuantity(object):
def __init__(self, serializaiton):
self.amount = serializaiton['amount']
def __eq__(self, other):
if isintance(other, str):
return self.amount == other
return self == other
["P638", "P639", "P640", "P646", "P648", "P649", "P650", "P651", "P652", "P653", "P657", "P661", "P662", "P663", "P665", "P668", "P671", "P672", "P673", "P675", "P677", "P679", "P683", "P685", "P686", "P687", "P691", "P695", "P696", "P698", "P699", "P700", "P701", "P704", "P705", "P709", "P714", "P715", "P716", "P717", "P718", "P721", "P722", "P723", "P724", "P727", "P731", "P732", "P733", "P745", "P757", "P758", "P759", "P760", "P761", "P762", "P763", "P764", "P771", "P772", "P773", "P774", "P775", "P776", "P777", "P778", "P779", "P781", "P782", "P804", "P806", "P808", "P809", "P815", "P818", "P819", "P821", "P824", "P827", "P829", "P830", "P836", "P838", "P839", "P842", "P843", "P844", "P845", "P846", "P849", "P850", "P858", "P860", "P861", "P862", "P863", "P864", "P865", "P866", "P867", "P212", "P213", "P214", "P218", "P219", "P220", "P221", "P227", "P231", "P232", "P234", "P235", "P236", "P243", "P244", "P245", "P247", "P267", "P268", "P269", "P270", "P271", "P278", "P297", "P298", "P299", "P300", "P303",
import os
from w3lib.html import get_base_url
from collections import defaultdict, OrderedDict
import requests
import extruct
import pprint
import sys
from wikidatarefisland.external_identifier import ExternalIdentifier