Closed anbo-de closed 3 years ago
Qanary triplestore credentials
Web UI to execute SPARQL queries (e.g. for debugging): https://stardog.studio
Connection parameters:
Login: admin
Password: admin
Endpoint: https://webengineering.ins.hs-anhalt.de:40159
Python code:
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper(endpoint) # endpoint here: "https://webengineering.ins.hs-anhalt.de:40159/qanary/query"
sparql.setCredentials(login, password)
sparql.setQuery(sparql_query) # replace query with your custom one
sparql.setReturnFormat(JSON)
sparql.setMethod("POST")
results = sparql.query().convert()
Qanary triplestore credentials
Web UI to execute SPARQL queries (e.g. for debugging): https://stardog.studio
Connection parameters:
Login: admin Password: admin Endpoint: https://webengineering.ins.hs-anhalt.de:40159
Python code:
from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper(endpoint) # endpoint here: "https://webengineering.ins.hs-anhalt.de:40159/qanary/query" sparql.setCredentials(login, password) sparql.setQuery(sparql_query) # replace query with your custom one sparql.setReturnFormat(JSON) sparql.setMethod("POST") results = sparql.query().convert()
@Perevalov Hi I am trying to get the graph information when I send the post request to QANARY API how can I get this information check screenshot - https://i.imgur.com/8QKS6Vw.png
Qanary triplestore credentials Web UI to execute SPARQL queries (e.g. for debugging): https://stardog.studio Connection parameters:
Login: admin Password: admin Endpoint: https://webengineering.ins.hs-anhalt.de:40159
Python code:
from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper(endpoint) # endpoint here: "https://webengineering.ins.hs-anhalt.de:40159/qanary/query" sparql.setCredentials(login, password) sparql.setQuery(sparql_query) # replace query with your custom one sparql.setReturnFormat(JSON) sparql.setMethod("POST") results = sparql.query().convert()
@Perevalov Hi I am trying to get the graph information when I send the post request to QANARY API how can I get this information check screenshot - https://i.imgur.com/8QKS6Vw.png
via Stardog Studio
graph id
with yours and adjust the query to retrieve specific annotations (this one fetches all the triples).qanary
database (as selected in the drop down element on the picture)via code (e.g. Python)
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("https://webengineering.ins.hs-anhalt.de:40159/qanary/query")
sparql.setCredentials("admin", "admin")
sparql_query = """
SELECT ?annotation ?p ?o
FROM
* Replace the `graph id` with yours and adjust the query to retrieve specific annotations (this one fetches all the triples).
Qanary triplestore credentials Web UI to execute SPARQL queries (e.g. for debugging): https://stardog.studio Connection parameters:
Login: admin Password: admin Endpoint: https://webengineering.ins.hs-anhalt.de:40159
Python code:
from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper(endpoint) # endpoint here: "https://webengineering.ins.hs-anhalt.de:40159/qanary/query" sparql.setCredentials(login, password) sparql.setQuery(sparql_query) # replace query with your custom one sparql.setReturnFormat(JSON) sparql.setMethod("POST") results = sparql.query().convert()
@Perevalov Hi I am trying to get the graph information when I send the post request to QANARY API how can I get this information check screenshot - https://i.imgur.com/8QKS6Vw.png
- via Stardog Studio
- Use https://stardog.studio to connect with the credentials described above. Check the following query:
- Replace the
graph id
with yours and adjust the query to retrieve specific annotations (this one fetches all the triples).- Execute the query on the
qanary
database (as selected in the drop down element on the picture)
- via code (e.g. Python)
- Use the following code snippet:
from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper("https://webengineering.ins.hs-anhalt.de:40159/qanary/query") sparql.setCredentials("admin", "admin") sparql_query = """ SELECT ?annotation ?p ?o FROM <urn:graph:422647b8-95fe-482b-98be-a5d5496205a4> WHERE {{ ?annotation ?p ?o . }}""" sparql.setQuery(sparql_query) sparql.setReturnFormat(JSON) sparql.setMethod("POST") results = sparql.query().convert() print(results)
- Replace the
graph id
with yours and adjust the query to retrieve specific annotations (this one fetches all the triples).
@Perevalov Hi yes but I am trying to get the graph id for the question for example if I send a post request to QANARY
import requests
load = {'query':'Where and when was Ada Lovelace born?'}
r = requests.post('https://webengineering.ins.hs anhalt.de:43740/gerbil-execute/NED-DBpediaSpotlight,QueryBuilderSimpleRealNameOfSuperHero,SparqlExecuter,OpenTapiocaNED,BirthDataQueryBuilder,WikidataQueryExecuter',data = load)
print(r.json())
I only get the JSON which has the answer to the question and SPARQL query but I need graph id so I can do visualization so how to get the graph id?
Qanary triplestore credentials Web UI to execute SPARQL queries (e.g. for debugging): https://stardog.studio Connection parameters:
Login: admin Password: admin Endpoint: https://webengineering.ins.hs-anhalt.de:40159
Python code:
from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper(endpoint) # endpoint here: "https://webengineering.ins.hs-anhalt.de:40159/qanary/query" sparql.setCredentials(login, password) sparql.setQuery(sparql_query) # replace query with your custom one sparql.setReturnFormat(JSON) sparql.setMethod("POST") results = sparql.query().convert()
@Perevalov Hi I am trying to get the graph information when I send the post request to QANARY API how can I get this information check screenshot - https://i.imgur.com/8QKS6Vw.png
- via Stardog Studio
- Use https://stardog.studio to connect with the credentials described above. Check the following query:
- Replace the
graph id
with yours and adjust the query to retrieve specific annotations (this one fetches all the triples).- Execute the query on the
qanary
database (as selected in the drop down element on the picture)
- via code (e.g. Python)
- Use the following code snippet:
from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper("https://webengineering.ins.hs-anhalt.de:40159/qanary/query") sparql.setCredentials("admin", "admin") sparql_query = """ SELECT ?annotation ?p ?o FROM <urn:graph:422647b8-95fe-482b-98be-a5d5496205a4> WHERE {{ ?annotation ?p ?o . }}""" sparql.setQuery(sparql_query) sparql.setReturnFormat(JSON) sparql.setMethod("POST") results = sparql.query().convert() print(results)
- Replace the
graph id
with yours and adjust the query to retrieve specific annotations (this one fetches all the triples).@Perevalov Hi yes but I am trying to get the graph id for the question for example if I send a post request to QANARY
import requests
load = {'query':'Where and when was Ada Lovelace born?'}
r = requests.post('https://webengineering.ins.hs anhalt.de:43740/gerbil-execute/NED-DBpediaSpotlight,QueryBuilderSimpleRealNameOfSuperHero,SparqlExecuter,OpenTapiocaNED,BirthDataQueryBuilder,WikidataQueryExecuter',data = load)
print(r.json())
I only get the JSON which has the answer to the question and SPARQL query but I need graph id so I can do visualization so how to get the graph id?
Please, use this call:
>>> from qanary_helpers import qanary_queries
>>> import requests
>>> r = requests.post('https://webengineering.ins.hs-anhalt.de:43740/startquestionansweringwithtextquestion',
... params={
... "question": "Where and when was Ada Lovelace born?",
... "componentlist[]": ["NED-DBpediaSpotlight",
... "QueryBuilderSimpleRealNameOfSuperHero",
... "SparqlExecuter",
... "OpenTapiocaNED",
... "BirthDataQueryBuilder",
... "WikidataQueryExecuter"]
... })
>>> r.json()
{'endpoint': 'http://admin:admin@webengineering.ins.hs-anhalt.de:40158/qanary', 'inGraph': 'urn:graph:69a0e1e3-9ca3-408a-ad17-ed7f880ed55b', 'outGraph': 'urn:graph:69a0e1e3-9ca3-408a-ad17-ed7f880ed55b', 'question': 'https://webengineering.ins.hs-anhalt.de:43740/question/stored-question__text_895ed9bb-f86f-438d-ac50-c8adbe515713'}
>>> res = r.json()
>>> text = qanary_queries.get_text_question_in_graph(res['endpoint'], res['inGraph'])
[{'text': 'Where and when was Ada Lovelace born?',
'uri': 'https://webengineering.ins.hs-anhalt.de:43740/question/stored-question__text_895ed9bb-f86f-438d-ac50-c8adbe515713'},
{'text': 'Where and when was Ada Lovelace born?',
'uri': 'https://webengineering.ins.hs-anhalt.de:43740/question/stored-question__text_895ed9bb-f86f-438d-ac50-c8adbe515713'}]
>>> text
[{'uri': 'https://webengineering.ins.hs-anhalt.de:43740/question/stored-question__text_895ed9bb-f86f-438d-ac50-c8adbe515713', 'text': 'Where and when was Ada Lovelace born?'}, {'uri': 'https://webengineering.ins.hs-anhalt.de:43740/question/stored-question__text_895ed9bb-f86f-438d-ac50-c8adbe515713', 'text': 'Where and when was Ada Lovelace born?'}]
Before, install pip install qanary_helpers
.
@anbo-de Here is the graph visualization link which is always active - https://rdfgraphvisualizations.herokuapp.com/visualize/example
this app is hosted on Heroku on a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep. so if link is not working reload it again!
@ram-g-athreya @RicardoUsbeck @anbo-de I think it is done, right?
Context
We would like to integrate a web-based visualization (Javascript or image) of the Qanary RDF graph (to show the created annotations of a query) and the SPARQL (used to compute the answer).
Options:
Definition of Done (DoD)
http://.../visualize/$ID$