Lift Wing API/Reference/Get revscoring draftquality prediction
POST | /service/lw/inference/v1/models/{wiki}-draftquality:predict
|
---|
Get a score from the Revscoring Draft Quality model (previously hosted on ORES) for a given Wiki revision id.
Examples
curl
Anonymous access
# Get a score from the Revscoring Draft Quality model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-draftquality:predict -X POST -d '{"rev_id": 12345}' -H "Content-type: application/json"
Logged in access
# Get a score from the Revscoring Draft Quality model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-draftquality:predict -X POST -d '{"rev_id": 12345}' -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-type: application/json"
Python
# Python 3
# Get a score from the Revscoring Draft Quality model for the revision 12345 of English Wikipedia.
import json
import requests
use_auth = False
inference_url = 'https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-draftquality:predict'
if use_auth:
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)',
'Content-type': 'application/json'
}
else:
headers = {}
data = {"rev_id": 12345 }
response = requests.post(inference_url, headers=headers, data=json.dumps(data))
print(response.json())
JavaScript
/*
Get a score from the Revscoring Draft Quality model for the revision 12345 of English Wikipedia.
*/
const inferenceUrl = "https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-draftquality:predict";
const accessToken = "YOUR_ACCESS_TOKEN";
const appName = "YOUR_APP_NAME";
const email = "YOUR_EMAIL_OR_CONTACT_PAGE";
let headers = new Headers({
"Content-Type": "application/json",
"Authorization": "Bearer " + accessToken,
"Api-User-Agent": appName + " ( " + email + " )"
});
let data = {"rev_id": 12345 };
fetch(inferenceUrl, {
method: "POST",
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(inferenceData => console.log(inferenceData));
URI Parameters
wiki
required |
Wiki code:enwiki (English) or ptwiki (Portuguese).
|
POST Parameters
rev_id
required |
Wiki Revision id: integer related to a certain revision id for the Wiki set in the URI parameter. |
extended_output
|
Whether or not the response should include the extended output of the model (like the list of features used etc..). Either true or false. Default: false |
Responses
200 | Success: Revision id found. Returns a Revscoring score object.
Example
{
"enwiki": {
"models": {
"draftquality": {
"version": "0.2.1"
}
},
"scores": {
"12345": {
"draftquality": {
"score": {
"prediction": "spam",
"probability": {
"OK": 0.2058707138961481,
"attack": 0.08356921917837876,
"spam": 0.39768296325893626,
"vandalism": 0.31287710366653687
}
}
}
}
}
}
}
|
---|