Closed dmcmilla closed 3 years ago
Using a unique value for the prop parameter for adding a claim seems to resolve this issue. I though that this value had to match the property identifier based on how the output of the wikibase API call to do the a similar creation.
I think you are right regarding the claims with multiple values. With current implementation of the claim-function we have to use extend
-function on lists, in order to add more values to the claim:
claims1 = claim(prop='P1', mainsnak=mainsnak1, qualifiers=qualifiers1, references=references1)
claims2 = claim(prop='P1', mainsnak=mainsnak2, qualifiers=qualifiers2, references=references2)
claims1['P1'].extend(claims2['P1'])
An alternative would be to rewrite the claim-function a bit and add a mainsnak-function. Then, the input for the claim-function would be the property and a list of mainsnaks.
I've added the mainsnak
and statement
functions. They can be used like this:
snak1 = snak(datatype='external-id', value='Q43229', prop='P1', snaktype='value')
snak2 = snak(datatype='external-id', value='Q5', prop='P1', snaktype='value')
mainsnak1 = mainsnak(prop='P1', snak=snak1, qualifiers=[], references=[])
mainsnak2 = mainsnak(prop='P1', snak=snak2, qualifiers=[], references=[])
statements = statement(prop='P1', mainsnaks=[mainsnak1, mainsnak2])
item = entity(labels=labels, aliases=aliases, descriptions=descriptions, claims=statements, etype='item')
If you try to add a new value to an existing statement of an item, only that new value is saved and other values are removed. From the datamodel, it looks like a new claim is hardcoded to have one element list of mainsnak, but a statement with multiple values would need the claim formatted so that there were a list of mainsnaks. If my assessment is incorrect, do you have any examples where multiple values are being loaded for the same statement of an item?