-
Notifications
You must be signed in to change notification settings - Fork 1
/
Utilities.py
25 lines (22 loc) · 850 Bytes
/
Utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from SPARQLWrapper import SPARQLWrapper, JSON
from rdflib import Graph
#the LDP design vocabulary prefix
vPrefix = "http://opensensingcity.emse.fr/LDPDesignVocabulary/"
def getRS(url,query):
query = query.replace("http://127.0.0.1:5000/","http://opensensingcity.emse.fr/ldpdfend/")
sparql = SPARQLWrapper(url)
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
return results
def getG(url,query):
query = query.replace("http://127.0.0.1:5000/","http://opensensingcity.emse.fr/ldpdfend/")
sparql = SPARQLWrapper(url)
sparql.returnFormat = "text/turtle"
sparql.setQuery(query)
result = sparql.query()
data = result.response.read()
resultGraph = Graph().parse(data=data,format="turtle")
return resultGraph
def getTerm(term):
return vPrefix+str(term)