--- a/src/hdalab/management/commands/query_geo_inclusion.py Fri Jun 20 17:04:51 2014 +0200
+++ b/src/hdalab/management/commands/query_geo_inclusion.py Tue Jun 24 16:58:34 2014 +0200
@@ -4,7 +4,7 @@
@author: raphv
'''
-
+from django.conf import settings
from django.core.management.base import NoArgsCommand
from django.core.management.color import no_style
from hdabo.utils import show_progress
@@ -20,22 +20,31 @@
qs = Tag.objects.filter(category__label="Localisation").exclude(dbpedia_uri = None)
total = qs.count()
- endpoint = SPARQLWrapper("http://dbpedia.org/sparql")
+ #endpoint = SPARQLWrapper("http://dbpedia.org/sparql")
+ endpoint = SPARQLWrapper(settings.DBPEDIA_URI_TEMPLATE % ( 'sparql', '' ))
endpoint.setReturnFormat(JSON)
+# sparqltext = """
+# SELECT ?resource WHERE {
+# { <%s> ?resource <http://dbpedia.org/ontology/Country> . }
+# UNION
+# { <%s> <http://dbpedia.org/ontology/country> ?resource . }
+# }
+# """
sparqltext = """
SELECT ?resource WHERE {
- { <%s> ?resource <http://dbpedia.org/ontology/Country> . }
+ { <%s> ?resource <%s> . }
UNION
- { <%s> <http://dbpedia.org/ontology/country> ?resource . }
+ { <%s> <%s> ?resource . }
}
"""
- resourceprefix = "http://dbpedia.org/resource/"
+ #resourceprefix = "http://dbpedia.org/resource/"
+ resourceprefix = settings.DBPEDIA_URI_TEMPLATE % ( 'resource', '' )
identityuri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
writer = None
for i,tag in enumerate(qs):
- endpoint.setQuery(sparqltext % (tag.dbpedia_uri, tag.dbpedia_uri))
+ endpoint.setQuery(sparqltext % (tag.dbpedia_uri, settings.DBPEDIA_URI_TEMPLATE % ( 'ontology', 'Country' ), tag.dbpedia_uri, settings.DBPEDIA_URI_TEMPLATE % ( 'ontology', 'country' )))
results = endpoint.query().convert()['results']['bindings']