addshore / wikicrowd

Tool for crowd sourced micro edits for Wikimedia
https://wikicrowd.toolforge.org/
MIT License
7 stars 4 forks source link

Allow marking an item as prominent #14

Open waldyrious opened 2 years ago

waldyrious commented 2 years ago

There could be a checkbox for "mark as prominent", or alternatively two green buttons: one for "Yes (prominent)" and one for "Yes (not prominent)". The second one could perhaps use a lighter shade of green.

The second approach would perhaps be more convenient to use because it would only require a single click per image.

addshore commented 2 years ago

I wonder if this should be implemented in the same question (with an extra button for prominent) Or only as a separate task?

Oer perhaps both?

waldyrious commented 2 years ago

As a user of the tool, I would expect them to be the same task, since the kind of judgment applied to reach the decision is very similar (i.e., I am already at times having to decide whether an image "clearly" depicts an item, because sometimes it is arguably present but in a very obscure manner).

addshore commented 2 years ago

Maybe options of

Might work?

waldyrious commented 2 years ago

Oh, that makes sense, yeah, since we don't really add a "prominent=no" qualifier when the item is not prominent in the image.

My only concern is whether it is not clear that "prominent" is a superset of "yes". Perhaps if they have the same color (e.g. different shades of green) it would be more evident. Or alternatively, my original suggestion of two green buttons labeled "Yes (prominent)" and "Yes (not prominent)" could also work.

addshore commented 2 years ago

my original suggestion of two green buttons labelled "Yes (prominent)" and "Yes (not prominent)" could also work.

Yeah, perhaps this is best! Would you want to give this a go?

waldyrious commented 2 years ago

Hmm, I'm not sure how I'd go about adding a qualifier to a statement using this codebase. I'd be happy to give it a go if you gave me some pointers.

addshore commented 2 years ago

First question, have you managed to get a local copy of the codebase running? If not I can also help you with that :)

And don't get overwhelmed by how much test I wrote here, any questions, just ask!

The code that currently adds the depicts statement is structured as a laravel job https://github.com/addshore/wikicrowd/blob/main/app/Jobs/AddDepicts.php

Specifically, here you can see (after a bunch of other logic) a statement gets created, with the depicts value, on the $mid https://github.com/addshore/wikicrowd/blob/main/app/Jobs/AddDepicts.php#L117-L132

Inside the addwiki library this currently makes use of the wbcreateclaim wikibase API module which unfortunately doesn't allow you to set the rank of a statement, (which is needed to make it as prominent) https://github.com/addwiki/addwiki/blob/main/packages/wikibase-api/src/Service/StatementCreator.php#L36-L59

We would need to use wbsetclaim https://www.wikidata.org/w/api.php?action=help&modules=wbsetclaim Which in the addwiki libraries can be accessed using the StatementSetter https://github.com/addwiki/addwiki/blob/bf50df609580ce99505533ff1efa567077035257/packages/wikibase-api/src/Service/StatementSetter.php#L25-L42

With this service, you need to create a Statement object, setting the mainsnak (we already have the mainsnak in the existing code) and also setting the rank to preffered. You can find the statement code here https://github.com/wmde/WikibaseDataModel/blob/master/src/Statement/Statement.php And here you can find the set rank method https://github.com/wmde/WikibaseDataModel/blob/master/src/Statement/Statement.php#L189-L206

So in summary

In order to create new GUIDS (which is needed for this method) you may find it useful to include the WikibaseDataModelService php library https://github.com/wmde/WikibaseDataModelServices/blob/master/src/Statement/GuidGenerator.php via composer (Perhaps I could abstract this away in the addwiki libraries... I'll add it to my list, hah!)