• Stars
    star
    1,254
  • Rank 37,230 (Top 0.8 %)
  • Language
    Python
  • License
    Other
  • Created almost 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A python framework to transform natural language questions to queries in a database query language.
  __ _ _   _  ___ _ __  _   _
 / _` | | | |/ _ \ '_ \| | | |
| (_| | |_| |  __/ |_) | |_| |
 \__, |\__,_|\___| .__/ \__, |
    |_|          |_|    |___/

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/main.py "Who is Tom Cruise?"

And it will output something like this:

SELECT DISTINCT ?x1 WHERE {
    ?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:

SELECT DISTINCT ?x1 WHERE {
    ?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"
}]

Installation

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

pip install quepy

You can get more details on the installation here:

http://quepy.readthedocs.org/en/latest/installation.html

Learn more

You can find a tutorial here:

http://quepy.readthedocs.org/en/latest/tutorial.html

And the full documentation here:

http://quepy.readthedocs.org/

Join our mailing list

Contribute!

Want to help develop quepy? Welcome aboard! Find us in http://groups.google.com/group/quepy

More Repositories

1

iepy

Information Extraction in Python
Python
905
star
2

featureforge

A set of tools for creating and testing machine learning features, with a scikit-learn compatible API
Python
381
star
3

mypy-django

PEP-484 type hints bindings for the Django web framework
Python
223
star
4

telegraphy

Telegraphy provides real time events for WSGI Python applications
JavaScript
202
star
5

refo

Regular expressions for objects
Python
143
star
6

yalign

A sentence aligner for comparable corpora
Python
127
star
7

satimg

Satellite data processing experiments
Jupyter Notebook
117
star
8

mypy-data

mypy typesheds for the Python data stack
Python
86
star
9

bidderd

RTBKIT Agent using Go and the HTTPInterface
Go
45
star
10

django-i18n-helper

Python
35
star
11

django-fasttest

A variant on django.test.TestCase optimized for postgres
Python
21
star
12

slides

Public talks by Machinalis
TeX
18
star
13

django-template-previewer

A Django app to allow developers preview templates
Python
17
star
14

mypy-django-example

A usage example for mypy-django
Python
15
star
15

django-test-autocomplete

Python
12
star
16

eff

Time tracking and report generation
Python
9
star
17

ninja-django-plugin

Django plugin for Ninja-IDE
Python
4
star
18

inventor

Inventor a very simple django based inventory system.
HTML
3
star
19

protobuf-python3

Google protobuf port to python3
C++
2
star
20

jquery_simple_progressbar

2
star
21

django-migration-tools

Scripts for helping with routine tasks while migration from 0.96 django versions to 1.x
Python
2
star
22

code_time_tracker

Python
1
star
23

ninja_ipython_console

An IPython console plugin for Ninja
Python
1
star
24

machinalis-movie-reviews

Python
1
star
25

alfajor

A site to collect shopping orders for packages of items, designed for an alfajor seller
Python
1
star