Wikidata:Requests for permissions/Bot/CC0-JS
The following discussion is closed. Please do not modify it. Subsequent comments should be made in a new section. A summary of the conclusions reached follows.
- Approved--Ymblanter (talk) 09:41, 24 May 2017 (UTC)[reply]
CC0-JS[edit]
CC0-JS (talk • contribs • new items • new lexemes • SUL • Block log • User rights log • User rights • xtools)
Operator: CC0 (talk • contribs • logs)
Task/s: Adding Tamil descriptions to items for which the translation is sure. The match is found using fixed strings, not RegEx.
Code:
Function details: This bot populates item descriptions with corresponding Tamil language one if a Tamil language one does not already exits and is not ambiguous. String matching is exact. The edits so far were done after manual confirmation through web interface (after human decisions on queried entries and queuing the list). It would be much more convenient to be able to make the edits faster without human decisions.
This script can possibly be extended to other languages like Sinhala. There are a lot of "exact match" entries which have strict 1-1 unambiguous translations from/to some other languages.
Sample code:
Get:
const sparql=`SELECT ?insect ?inesctLabel ?insectDescription (xsd:string(?insect) as ?iS)
WHERE {
?insect schema:description "species of insect"@en.
SERVICE wikibase:label { bd:serviceParam wikibase:language "ta". }
}
LIMIT 100`
…………………………………
var s = wdk.simplifySparqlResults (data);
var arr = [];
console.log(s);
s.forEach(function(v,k,a){if(!v.insectDescription){arr.push(v.insect)} else {console.log("Already exists: "); console.log(v);}})
Edit:
…………………………………
a.forEach(function(v,k,a){wdEdit.description.set(v, 'ta', 'பூச்சி இனம்'); sleep(10000);})
…………………………………
--CC0-JS (talk) 08:15, 16 May 2017 (UTC)[reply]
The reason for not using descriptioner is because a lot of these have 10000+ matches. Please note that this bot does not erase any existing entries; if an entry already exists, this script will not modify that particular description entry. This script also checks for it manually instead of placing the load on the SPARQL endpoint by#FILTER ()
...........
?insect schema:description ?description.
FILTER(LANG(?description) = "ta").
...........
SERVICE {bd:serviceParam wikibase:language [lang-tag]}