commit ada7623e6c281f7456e7811efa6d60f07a5d758d Author: mb@mb Date: Mon Oct 8 20:27:32 2018 +0200 very first commit! :) diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae2e5f4 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Trust ~in~ formation + +A small tool for Wikipedia article quality inspection using ORES. + + diff --git a/sandbox-score-revids.py b/sandbox-score-revids.py new file mode 100644 index 0000000..3e723e3 --- /dev/null +++ b/sandbox-score-revids.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 + +import os, time, json +import mwclient + +from sys import stdin, stderr, stdout +import select +from pprint import pprint +import subprocess + +site = mwclient.Site('en.wikipedia.org') +print(site) + +while True: + + + page = site.Pages['User:Trustinformationws/sandbox'] + # print(page) + + revid = list(page.revisions())[0]['revid'] + + # model = 'draftquality' + # model = 'damaging' + model = 'goodfaith' + model = 'goodfaith draftquality' + + cmd = "echo '{\"rev_id\": "+str(revid)+"}' | ores score_revisions https://ores.wikimedia.org enwiki "+model + # print(cmd) + + sub = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + output = sub.communicate()[0] + # print('>>> this is the current output', output) + output = str(output) + output = output.split('\\n')[2] + result = json.loads(output) + # pprint(result) + + if model == 'damaging': + true = result['score']['damaging']['score']['probability']['true'] + false = result['score']['damaging']['score']['probability']['false'] + x = '''\nLatest revid: {}. This edit is ... + ... {} likely to be goodfaith, + ... {} likely badfaith.'''.format(revid, true, false) + + if model == 'draftquality': + ok = result['score']['draftquality']['score']['probability']['OK'] + vandalism = result['score']['draftquality']['score']['probability']['vandalism'] + spam = result['score']['draftquality']['score']['probability']['spam'] + attack = result['score']['draftquality']['score']['probability']['attack'] + x = '''\nLatest revid: {}. It is ... + ... {} likely to be OK, + ... {} likely to be vandalism, + ... {} likely to be spam, + ... {} likely to be an attack.'''.format(revid, ok, vandalism, spam, attack) + + if model == 'goodfaith': + true = result['score']['goodfaith']['score']['probability']['true'] + false = result['score']['goodfaith']['score']['probability']['false'] + x = '''\nLatest revid: {}. This edit is ... + ... {} likely to be goodfaith, + ... {} likely badfaith.'''.format(revid, true, false) + + if model == 'goodfaith draftquality': + true = result['score']['goodfaith']['score']['probability']['true'] + false = result['score']['goodfaith']['score']['probability']['false'] + ok = result['score']['draftquality']['score']['probability']['OK'] + vandalism = result['score']['draftquality']['score']['probability']['vandalism'] + spam = result['score']['draftquality']['score']['probability']['spam'] + attack = result['score']['draftquality']['score']['probability']['attack'] + x = '''\nLatest revid: {}. It is ... + ... {} likely to be OK, + ... {} likely to be vandalism, + ... {} likely to be spam, + ... {} likely to be an attack.\n + ... {} likely to be goodfaith, + ... {} likely badfaith.'''.format(revid, ok, vandalism, spam, attack, true, false) + + print(x) + + time.sleep(10) \ No newline at end of file