Lift Wing API/Reference/Get revscoring articletopic prediction
POST | /service/lw/inference/v1/models/{wiki}-articletopic:predict
|
---|
Get a score from the Revscoring Article Topic model (previously hosted on ORES) for a given Wiki revision id.
Note: For historical reasons, the articletopic model that is used for wikidata items uses a different URL scheme (item
instead of article
), thus the URI for wikidata is /service/lw/inference/v1/models/wikidatawiki-itemtopic:predict
.
Examples
curl
Anonymous access
# Get a score from the Revscoring Article Topic model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-articletopic:predict -X POST -d '{"rev_id": 12345}' -H "Content-type: application/json"
Logged in access
# Get a score from the Revscoring Article Topic model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-articletopic: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 Article Topic 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-articletopic: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 Article Topic model for the revision 12345 of English Wikipedia.
*/
const inferenceUrl = "https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-articletopic: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:arwiki (Arabic), cswiki (Czech), enwiki (English), euwiki (Basque), huwiki (Hungarian), hywiki (Armenian), kowiki (Korean), srwiki (Serbian), ukwiki (Ukrainian), viwiki (Vietnamese), wikidatawiki (Wikidata, see note above).
|
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": {
"articletopic": {
"version": "1.3.0"
}
},
"scores": {
"12345": {
"articletopic": {
"score": {
"prediction": [
"STEM.STEM*"
],
"probability": {
"Culture.Biography.Biography*": 0.0037221493203970753,
"Culture.Biography.Women": 0.0016274082204131065,
"Culture.Food and drink": 0.003869384114515742,
"Culture.Internet culture": 0.0027448342044452587,
"Culture.Linguistics": 0.0004704196841241876,
"Culture.Literature": 0.0029036128875354625,
"Culture.Media.Books": 0.000742678990345212,
"Culture.Media.Entertainment": 0.0989755577969651,
"Culture.Media.Films": 0.0031771755584005376,
"Culture.Media.Media*": 0.21201751150971165,
"Culture.Media.Music": 0.0009582260980479466,
"Culture.Media.Radio": 6.200606120337714e-05,
"Culture.Media.Software": 0.006069833295704291,
"Culture.Media.Television": 0.0015207772089172447,
"Culture.Media.Video games": 0.0005615093206567188,
"Culture.Performing arts": 0.0016136571753909768,
"Culture.Philosophy and religion": 0.005162001475415081,
"Culture.Sports": 0.006003766168026103,
"Culture.Visual arts.Architecture": 0.02932200170357891,
"Culture.Visual arts.Comics and Anime": 0.000367749742655391,
"Culture.Visual arts.Fashion": 0.0073053897003234405,
"Culture.Visual arts.Visual arts*": 0.045704381965926126,
"Geography.Geographical": 0.0035315512289540245,
"Geography.Regions.Africa.Africa*": 0.00483994316149668,
"Geography.Regions.Africa.Central Africa": 0.0004058831032942602,
"Geography.Regions.Africa.Eastern Africa": 8.202888604849657e-05,
"Geography.Regions.Africa.Northern Africa": 0.00014172395987364393,
"Geography.Regions.Africa.Southern Africa": 0.0008028449272043562,
"Geography.Regions.Africa.Western Africa": 0.000272816147365302,
"Geography.Regions.Americas.Central America": 0.00023176185775056676,
"Geography.Regions.Americas.North America": 0.0031703002857622485,
"Geography.Regions.Americas.South America": 0.000188786651678672,
"Geography.Regions.Asia.Asia*": 0.005622487337808649,
"Geography.Regions.Asia.Central Asia": 0.00035000790929257494,
"Geography.Regions.Asia.East Asia": 0.0033450611384150454,
"Geography.Regions.Asia.North Asia": 0.0004353985298481421,
"Geography.Regions.Asia.South Asia": 0.00020663669814920222,
"Geography.Regions.Asia.Southeast Asia": 0.00032506406741737574,
"Geography.Regions.Asia.West Asia": 0.001011685969040056,
"Geography.Regions.Europe.Eastern Europe": 0.0032436576651452653,
"Geography.Regions.Europe.Europe*": 0.004678418783680385,
"Geography.Regions.Europe.Northern Europe": 0.0003478676128337494,
"Geography.Regions.Europe.Southern Europe": 0.0023790437464152685,
"Geography.Regions.Europe.Western Europe": 0.001866188163881686,
"Geography.Regions.Oceania": 0.020499546152686617,
"History and Society.Business and economics": 0.006809005223678666,
"History and Society.Education": 0.0004626665847193515,
"History and Society.History": 0.003483860446308053,
"History and Society.Military and warfare": 0.0007483799946402382,
"History and Society.Politics and government": 0.04064941446684307,
"History and Society.Society": 0.0039896466301302305,
"History and Society.Transportation": 0.0021103679224344224,
"STEM.Biology": 0.0063757590084982845,
"STEM.Chemistry": 0.002592859482757056,
"STEM.Computing": 0.025968220954150065,
"STEM.Earth and environment": 0.004485463793376359,
"STEM.Engineering": 0.0007893097092528008,
"STEM.Libraries & Information": 0.0005542340017675382,
"STEM.Mathematics": 0.39109499414712584,
"STEM.Medicine & Health": 0.08689195662186826,
"STEM.Physics": 0.004884195584942447,
"STEM.STEM*": 0.9049354239597514,
"STEM.Space": 0.0002139344401835148,
"STEM.Technology": 0.07492699172495908
}
}
}
}
}
}
}
|
---|