wikibase-edit icon indicating copy to clipboard operation
wikibase-edit copied to clipboard

translation: QS ---> wikibase-edit JSON

Open rwst opened this issue 3 years ago • 7 comments

QuickStatements commands can be translated to JSON that is fed to the wd ee --batch (or create-entity) commaand by the user. Some commands may need an automated SPARQL query before translation. Still, such a tool would be valuable, if not for the reason that QS needs to be fixed, and no one wants to fix PHP.

rwst avatar Mar 20 '21 09:03 rwst

could you provide a sample of the QS JSON, with annotation of how it should be interpreted if there is anything non-trivial? (I have not worked with QS much, so I do need some guidance)

maxlath avatar Mar 20 '21 10:03 maxlath

It is not JSON but a simple command language made for the purpose, please see https://www.wikidata.org/wiki/Help:QuickStatements#Command_sequence_syntax

rwst avatar Mar 20 '21 11:03 rwst

This is exactly what I'm looking for! I'm developing a WikiCite (a Wikidata project) plugin for the reference management software Zotero, and I would like to provide a way of creating new Wikidata entities from Zotero items. Right now there is this QuickStatements translator that translates a Zotero item into QuickStatements commands. Having a way to translate these QS commands into wikibase-edit JSON, as suggested in this issue, would be ideal.

This PHP file, from QuickStatements source code, takes care of converting QS commands into MediaWiki API actions. I wonder if it may be useful to create the JS tool proposed.

diegodlh avatar Mar 31 '21 00:03 diegodlh

I started experimenting in a separate repo https://github.com/maxlath/quickstatements-to-wikibase-edit :

  • how practical would this approach be for your respective use-cases?
  • note the missing features section: those are due to those features being currently missing in wikibase-edit

maxlath avatar Apr 04 '21 20:04 maxlath

Amazing! This is exactly what I was looking for. I installed it through npm and tried it with a simple set of QS commands returned by Zotero's QuickStatements export translator:

CREATE
LAST	P31	Q13442814
LAST	Len	\"Test article\"
LAST	Den	\"journal article\"
LAST	P1476	en:\"Test article\"
LAST	P407	Q1860

However, convert.js is failing at line 34 with edit.claims is undefined. I guess this is because you are still experimenting with it.

I couldn't debug it because I may not have time to implement this new feature immediately, but I have already posted an issue in my plugin's repository to keep track of this and use it as soon as possible.

Thanks!!

diegodlh avatar Apr 05 '21 20:04 diegodlh

@diegodlh could you provide a sample of the input that fails to be converted?

maxlath avatar May 02 '21 07:05 maxlath

I finally found the time to look into this more closely today. I submitted a PR that seems to fix it.

With this fix, and other time-value-related fixes, I'm using this package in Cita and it seems to work like a charm to convert QuickStatements commands for basic publications (journal articles, etc) into a JSON that wikibase-edit can understand.

Thank you!!

diegodlh avatar May 23 '21 02:05 diegodlh