@@ -128,44 +128,46 @@ def load_statements(self, claims: Union[List[Claim], Claims, Claim], cache: Opti
128128 self .data [prop_nr ] = {}
129129
130130 while True :
131- # if claim.mainsnak.datavalue:
132- # query = '''
133- # #Tool: WikibaseIntegrator wbi_fastrun.load_statements
134- # SELECT ?entity ?sid ?value ?property_type WHERE {{
135- # # Base filter string
136- # {base_filter_string}
137- # ?entity <{wb_url}/prop/{prop_nr}> ?sid.
138- # <{wb_url}/entity/{prop_nr}> wikibase:propertyType ?property_type.
139- # ?sid <{wb_url}/prop/statement/{prop_nr}> ?value.
140- # ?sid <{wb_url}/prop/statement/{prop_nr}> {value}.
141- # {qualifiers_filter_string}
142- # }}
143- # ORDER BY ?sid
144- # OFFSET {offset}
145- # LIMIT {limit}
146- # '''
147- #
148- # # Format the query
149- # query = query.format(base_filter_string=base_filter_string, wb_url=wb_url, prop_nr=prop_nr, offset=str(offset), limit=str(limit),
150- # value=claim.get_sparql_value(wikibase_url=wb_url), qualifiers_filter_string=qualifiers_filter_string)
151- # else:
152- query = '''
153- #Tool: WikibaseIntegrator wbi_fastrun.load_statements
154- SELECT ?entity ?sid ?value ?property_type WHERE {{
155- # Base filter string
156- {base_filter_string}
157- ?entity <{wb_url}/prop/{prop_nr}> ?sid.
158- <{wb_url}/entity/{prop_nr}> wikibase:propertyType ?property_type.
159- ?sid <{wb_url}/prop/statement/{prop_nr}> ?value.
160- {qualifiers_filter_string}
161- }}
162- ORDER BY ?sid
163- OFFSET {offset}
164- LIMIT {limit}
165- '''
166-
167- # Format the query
168- query = query .format (base_filter_string = base_filter_string , wb_url = wb_url , prop_nr = prop_nr , offset = str (offset ), limit = str (limit ), qualifiers_filter_string = qualifiers_filter_string )
131+ if claim .mainsnak .datavalue and not cache :
132+ query = '''
133+ #Tool: WikibaseIntegrator wbi_fastrun.load_statements
134+ SELECT ?entity ?sid ?value ?property_type WHERE {{
135+ # Base filter string
136+ {base_filter_string}
137+ ?entity <{wb_url}/prop/{prop_nr}> ?sid.
138+ <{wb_url}/entity/{prop_nr}> wikibase:propertyType ?property_type.
139+ ?sid <{wb_url}/prop/statement/{prop_nr}> ?value.
140+ ?sid <{wb_url}/prop/statement/{prop_nr}> {value}.
141+ {qualifiers_filter_string}
142+ }}
143+ ORDER BY ?sid
144+ OFFSET {offset}
145+ LIMIT {limit}
146+ '''
147+
148+ # Format the query
149+ query = query .format (base_filter_string = base_filter_string , wb_url = wb_url , prop_nr = prop_nr , offset = str (offset ), limit = str (limit ),
150+ value = claim .get_sparql_value (wikibase_url = wb_url ), qualifiers_filter_string = qualifiers_filter_string )
151+ else :
152+ query = '''
153+ #Tool: WikibaseIntegrator wbi_fastrun.load_statements
154+ SELECT ?entity ?sid ?value ?property_type WHERE {{
155+ # Base filter string
156+ {base_filter_string}
157+ ?entity <{wb_url}/prop/{prop_nr}> ?sid.
158+ <{wb_url}/entity/{prop_nr}> wikibase:propertyType ?property_type.
159+ ?sid <{wb_url}/prop/statement/{prop_nr}> ?value.
160+ {qualifiers_filter_string}
161+ }}
162+ ORDER BY ?sid
163+ OFFSET {offset}
164+ LIMIT {limit}
165+ '''
166+
167+ # Format the query
168+ # TODO: Add custom query support
169+ query = query .format (base_filter_string = base_filter_string , wb_url = wb_url , prop_nr = prop_nr , offset = str (offset ), limit = str (limit ),
170+ qualifiers_filter_string = qualifiers_filter_string )
169171
170172 offset += limit # We increase the offset for the next iteration
171173 results = execute_sparql_query (query = query , endpoint = self .sparql_endpoint_url )['results' ]['bindings' ]
0 commit comments