Page MenuHomePhabricator

claimit.py: enable claim with the same property, but different value
Closed, ResolvedPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/feature-requests/349/
Reported by: apac1
Created on: 2013-09-15 16:15:03.602000
Subject: claimit.py: enable claim with the same property, but different value
Original labels: claimit.py, wikidata, enhancement, python, pywikibotOriginal description:
The below can be added to claimit.py to enable adding statements on items with the same property, but different values.

https://github.com/wikimedia/pywikibot-core/blob/master/scripts/claimit.py

:::python

for claim in self.claims:
    if claim.getID() in item.get().get('claims'):
        propertytoadd = claim.getID()
        for valueofproperty in item.claims[propertytoadd]:
            if valueofproperty.getTarget() == claim.getTarget():
                pywikibot.output("item for %s has already property %s with value %s" % (page.title(), propertytoadd, valueofproperty.getTarget()))
                break
            else:
                continue
        else:
            pywikibot.output('Adding additional %s --> %s' % (claim.getID(), claim.getTarget()))
            item.addClaim(claim)
        
    else:
        pywikibot.output('Adding %s --> %s'
                         % (claim.getID(), claim.getTarget()))
        item.addClaim(claim)

Version: unspecified
Severity: enhancement
Whiteboard: gci2013 https://www.mediawiki.org/wiki/Google_Code-In#Candidate_tasks

Details

Reference
bz54415

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 2:07 AM
bzimport set Reference to bz54415.
bzimport added a subscriber: Unknown Object (????).

slightly improved version, merged with the new "source" function

:::python

for claim in self.claims:
    if claim.getID() in item.get().get('claims'):
        for existingclaimwithproperty in item.claims[claim]:
            if existingclaimwithproperty.getTarget() == claim.getTarget():
                pywikibot.output("item for %s has already property %s with value %s" % (page.title(), claim, existingclaimwithproperty.getTarget()))
                break
            else:
                continue
        else:
            pywikibot.output('Adding additional %s --> %s' % (claim.getID(), claim.getTarget()))
            item.addClaim(claim)
            source = self.getSource(page.site.language())
            if self.source:
                claim.addSource(self.source, bot=True)
                # TODO FIXME: We need to check that we aren't adding a
                # duplicate source

    else:
        pywikibot.output('Adding %s --> %s'
                         % (claim.getID(), claim.getTarget()))
        item.addClaim(claim)
        source = self.getSource(page.site.language())
        if self.source:
            claim.addSource(self.source, bot=True)
        # TODO FIXME: We need to check that we aren't adding a
        # duplicate source

Change 92073 had a related patch set uploaded by Merlijn van Deen:
Enable adding statements on items with the same property, but different values.

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

Change 97198 had a related patch set uploaded by Tholam:
Enable claims with the same property, but different value for claimit.py

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

Change 92073 abandoned by Merlijn van Deen:
Enable adding statements on items with the same property, but different values.

Reason:
One of the GCI students has worked on this: https://gerrit.wikimedia.org/r/#/c/97198/

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

Change 97198 merged by jenkins-bot:
Enable claims with the same property, but different value for claimit.py

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

  • Bug 54542 has been marked as a duplicate of this bug. ***

Change 92073 restored by John Vandenberg:
Enable adding statements on items with the same property, but different values.

Reason:
The GCI code didnt check for duplicates like APAC's code does

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

Change 92073 abandoned by John Vandenberg:
Enable adding statements on items with the same property, but different values.

Reason:
My bad, yes it did.

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

jayvdb subscribed.

Unfortunately, we have many bugs about this, and the root of the problem was the addition of 'qualifier' and 'source' to the design.
I am using T69284 as the spot to fix this.

jayvdb claimed this task.

Sorry; didnt mean to re-open it.