skip to navigation
skip to content

quepy 0.2

A framework to convert natural language to database queries.

  __ _ _   _  ___ _ __  _   _
 / _` | | | |/ _ \ '_ \| | | |
| (_| | |_| |  __/ |_) | |_| |
 \__, |\__,_|\___| .__/ \__, |
    |_|          |_|    |___/

What’s quepy?

Quepy is a python framework to transform natural language questions to queries in a database query language. It can be easily customized to different kinds of questions in natural language and database queries. So, with little coding you can build your own system for natural language access to your database.

Currently Quepy provides support for Sparql and MQL query languages. We plan to extended it to other database query languages.

An example

To illustrate what can you do with quepy, we included an example application to access DBpedia contents via their sparql endpoint.

You can try the example online here: Online demo

Or, you can try the example yourself by doing:

python examples/dbpedia/ "Who is Tom Cruise?"

And it will output something like this:

    ?x0 rdf:type foaf:Person.
    ?x0 rdfs:label "Tom Cruise"@en.
    ?x0 rdfs:comment ?x1.

Thomas Cruise Mapother IV, widely known as Tom Cruise, is an...

The transformation from natural language to sparql is done by first using a special form of regular expressions:

person_name = Group(Plus(Pos("NNP")), "person_name")
regex = Lemma("who") + Lemma("be") + person_name + Question(Pos("."))

And then using and a convenient way to express semantic relations:

person = IsPerson() + HasKeyword(person_name)
definition = DefinitionOf(person)

The rest of the transformation is handled automatically by the framework to finally produce this sparql:

    ?x0 rdf:type foaf:Person.
    ?x0 rdfs:label "Tom Cruise"@en.
    ?x0 rdfs:comment ?x1.

Using a very similar procedure you could generate and MQL query for the same question obtaining:

    "/common/topic/description": [{}],
    "/type/object/name": "Tom Cruise",
    "/type/object/type": "/people/person"


You need to have installed numpy. Other than that, you can just type:

pip install quepy

You can get more details on the installation here:

Learn more

You can find a tutorial here:

And the full documentation here:

Join our mailing list


Want to help develop quepy? Welcome aboard! Find us in

  • #quepy at freenode
  • quepydev at
File Type Py Version Uploaded on Size
quepy-0.2.tar.gz (md5) Source 2013-09-10 41KB
  • Downloads (All Versions):
  • 4 downloads in the last day
  • 35 downloads in the last week
  • 234 downloads in the last month