Code Monkey home page Code Monkey logo

Comments (8)

VojtechDostal avatar VojtechDostal commented on September 23, 2024 1

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):

  1. 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).
  2. go to working folder, eg. Downloads in my case
  3. 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

  1. put the update_multiple_statements.js and the query.rq file into the "wikibase-cli-template-collection" folder

  2. (optional) check that the query is working as it should, outputting a correct file:

wd sparql ./query.rq | jq '.[]' -cr > ./results.ndjson

  1. 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.

maxlath avatar maxlath commented on September 23, 2024

Yes it is possibe! 😁 See https://www.wikidata.org/w/index.php?title=Q117523&type=revision&diff=1763048325&oldid=1762491473

With

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.

VojtechDostal avatar VojtechDostal commented on September 23, 2024

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.

maxlath avatar maxlath commented on September 23, 2024

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.

VojtechDostal avatar VojtechDostal commented on September 23, 2024

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.

maxlath avatar maxlath commented on September 23, 2024

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.

VojtechDostal avatar VojtechDostal commented on September 23, 2024

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.

maxlath avatar maxlath commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.