Skip to content

Commit

Permalink
removed PMID check for evaluation of good reference
Browse files Browse the repository at this point in the history
  • Loading branch information
sebotic committed Sep 22, 2017
1 parent 638009b commit ca9f1ca
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions wikidataintegrator/wdi_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, wd_item_id='', item_name='', domain='', data=None, server='ww
references can hold only one value for one property. The number of good reference blocks is not limited.
This parameter OVERRIDES any other reference mode set!!
:type good_refs: list containing dictionaries.
:param keep_good_ref_statements: Do not delete any statement which has a good reference, either definded in the
:param keep_good_ref_statements: Do not delete any statement which has a good reference, either defined in the
good_refs list or by any other referencing mode.
:type keep_good_ref_statements: bool
:param search_only: If this flag is set to True, the data provided will only be used to search for the
Expand Down Expand Up @@ -426,7 +426,7 @@ def handle_qualifiers(old_item, new_item):

def is_good_ref(ref_block):

if len(WDItemEngine.databases) == 0 or len(WDItemEngine.pmids) == 0:
if len(WDItemEngine.databases) == 0:
WDItemEngine._init_ref_system()

prop_nrs = [x.get_prop_nr() for x in ref_block]
Expand Down Expand Up @@ -454,7 +454,7 @@ def is_good_ref(ref_block):
ref_properties = ['P248', 'P1476', 'P813'] # 'P407' language of work,

for v in values:
if prop_nrs[values.index(v)] == 'P248' and v in WDItemEngine.pmids:
if prop_nrs[values.index(v)] == 'P248':
return True
elif v == 'P698':
return True
Expand Down Expand Up @@ -1164,25 +1164,25 @@ def _init_ref_system():
if 'wd_prop' in x:
WDItemEngine.databases[db_qid].append(x['wd_prop']['value'].split('/')[-1])

count = 0

while True:
pmid_query = '''
SELECT DISTINCT ?x WHERE {{
?x wdt:P698 [] .
}}
OFFSET {0}
LIMIT 500000
'''

results = WDItemEngine.execute_sparql_query(pmid_query.format(count * 100000))['results']['bindings']
count += 1

if len(results) == 0:
break

for x in results:
WDItemEngine.pmids.append(x['x']['value'].split('/')[-1])
# count = 0
#
# while True:
# pmid_query = '''
# SELECT DISTINCT ?x WHERE {{
# ?x wdt:P698 [] .
# }}
# OFFSET {0}
# LIMIT 500000
# '''
#
# results = WDItemEngine.execute_sparql_query(pmid_query.format(count * 500000))['results']['bindings']
# count += 1
#
# if len(results) == 0:
# break
#
# for x in results:
# WDItemEngine.pmids.append(x['x']['value'].split('/')[-1])

@staticmethod
def delete_items(item_list, reason, login, user_agent=config['USER_AGENT_DEFAULT']):
Expand Down

0 comments on commit ca9f1ca

Please sign in to comment.