Вікідані:Інструменти/WikibaseJS-cli
wikibase-cli, також відомий як WikibaseJS-cli або wikibase-cli (Q87194660) — інтерфейс командного рядка для Вікіданих або будь-якого іншого екземпляра Wikibase (Q16354758) на основі wikibase-edit. Його можна використовувати з терміналу як альтернативний інтерфейс до інтерфейсу веб-браузера або в скриптах для запуску багатьох редагувань.
Як зазначено в назві, WikibaseJS-cli написаний на JavaScript (Q2005), щоб запускатися як процес Node.js (Q756100). Таким чином, цей процес можна запустити в будь-якому середовищі, де можна встановити Node.js (Q756100), або як альтернативу в контейнері Docker, див. документацію для встановлення.
Документація
Див. документацію
Приклади
Документація на https://github.com/maxlath/wikibase-cli містить багато прикладів. Також є ще кілька прикладів коду на
- https://github.com/maxlath/wikibase-cli-template-collection
- https://github.com/maxlath/wikidata-scripting
Кілька додаткових прикладів є нижче.
Мітки та описи
- додати мітку
wd set-label Q89208827 en "Aellopus Saxum"
- додати опис
wd set-description Q89208827 en "saxum on asteroid 101955 Bennu"
Додавання тверджень
- додати твердження (просто)
wd ac Q75887503 P735 Q18009833
- додати твердження (просто, з описом редагування)
wd ac Q96817942 P921 Q11558 --summary 'adding claim [[Property:P921]]: [[Q11558]]'
- додати твердження (просто, використовуючи шаблон)
крок #1: створити файл "givenname.js" з таким вмістом:
module.exports = (qid, gn) => {
return {
id: qid,
claims: { P735: { value: gn } },
summary: "adding claim [[Property:P735]]: [[" + gn + "]]"
}
}
крок #2: перевірити файл (редагування не виконується):
wd ee givenname.js Q75887503 Q18009833 --dry
крок #3: виконати його (Вікідані редагуються):
wd ee givenname.js Q75887503 Q18009833
- add a statement (complex with special somevalue, qualifier and reference, using a template)
step #1: create a file "templatehay.js" with the following:
module.exports = (qid, hay, color) => {
return {
id: qid,
claims: {
P2827: {
"snaktype":"somevalue",
// value: "Q53569537",
qualifiers: { P1932: color },
references: [ { P248: 'Q96634446', P8662: hay } ]
}
} ,
summary: "adding claim [[Property:P2827]]: " + color + " from [[Q96634446|L'Haÿ]]"
}
}
step #2: test it with (no edit is done):
wd ee templatehay.js Q60964601 1837 "rose vif" --dry
step #3: run it with (edits Wikidata):
wd ee templatehay.js Q60964601 1837 "rose vif"
Створення елементів
- створити елементи, схожі на інший елемент
step #1: create a template file based on suitable sample (here Q100700188)
wd generate-template --create-mode Q100700188 > Qianguimon.js
step #2: open file |
step #3: edit it into a template |
module.exports = function () {
return {
type: 'item',
labels: {
en: 'Qianguimon elongatum',
nl: 'Qianguimon elongatum'
},
descriptions: {
en: 'species of crustacean',
nl: 'taxon'
},
aliases: {},
claims: {
// instance of: taxon
P31: 'Q16521',
// taxon name
P225: 'Qianguimon elongatum',
// taxon rank: species
P105: 'Q7432',
// parent taxon: Qianguimon
P171: 'Q100605554',
// WoRMS-ID for taxa
P850: '1062897'
},
sitelinks: {}
}
}
|
module.exports = function (name, identifier) {
return {
type: 'item',
labels: {
en: name,
nl: name
},
descriptions: {
en: 'species of crustacean',
nl: 'taxon'
},
aliases: {},
claims: {
// instance of: taxon
P31: 'Q16521',
// taxon name
P225: name,
// taxon rank: species
P105: 'Q7432',
// parent taxon: Qianguimon
P171: 'Q100605554',
// WoRMS-ID for taxa
P850: identifier
},
sitelinks: {}
}
}
|
step #4: create similar ones using that template:
wd ce Qianguimon.js "Qianguimon rongxianense" 1389612
step #5: check result
- This could have been: Q100700189
- створити елемент на основі готового шаблону
step #1: copy latinscriptfemalegivenname.js to your cli directory
step #2: use it
wd ce latinscriptfemalegivenname.js "Clarenza"
step #3: check the result
- This could have been: Q100967811
Код
- Репозиторій: https://github.com/maxlath/wikibase-cli
- Ліцензія: MIT
Проблеми
To signal a bug or ask for help, you can open an issue at https://github.com/maxlath/wikibase-cli/issues.
Список редагувань
Edits done by wikibase-edit use the WikibaseJS-cli
tag by default, which allows to get a list of edits done this way:
WikibaseJS-cli
in Recent Changes.
When using the batch mode, edits are grouped in EditGroups.
Userbox
Babel user information | ||
---|---|---|
| ||
Users by language |
You can share your love for this tool by displaying a userbox on your user page: add {{#babel:Wikibase CLI}}
Список користувачів: Category:Wikibase CLI user