Page MenuHomePhabricator

API: Support editing statements on senses via wbeditentity
Open, HighPublic8 Estimated Story Points

Description

As an API user I want to be able to edit statements on Sensess through wbeditentity in order to quickly add/modify/remove data.

Problem:
Currently editing of statements on Senses is not supported via wbeditentity.

Example:
TBA

BDD

GIVEN I make a wbeditentity API request with the "claims" key set within a sense's JSON
WHEN  I submit the request
THEN  the sense's statements are modified accordingly

Acceptance criteria:

  • statements are saved persistently
  • edit summary shows up in recent changes/Lexeme history/watchlist
  • statements contain a GUID that is correctly prefixed with the sense id they describe (compare)

Notes:

  • This was done for Forms in T194732

Event Timeline

Might possibly be considered a duplicate of T196298.

WMDE-leszek renamed this task from Support editing senses via wbeditentity to Support editing statements on senses via wbeditentity.Aug 21 2018, 11:30 AM
WMDE-leszek updated the task description. (Show Details)
Lydia_Pintscher renamed this task from Support editing statements on senses via wbeditentity to API: Support editing statements on senses via wbeditentity.Sep 2 2018, 4:04 PM

@Addshore @Lucas_Werkmeister_WMDE: the ticket Leszek mentioned as a possible duplicate is closed. Where are we with this?

This still does not work (just checked on testwikidata).

I checked and confirmed this with id=lexeme and trying to update a statement in a sense on the lexeme
I also checked this with id=sense trying to update a statement in the sense json.

I expect the individual cases as described in T196298 are all covered however.

Shouldn't this be a higher priority? It's a blocker for Wiktionary imports and assisted editing, two big sources of growth.

Lydia_Pintscher raised the priority of this task from Medium to High.Feb 1 2021, 4:32 PM

True. Changing to high.

Question: is the problem occurring only on Senses, or also on Forms?

@Lea_Lacroix_WMDE I have recently (a few weeks ago) tested all possible lexeme edit operations. The only thing that does not work is editing statements on senses. Senses themselves can be created, but any sense statements in the edit request are ignored.

Change 668709 had a related patch set uploaded (by Jakob; owner: Jakob):
[mediawiki/extensions/WikibaseLexeme@master] wbeditentity: add test for adding a Form statement

https://gerrit.wikimedia.org/r/668709

Change 668710 had a related patch set uploaded (by Jakob; owner: Jakob):
[mediawiki/extensions/WikibaseLexeme@master] Support editing statements on senses via wbeditentity

https://gerrit.wikimedia.org/r/668710

Change 670218 had a related patch set uploaded (by Jakob; owner: Jakob):
[mediawiki/extensions/WikibaseLexeme@master] EditFormChangeOpDeserializerTest: refactor for readability

https://gerrit.wikimedia.org/r/670218

Change 670218 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] EditFormChangeOpDeserializerTest: refactor for readability

https://gerrit.wikimedia.org/r/670218

Change 668709 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] wbeditentity: add test for adding a Form statement

https://gerrit.wikimedia.org/r/668709

Change 668710 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Support editing statements on senses via wbeditentity

https://gerrit.wikimedia.org/r/668710

@Addshore Can you test and resolve this ticket ?
Thanks!!

I would like to assemble a JSON string with which to generate a lexeme using a single wbeditentity call.

JSON strings of the following form did work prior to this change (with no statements on forms or senses):

{"lexicalCategory": "Q34698", "language": "Q9610", "type": "lexeme",
 "lemmas": {"bn": {"value": "\u09a6\u09cd\u09b0\u09c1\u09a4", "language": "bn"}},
 "forms": [{"representations": {"bn": {"value": "\u09a6\u09cd\u09b0\u09c1\u09a4", "language": "bn"}}, "grammaticalFeatures": ["Q3482678"], "add": ""}],
 "senses": [{"glosses": {"bn": {"value": "\u09aa\u09cd\u09b0\u09a5\u09ae \u0985\u09b0\u09cd\u09a5", "language": "bn"}}, "add": ""}]}

After the deployment of wmf.35 to Wikidata I tried to add statements (with qualifiers, if that matters) to a sense using a similar JSON string:

{"lexicalCategory": "Q34698", "language": "Q33173", "type": "lexeme",
 "lemmas": {"ctg": {"value": "\u0985\u0993\u09a1\u09cd\u09af\u09be", "language": "ctg"}},
 "forms": [{"representations": {"ctg": {"value": "\u0985\u0993\u09a1\u09cd\u09af\u09be", "language": "ctg"}}, "grammaticalFeatures": ["Q3482678"], "add": ""}],
 "senses": [{"glosses": {"bn": {"value": "\u098f\u09a4 \u09ac\u09a1\u09bc", "language": "bn"}}, "add": "",
    "claims": [{"type": "statement", "mainsnak": {"snaktype": "value", "property": "P1343", "datatype": "wikibase-item", "datavalue": {"value": {"entity-type": "item", "numeric-id": 25586900, "id": "Q25586900"}, "type": "wikibase-entityid"}}, "rank": "normal",
      "qualifiers": [{"snaktype": "value", "property": "P304", "datatype": "string", "datavalue": {"value": "1", "type": "string"}}], "qualifiers-order": ["P304"]}]}]}

but am being greeted with "Statement GUID can not be parsed". After some tinkering around to try to make something happen, a lexeme did get created as L447292 (albeit without the sense); trying to add just the sense with the statement to that lexeme using wbeditentity is greeting me with the same message. It remains possible, however, to add statements to forms in a new lexeme using a single wbeditentity call.

It is clearly possible to assemble entire items in a single go (that's at least what QuickStatements is able to do); here's hoping this will soon be entirely possible with lexemes.

@Lydia_Pintscher @amy_rc the ACs / BDD is perhaps slightly unclear here. Is it expected that this should only work the ID being editied via wbeditentity is a sense ID? or also if it is a lexeme ID?

I would say we should support the case Mahir is talking about where you provide the whole Lexeme content including Senses and statements on Senses. If we support this for Forms and other entity types I don't think it makes sense to not support this for Senses and just causes issues as Mahir pointed out.

I just tested editing sense statements using patched Wikidata Toolkit. All parts of the lexeme are now editable via wbeditentity. Senses can be edited either as part of the lexeme or on their own. I have not tested more complex edit operations like the one @Mahir256 mentioned.