Query Generation for Question Answering over Knowledge Bases
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea/inspectionProfiles
analysis
common speed up __eq__ by comparing __str__ Apr 13, 2018
data exclude data dir Feb 20, 2018
images
kb fix bug: do not check the bloomfilter when there is a variable Apr 6, 2018
learning use hashing for sqg_webserver Apr 12, 2018
linker
parser resolve merge conflicts Apr 5, 2018
scripts save the result Mar 12, 2018
.gitignore
README.md
dependencies.txt Create dependencies.txt Sep 10, 2018
dssm.py create earl class to parse the output of EARL syste, Nov 15, 2017
evaluate.py Basic Query Comparison and some other helper methods Feb 27, 2018
logging.json add logging Nov 15, 2017
main.py include all datasets Sep 13, 2017
orchestrator.py
output_analysis.py
query_gen.py resolve merge conflicts: dev Apr 5, 2018
sqg_webserver.py

README.md

Query Generation

Question answering (QA) systems over Knowledge Graph often consist of several components such as Named Entity Disambiguation (NED), Relation Extraction (RE), and Query Generation (QG). The main objective of this project is to generate SPARQL query for a given question which is annotated by its linked entities and relations.

SQG is a SPARQL Query Generator with modular architecture, enabling easy integration with other components for the construction of a fully functional QA pipeline. To increase the chance constructthe correct query, SQG is able to handle a set of annotations including several incorrect ones. It also benefits from Tree-LSTM model to deal with syntactic ambiguity of the input questions. Special adjustment is considered in order to cope with large-scale knowledge base.

Supported Questions

Currently the following questions are supported:

  • Single entity relation questions
  • Compound questions
  • Count questions
  • Boolean questions

Cite

If you would use the codebase, please cite our paper as well:

@inproceedings{zafar2018formal,
  title={Formal query generation for question answering over knowledge bases},
  author={Zafar, Hamid and Napolitano, Giulio and Lehmann, Jens},
  booktitle={European Semantic Web Conference},
  pages={714--728},
  year={2018},
  organization={Springer}
}

How-to

Data

Getting Started

You can find the list of required packages in here.

To run it (python 2.7 is required):

python sqg_webserver.py

Consume Web API

SQG provides a RESTfull api for the query generator.

Here is an example of how to use the api:

curl -i -H "Content-Type: application/json" -X POST -d '{"question":"What is the hometown of Nader Guirat, where Josef Johansson was born too?","relations":[{"surface":"","uris":[{"confidence":1,"uri":"http://dbpedia.org/property/birthPlace"}]},{"surface":"","uris":[{"confidence":1,"uri":"http://dbpedia.org/ontology/hometown"}]}],"entities":[{"surface":"","uris":[{"confidence":0.7,"uri":"http://dbpedia.org/resource/Josef_Johansson"},{"confidence":0.3,"uri":"http://dbpedia.org/resource/Barack_Obama"}]},{"surface":"","uris":[{"confidence":1,"uri":"http://dbpedia.org/resource/Nader_Guirat"}]}],"kb":"dbpedia"}' http://localhost:5000/qg/api/v1.0/query