Skip to content
Aleksandr Perevalov edited this page May 10, 2022 · 1 revision

Homepage

Welcome to the qanary_helpers wiki! Here are some useful guides related to the library

How to use qanary_queries module

qanary_queries has 3 methods that are intended to be called by a user of the library:

  • get_text_question_in_graph -- fetches the text of the question that was asked by a user and its URI from a triplestore;
  • select_from_triplestore -- wraps the functionality related to execution of the SELECT SPARQL queries on a triplestore;
  • insert_into_triplestore -- wraps the functionality related to execution of the INSERT SPARQL queries on a triplestore.

Example with get_text_question_in_graph

# Get question text. `question_text` will be something like "Where was Angela Merkel born?"
question_text = get_text_question_in_graph(triplestore_endpoint_url, triplestore_ingraph_uuid)[0]['text']

# Get question URI. `question_uri` will be something like "http://demos.swe.htwk-leipzig.de:40111/question/stored-question__text_46128b0a-f17b-4d95-a705-623ecd47444f"
question_uri = get_text_question_in_graph(triplestore_endpoint_url, triplestore_ingraph_uuid)[0]['uri']

Example with select_from_triplestore

# Execute a SPARQL SELECT query on the given triplestore
sparql_result = select_from_triplestore(triplestore_endpoint_url, sparql_query)

Example with insert_into_triplestore

# Execute a SPARQL INSERT query on the given triplestore
execution_result = insert_into_triplestore(triplestore_endpoint_url, sparql_query)