Get language agnostic articlequality prediction
POST | /service/lw/inference/v1/models/articlequality:predict
|
---|
The goal of this model is to predict/assess the quality of Wikipedia articles. Check the model card for more info.
Examples
curl
Anonymous access
# Get the quality score for an article on English Wikipedia identified by the revision id 123456.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/articlequality:predict -X POST -d '{"rev_id": 123456, "lang": "en"}' -H "Content-type: application/json"
Logged in access
# Get the quality score for an article on English Wikipedia identified by the revision id 123456.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/articlequality:predict -X POST -d '{"rev_id": 123456, "lang": "en"}' -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-type: application/json"
Python
# Python 3
# Get the quality score for an article on English Wikipedia identified by the revision id 123456.
import json
import requests
use_auth = False
inference_url = 'https://api.wikimedia.org/service/lw/inference/v1/models/articlequality: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": 123456, "lang": "en"}
response = requests.post(inference_url, headers=headers, data=json.dumps(data))
print(response.json())
JavaScript
/*
Get the quality score for an article on English Wikipedia identified by the revision id 123456.
*/
const inferenceUrl = "https://api.wikimedia.org/service/lw/inference/v1/models/articlequality: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": 123456, "lang": "en"};
fetch(inferenceUrl, {
method: "POST",
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(inferenceData => console.log(inferenceData));
POST Parameters
lang
required |
A string representing the language code related to the target wiki. Example: "en" for English Wikipedia. |
rev_id
required |
The revision id for the wiki identified by the lang parameter.
|
extended_output
|
Whether or not the response should include the extended output of the model. Either true or false. Default: false
The extended output includes the feature values used during inference as well as the output label. |
Responses
200 | Success: Returns a Articlequality Score object.
Example
{
"model_name": "articlequality",
"model_version": "1",
"wiki_db": "enwiki",
"revision_id": 123456,
"score": 0.10748992767177634,
"features":
{
"raw":
{
"characters": 625,
"refs": 0,
"wikilinks": 8,
"categories": 0,
"media": 0,
"headings": 0,
"sources": 0,
"infobox": false,
"messagebox": false
},
"normalized":
{
"characters": 0.2589179540286342,
"refs": 0.0,
"wikilinks": 0.2710334973090758,
"categories": 0.0,
"media": 0.0,
"headings": 0.0,
"sources": 0.0,
"infobox": false,
"messagebox": false
}
}
}
|
---|