Rocco Lillo
2015-11-17 20:46:59 UTC
I use apache jena fuseki as server sparqlendpoint interface for execute
query sparql on an ontology OWL that is loaded on server apache jena. The
queries are executed through python languages.
I have need that the results of query must be the consequence of process
the reasoning.
How I do at configure the reasoner with apache jena fuseki?
I use library sparqlwrapper for SPARQL Endpoint interface to Python.
# defines the URI of the endpoint and the query to send
uri = "http://localhost:3030/Hotel/query" <http://localhost:3030/Hotel/query>
query = ("PREFIX : <http://www.semanticweb.org/ontologies/Hotel.owl#> <http://www.semanticweb.org/ontologies/Hotel.owl#> "
"SELECT ?hotel ?price WHERE {"
" ?hotel a :Hotel. "
" ?hotel :hasPrice ?price }")
# obtain a connection to the endpoint and sends the query
sparql = SPARQLEndpointInterface(uri)
rs,fields = converter(sparql(query))
'''
This function sends the query to the SPARQL end-point.
statement: query in string form to send.
resultset: the result-set list in JSON format.
'''
resultset = []
self._sparql.setQuery(statement)
self._sparql.setReturnFormat(JSON)
print("SPARQLInterface is executing the query...")
t0 = time()
rs = self._sparql.query()
tf = time()
resultset = rs.convert()
print("Query has been executed successfully!\nTime elapsed: {0:.3f} seconds.".format(tf-t0))
raise Exception("")
self._sparql.resetQuery()
return resultset
query sparql on an ontology OWL that is loaded on server apache jena. The
queries are executed through python languages.
I have need that the results of query must be the consequence of process
the reasoning.
How I do at configure the reasoner with apache jena fuseki?
I use library sparqlwrapper for SPARQL Endpoint interface to Python.
# defines the URI of the endpoint and the query to send
uri = "http://localhost:3030/Hotel/query" <http://localhost:3030/Hotel/query>
query = ("PREFIX : <http://www.semanticweb.org/ontologies/Hotel.owl#> <http://www.semanticweb.org/ontologies/Hotel.owl#> "
"SELECT ?hotel ?price WHERE {"
" ?hotel a :Hotel. "
" ?hotel :hasPrice ?price }")
# obtain a connection to the endpoint and sends the query
sparql = SPARQLEndpointInterface(uri)
rs,fields = converter(sparql(query))
'''
This function sends the query to the SPARQL end-point.
statement: query in string form to send.
resultset: the result-set list in JSON format.
'''
resultset = []
self._sparql.setQuery(statement)
self._sparql.setReturnFormat(JSON)
print("SPARQLInterface is executing the query...")
t0 = time()
rs = self._sparql.query()
tf = time()
resultset = rs.convert()
print("Query has been executed successfully!\nTime elapsed: {0:.3f} seconds.".format(tf-t0))
raise Exception("")
self._sparql.resetQuery()
return resultset