Comments (8)
Thank you very much for the patience you've had with me.
This time I was successful, I am able to run the commands:
https://www.wikidata.org/w/index.php?title=Q130081&diff=prev&oldid=1764295342
Please let me summarize the required steps I needed to take (for my future reference):
- run Powershell as admin. need to have chocolatey+jq and chocolatey+git installed there and wikibase-cli (if not working, also try installing wikibase-sdk package too).
- go to working folder, eg. Downloads in my case
- clone the template collection and install npm there like this
git clone https://github.com/maxlath/wikibase-cli-template-collection --branch update-multiple-statements
cd ./wikibase-cli-template-collection
npm install
-
put the update_multiple_statements.js and the query.rq file into the "wikibase-cli-template-collection" folder
-
(optional) check that the query is working as it should, outputting a correct file:
wd sparql ./query.rq | jq '.[]' -cr > ./results.ndjson
- run the following command:
wd sparql query.rq | jq '.[]' -cr | wd edit-entity update_multiple_statements.js --batch --summary 'updating P1082 statements - rank and date precision'
That's hopefully all.
Thank you again @maxlath
from wikibase-cli.
Yes it is possibe! 😁 See https://www.wikidata.org/w/index.php?title=Q117523&type=revision&diff=1763048325&oldid=1762491473
With
- the request at https://w.wiki/5u9R in
./query.rq
update_multiple_statements.js
and its dependencies
wd sparql ./query.rq | jq '.[]' -cr > ./results.ndjson
cat results.ndjson | wd edit-entity /path/to/wikibase-cli-template-collection/edit/edit_multiple_statements.js --batch --summary 'updating P1082 statements'
from wikibase-cli.
Very cool! 👍 This looks promising and now I know which part of the instructions I need to pay attention to, and what kinds of scripts I need to hack from your example collection :))
I tried but... jq and cat are probably not available on Windows.
I wonder if there is a Windows-friendly way to do this?
from wikibase-cli.
- jq should be available on Windows: https://stedolan.github.io/jq/download/
- there is a discussion here about how to substitute
cat
, but you could also just directly pipe the first line to the second:wd sparql ./query.rq | jq '.[]' -cr | wd edit-entity /path/to/wikibase-cli-template-collection/edit/edit_multiple_statements.js --batch --summary 'updating P1082 statements'
(but then you can't control what you got from the query before doing the edits)
Otherwise, could you maybe use Windows Subsystem for Linux
? (I never used it, so I don't know if that works, but I don't see why that wouldn't)
from wikibase-cli.
Thanks, I am almost there, I think!
Powershell install of wikibase-cli does not seem to install dependencies.
I had to manually install wikibase-sdk but it's still asking for some libraries:
"Error: Cannot find module '../lib/helpers'"
from wikibase-cli.
I guess those are the helpers from wikibase-cli-template-collection
on the update-multiple-statements
that you have to get locally too. I guess it could make sense to package some helpers with wikibase-cli itself, but I haven't explored that option much yet
from wikibase-cli.
Sorry, I don't really know what "getting it locally means" and what is "it".
I was playing with it and I think I was able to get it working by pointing to the file like this:
const { getEntityClaims } = require('C:/Users/vojte/AppData/Roaming/npm/node_modules/wikibase-cli-templates/lib/helpers')
But now I get a different error:
TypeError: getEntityClaims is not a function
The full response is:
PS C:\Users\vojte\Downloads> wd sparql query.rq | jq '.[]' -cr | wd edit-entity update_multiple_statements.js --batch --summary 'updating P1082 statements - rank and date precision'
edit group: https://tools.wmflabs.org/editgroups/b/wikibase-cli/e120709cd0983/
processing line 1: {"item":"Q122690","s1":"Q122690$0A238085-79C0-465D-BD6E-5898BC61B8E7","s2":"Q122690$13B3D94B-9A6C-4D83-8C1C-1278A812B259"}
TypeError: getEntityClaims is not a function
at module.exports (C:\Users\vojte\Downloads\update_multiple_statements.js:7:30)
at getDataFromJsModule (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\lib\object_arg_parser.js:63:12)
at getData (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\lib\object_arg_parser.js:38:14)
at Command.module.exports [as customArgsParser] (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\lib\object_arg_parser.js:9:16)
at runOnce (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\lib\edit\edit_command.js:67:20)
at Stream. (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\lib\edit\edit_command.js:159:15)
at Stream.emit (node:events:390:28)
at drain (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\node_modules\through\index.js:36:16)
at Stream.stream.queue.stream.push (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\node_modules\through\index.js:45:5)
at emit (C:\Users\vojte\AppData\Roaming\npm\node_modules\wikibase-cli\node_modules\split\index.js:37:14)
from wikibase-cli.
By getting it locally, I meant having the files on which the JS template depends on your machine (="locally"). You can do that with git:
git clone https://github.com/maxlath/wikibase-cli-template-collection --branch update-multiple-statements
cd ./wikibase-cli-template-collection
npm install
wd sparql /path/to/query.rq | jq '.[]' -cr | wd edit-entity ./edit/update_multiple_statements.js --batch --summary 'updating P1082 statements - rank and date precision'
from wikibase-cli.
Related Issues (20)
- set-sitelink does not work on redirecting articles HOT 2
- wd search --type property does not find property HOT 4
- Use OAuth2 so users do not have to create their own owner-only OAuth consumers
- `wb sparql`: Support reading from stdin
- Add the ability to get the Wikidata IDs for multiple Wikipedia articles
- stray argument in static js object example HOT 5
- Error: invalid id -make less verbose
- Bad token error HOT 4
- Some qualifiers probably cannot be removed
- wikibase-cli 17.0.0 build issue HOT 2
- support custom datatypes HOT 4
- wb search: --properties results get ignored when --json is specified
- removing qualifier in lexeme form, invalid guid HOT 1
- Updating claim does not load the current timezone in time-datatype properties HOT 6
- I can't install in paws HOT 7
- breaking change in date richvalues in 17.x? HOT 3
- wd sparql -f csv triggers JSON SyntaxError HOT 1
- error in version 17.0 and above HOT 1
- I got "invalid language: C" HOT 2
- `wikibase-api-not-recognized-language` when trying to copy entities from Wikidata HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wikibase-cli.