How to use the wikidataintegrator.wdi_core.ManualInterventionReqException function in wikidataintegrator

To help you get started, we’ve selected a few wikidataintegrator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
for i in results['results']['bindings']:
                    qid = i['item_id']['value'].split('/')[-1]
                    if ('mrt' not in i) or ('mrt' in i and i['mrt']['value'].split('/')[-1] == exact_qid):
                        tmp_qids.add(qid)

                qid_list.update(tmp_qids)

                # Protocol in what property the conflict arises
                if wd_property in conflict_source:
                    conflict_source[wd_property].append(tmp_qids)
                else:
                    conflict_source[wd_property] = [tmp_qids]

                if len(tmp_qids) > 1:
                    raise ManualInterventionReqException(
                        'More than one WD item has the same property value', wd_property, tmp_qids)

        if len(qid_list) == 0:
            self.create_new_item = True
            return ''

        if not __debug__:
            print(qid_list)

        unique_qids = set(qid_list)
        if len(unique_qids) > 1:
            raise ManualInterventionReqException('More than one WD item has the same property value',
                                                 conflict_source, unique_qids)
        elif len(unique_qids) == 1:
            return list(unique_qids)[0]
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
for i in results['results']['bindings']:
                                qid = i['item_id']['value'].split('/')[-1]
                                # remove 'Q' prefix
                                qid = qid[1:]
                                tmp_qids.append(qid)

                        qid_list.append(tmp_qids)

                        # Protocol in what property the conflict arises
                        if wd_property in conflict_source:
                            conflict_source[wd_property].append(tmp_qids)
                        else:
                            conflict_source[wd_property] = [tmp_qids]

                        if len(tmp_qids) > 1:
                            raise ManualInterventionReqException(
                                'More than one WD item has the same property value', wd_property, tmp_qids)

                except requests.HTTPError as e:
                    self.log('ERROR', str(e))

        qid_list = [i for i in itertools.chain.from_iterable(qid_list)]

        if len(qid_list) == 0:
            self.create_new_item = True
            return ''

        print(qid_list)

        unique_qids = set(qid_list)
        if len(unique_qids) > 1:
            raise ManualInterventionReqException('More than one WD item has the same property value',
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
conflict_source[wd_property] = [tmp_qids]

                if len(tmp_qids) > 1:
                    raise ManualInterventionReqException(
                        'More than one WD item has the same property value', wd_property, tmp_qids)

        if len(qid_list) == 0:
            self.create_new_item = True
            return ''

        if not __debug__:
            print(qid_list)

        unique_qids = set(qid_list)
        if len(unique_qids) > 1:
            raise ManualInterventionReqException('More than one WD item has the same property value',
                                                 conflict_source, unique_qids)
        elif len(unique_qids) == 1:
            return list(unique_qids)[0]
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
'More than one WD item has the same property value', wd_property, tmp_qids)

                except requests.HTTPError as e:
                    self.log('ERROR', str(e))

        qid_list = [i for i in itertools.chain.from_iterable(qid_list)]

        if len(qid_list) == 0:
            self.create_new_item = True
            return ''

        print(qid_list)

        unique_qids = set(qid_list)
        if len(unique_qids) > 1:
            raise ManualInterventionReqException('More than one WD item has the same property value',
                                                 conflict_source, unique_qids)
        elif len(unique_qids) == 1:
            return list(unique_qids)[0]
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
pn = new_stat.get_prop_nr()
                if new_stat == stat and pn in core_props_list:
                    if pn in match_count_per_prop:
                        match_count_per_prop[pn] += 1
                    else:
                        match_count_per_prop[pn] = 1

        core_prop_match_count = 0
        for x in match_count_per_prop:
            core_prop_match_count += match_count_per_prop[x]

        data_kv_pairs = ['{}:{}'.format(x.get_prop_nr(), x.get_value()) for x in self.data]
        statements_kv_pairs = ['{}:{}'.format(x.get_prop_nr(), x.get_value()) for x in self.statements]

        if core_prop_match_count < count_existing_ids * 0.66:
            raise ManualInterventionReqException('Retrieved item ({}) does not match provided core IDs. '
                                                 'Matching count {}, non-matching count {}'
                                                 .format(self.wd_item_id, core_prop_match_count,
                                                         count_existing_ids - core_prop_match_count),
                                                 'data Key values: {}'.format(data_kv_pairs),
                                                 'statement Key values: {}'.format(statements_kv_pairs))
        else:
            return True