|
@ -5,10 +5,20 @@ from sys import stdin, stderr, stdout |
|
|
from pprint import pprint |
|
|
from pprint import pprint |
|
|
import subprocess |
|
|
import subprocess |
|
|
import mwclient |
|
|
import mwclient |
|
|
|
|
|
from datetime import datetime |
|
|
|
|
|
|
|
|
site = mwclient.Site('en.wikipedia.org') |
|
|
site = mwclient.Site('en.wikipedia.org') |
|
|
print(site) |
|
|
print(site) |
|
|
|
|
|
|
|
|
|
|
|
previous_result = '' # keep track of changes, only print when there are new results (when the wikipage changed) |
|
|
|
|
|
|
|
|
|
|
|
timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') |
|
|
|
|
|
log = open('sandbox-score-revids.txt', 'a+') |
|
|
|
|
|
log.write('''* * * * * * * * * * * * * * * * * * * * * * * * * * |
|
|
|
|
|
Logging sandbox-score-revids.py {} |
|
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * *'''.format(timestamp)) |
|
|
|
|
|
|
|
|
while True: |
|
|
while True: |
|
|
|
|
|
|
|
|
page = site.Pages['User:Trustinformationws/sandbox'] |
|
|
page = site.Pages['User:Trustinformationws/sandbox'] |
|
@ -20,6 +30,7 @@ while True: |
|
|
# model = 'damaging' |
|
|
# model = 'damaging' |
|
|
# model = 'goodfaith' |
|
|
# model = 'goodfaith' |
|
|
model = 'goodfaith draftquality' |
|
|
model = 'goodfaith draftquality' |
|
|
|
|
|
# model = 'wp10' |
|
|
|
|
|
|
|
|
cmd = "echo '{\"rev_id\": "+str(revid)+"}' | ores score_revisions https://ores.wikimedia.org enwiki "+model |
|
|
cmd = "echo '{\"rev_id\": "+str(revid)+"}' | ores score_revisions https://ores.wikimedia.org enwiki "+model |
|
|
# print(cmd) |
|
|
# print(cmd) |
|
@ -32,46 +43,59 @@ while True: |
|
|
result = json.loads(output) |
|
|
result = json.loads(output) |
|
|
# pprint(result) |
|
|
# pprint(result) |
|
|
|
|
|
|
|
|
if model == 'damaging': |
|
|
if result != previous_result: |
|
|
true = result['score']['damaging']['score']['probability']['true'] |
|
|
|
|
|
false = result['score']['damaging']['score']['probability']['false'] |
|
|
if model == 'damaging': |
|
|
x = '''\nLatest revid: {}. This edit is ... |
|
|
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 to be goodfaith, |
|
|
... {} likely badfaith.'''.format(revid, true, false) |
|
|
... {} likely badfaith.'''.format(revid, true, false) |
|
|
|
|
|
|
|
|
if model == 'draftquality': |
|
|
if model == 'draftquality': |
|
|
ok = result['score']['draftquality']['score']['probability']['OK'] |
|
|
ok = result['score']['draftquality']['score']['probability']['OK'] |
|
|
vandalism = result['score']['draftquality']['score']['probability']['vandalism'] |
|
|
vandalism = result['score']['draftquality']['score']['probability']['vandalism'] |
|
|
spam = result['score']['draftquality']['score']['probability']['spam'] |
|
|
spam = result['score']['draftquality']['score']['probability']['spam'] |
|
|
attack = result['score']['draftquality']['score']['probability']['attack'] |
|
|
attack = result['score']['draftquality']['score']['probability']['attack'] |
|
|
x = '''\nLatest revid: {}. It is ... |
|
|
x = '''\nLatest revid: {}. It is ... |
|
|
... {} likely to be OK, |
|
|
... {} likely to be OK, |
|
|
... {} likely to be vandalism, |
|
|
... {} likely to be vandalism, |
|
|
... {} likely to be spam, |
|
|
... {} likely to be spam, |
|
|
... {} likely to be an attack.'''.format(revid, ok, vandalism, spam, attack) |
|
|
... {} likely to be an attack.'''.format(revid, ok, vandalism, spam, attack) |
|
|
|
|
|
|
|
|
if model == 'goodfaith': |
|
|
if model == 'wp10': |
|
|
true = result['score']['goodfaith']['score']['probability']['true'] |
|
|
pprint(result) |
|
|
false = result['score']['goodfaith']['score']['probability']['false'] |
|
|
|
|
|
x = '''\nLatest revid: {}. This edit is ... |
|
|
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 to be goodfaith, |
|
|
... {} likely badfaith.'''.format(revid, true, false) |
|
|
... {} likely badfaith.'''.format(revid, true, false) |
|
|
|
|
|
|
|
|
if model == 'goodfaith draftquality': |
|
|
if model == 'goodfaith draftquality': |
|
|
true = result['score']['goodfaith']['score']['probability']['true'] |
|
|
true = result['score']['goodfaith']['score']['probability']['true'] |
|
|
false = result['score']['goodfaith']['score']['probability']['false'] |
|
|
false = result['score']['goodfaith']['score']['probability']['false'] |
|
|
ok = result['score']['draftquality']['score']['probability']['OK'] |
|
|
|
|
|
vandalism = result['score']['draftquality']['score']['probability']['vandalism'] |
|
|
ok = result['score']['draftquality']['score']['probability']['OK'] |
|
|
spam = result['score']['draftquality']['score']['probability']['spam'] |
|
|
vandalism = result['score']['draftquality']['score']['probability']['vandalism'] |
|
|
attack = result['score']['draftquality']['score']['probability']['attack'] |
|
|
spam = result['score']['draftquality']['score']['probability']['spam'] |
|
|
x = '''\nLatest revid: {}. It is ... |
|
|
attack = result['score']['draftquality']['score']['probability']['attack'] |
|
|
|
|
|
x = '''\nLatest revid: {}. |
|
|
|
|
|
The last edit is ... |
|
|
|
|
|
... {} likely to be goodfaith, |
|
|
|
|
|
... {} likely badfaith.\n |
|
|
|
|
|
The article quality ... |
|
|
... {} likely to be OK, |
|
|
... {} likely to be OK, |
|
|
... {} likely to be vandalism, |
|
|
... {} likely to be vandalism, |
|
|
... {} likely to be spam, |
|
|
... {} likely to be spam, |
|
|
... {} likely to be an attack.\n |
|
|
... {} likely to be an attack.\n'''.format(revid, ok, vandalism, spam, attack, true, false) |
|
|
... {} likely to be goodfaith, |
|
|
|
|
|
... {} likely badfaith.'''.format(revid, ok, vandalism, spam, attack, true, false) |
|
|
|
|
|
|
|
|
|
|
|
print(x) |
|
|
print(x) |
|
|
|
|
|
log.write(x) |
|
|
|
|
|
|
|
|
|
|
|
previous_result = result |
|
|
|
|
|
|
|
|
time.sleep(10) |
|
|
time.sleep(10) |
|
|
|
|
|
|
|
|
|
|
|
log.close() |
|
|