< Home

TGM v1

Category Template generation


Templator is a module for dependency-driven SPARQL template generation from natural language.

Templator takes in a question and generates pseudo-queries as well as a list of strings (so-called slots) for which data from the knowledge base is needed.


First, the question is linguistically analysed, annotating it with part-of-speech tags, dependency relations, and semantic role labels. Second, the resulting parse tree is transformed into a template, covering one possibility of the how natural language expressions correspond to constructs in the target SPARQL query. This is the template that is most faithful to the linguistic structure of the question.

In order to also account for structural differences between the question and the target query, the template is modified by a sequence of steps that collapse or expand triples, yielding additional templates.

The scoring of the templates follows a simple heuristics computing the number of nodes in the query body that are neither projection variables nor slots. In addition, each rewriting operation reduces the score by a predetermined factor.


1. NLP tools (e.g. the stanford parser) analyze the input question text into dependency parse tree.
2. Then Templator generates the pseudo query for SPARQL query based on the RULEs within dependency parse tree

Scope and limit

Current version (March, 2016) focused on the hand-crafted RULEs for dependency parse tree.
So that the QA performance depends on the RULEs' quality and coverage.

Issues and discusion

* How to check/add/edit RULEs?

- RULEs for English: SRL_rules_en.json
- RULEs for Korean: SRL_rules_ko.json

At this time (January 13, 2016, at OKBQA 3.5) we can not provide yet the web service to add/edit exist RULEs or use your own RULEs for the OKBQA platform.
This web service would be provided before/during OKBQA 4 (http://4.okbqa.org)
We believe that good RULEs would improve overall performance of (our/your own) QA system.

* Does it works for Korean?
It currently works for English and Korean.
Yes. We've added simple RULEs for some Korean question words such as "무엇", "누구", "어떤", and "얼마나 많". Of course, this rules cover few cases.
Now you can test this sentence: "어떤 강이 서울을 흐르는가?" using the following Sample curl command.

* How to deploy it:
$ git clone https://github.com/okbqa/templator
$ cd templator
$ mvn compile exec:java

Source code

Implementations are available on GitHub: github.com/okbqa/templategeneration github.com/okbqa/templator


While general questions about Templator should be addressed to the original developer, Christina Unger {cunger@cit-ec.uni-bielefeld.de}, Younggyun Hahm {hahmyg@kaist.ac.kr} also can act as a contact point especially for the matter on Korean applications.
Maintainer cunger@cit-ec.uni-bielefeld.de
Source-code URL https://github.com/okbqa/templator
Homepage URL
Web service URL http://ws.okbqa.org:1555/templategeneration/templator
Sample cURL command curl -H "Content-Type: application/json" -X POST -d '_sample_input_' _ws_url_ Test
Sample input
Sample output