Git Product home page Git Product logo

quepy's Introduction

__ _ _   _  ___ _ __  _   _

/ _` | | | | |

(_| | | __/ | __, ___| .__/ __, | |___/

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:

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

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:

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

quepy's People

Contributors

arielrossanigo avatar dmoisset avatar drdub avatar iscienceluvr avatar j0hn avatar lurst avatar mrshu avatar rafacarrascosa avatar roger avatar sigvef avatar testsubjector avatar tutuca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quepy's Issues

support for sql_92

Hi,

Is there any support for legacy sql systems like mysql and oracle

Broken NLTK setup

While running quepy nltkdata /some/pathdownloads the resources "wordnet" and "maxent_treebank
_pos_tagger", trying to run the applicaion gives the following error:

Resource u'taggers/averaged_perceptron_tagger/averaged_perceptron_tagger.pickle' not found. Please use the NLTK Downloader to obtain the resource: >>> nltk.download()

I believe this is because of the perceptron tagger being made the default tagger in the nltk project, which is a dependency for quepy.

does the quepy support the python3?

my conda env is python3,but it doesn't work,i can't import the quepy.when i create the env python2,it can work.it may not support the python3?

Insufficient documentation

I am facing some issues in understanding the api usage since I couldn't find enough examples. Besides the existing examples are unfortunately not very clear. It would be a great help if successful users of this framework could provide links to their projects.

Update tutorial

A few files where renamed and the docs were not changed to reflect this.
In particular, the tutorial name a file parsing.py that does not exists because it was renamed to basic.py.
This error should be fixed and a review of the docs should be made.
Anybody is welcome to submit pull requests for this!

Not installed on ubuntu 14 and windows 10

After installing with pip,It doesn't found any module quepy,(on windows)->and on "quepy --version" it opens up the quepy file in text editor.
please help me,I tries different way,but not any work for me.

Resource u 'corpora/wordnet' not found

I just installed quepy to start working with some examples as shown in the tutorials. But I get the following errors while running main.py.


Traceback (most recent call last):
  File "main.py", line 9, in <module>
    target, query, metadata = testquepy.get_query("what is a blowtorch?")
  File "/usr/local/lib/python2.7/dist-packages/quepy/quepyapp.py", line 106, in get_query
    for target, query, userdata in self.get_queries(question):
  File "/usr/local/lib/python2.7/dist-packages/quepy/quepyapp.py", line 123, in get_queries
    for expression, userdata in self._iter_compiled_forms(question):
  File "/usr/local/lib/python2.7/dist-packages/quepy/quepyapp.py", line 137, in _iter_compiled_forms
    words = list(self.tagger(question))
  File "/usr/local/lib/python2.7/dist-packages/quepy/tagger.py", line 68, in wrapper
    words = tagger_function(string)
  File "/usr/local/lib/python2.7/dist-packages/quepy/tagger.py", line 64, in <lambda>
    tagger_function = lambda x: run_nltktagger(x, settings.NLTK_DATA_PATH)
  File "/usr/local/lib/python2.7/dist-packages/quepy/nltktagger.py", line 49, in run_nltktagger
    u'NN': wordnet.NOUN,
  File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/util.py", line 99, in __getattr__
    self.__load()
  File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/util.py", line 64, in __load
    except LookupError: raise e
LookupError: 
**********************************************************************
  Resource u'corpora/wordnet' not found.  Please use the NLTK
  Downloader to obtain the resource:  >>> nltk.download()
  Searched in:
    - u'/'
    - u'h'
    - u'o'
    - u'm'
    - u'e'
    - u'/'
    - u'g'
    - u'u'
    - u'r'
    - u'u'
    - u'p'
    - u'a'
    - u'd'
    - u'/'
    - u'n'
    - u'l'
    - u't'
    - u'k'
    - u'_'
    - u'd'
    - u'a'
    - u't'
    - u'a'
**********************************************************************

Also this is how i set he nltk_data variable in settings.py:

# NLTK config
NLTK_DATA_PATH = "/home/gurupad/nltk_data"  # List of paths with NLTK data

Can someone help me out?

Error in : file name = quepy.install("file name")

I am constantly facing errors in this code, could anyone help me ?
I declared my ontology as filename in the settings.py folder,
what would be the best way to import ontology made in system to be used in quepy to generate queries ??

Missing instruction in the Quepy example

In the example given on the Quepy README.rst, before

python examples/dbpedia/main.py "Who is Tom Cruise?"

, an instruction to configure settings.py (in examples/dbpedia) so that it points to the path where the nltkdata is placed, should be given.

Python 3 Support Not Implemented

Traceback (most recent call last):
File "main.py", line 20, in
import quepy
File "/opt/rh/rh-python35/root/usr/lib/python3.5/site-packages/quepy/init.py", line 17, in
from quepy.quepyapp import install, QuepyApp
File "/opt/rh/rh-python35/root/usr/lib/python3.5/site-packages/quepy/quepyapp.py", line 41
except ImportError, error:
^
SyntaxError: invalid syntax

Remove depreciated freebase-mql code?

MQL write API has been retired and freebase now exists as a data dump of 1.9 billion Freebase triples in N-Triples RDF format, available on the developers page. So is it preferable to remove the related code or keep it as legacy?

issue

Hi elias,

Am getting below error..

C:\Users\xbbl1wk\Desktop\quepy-develop\examples\dbpedia>python main.py "who i

who is Tom Cruise

PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX foaf: http://xmlns.com/foaf/0.1/
PREFIX skos: http://www.w3.org/2004/02/skos/core#
PREFIX quepy: http://www.machinalis.com/quepy#
PREFIX dbpedia: http://dbpedia.org/ontology/
PREFIX dbpprop: http://dbpedia.org/property/
PREFIX dbpedia-owl: http://dbpedia.org/ontology/

SELECT DISTINCT ?x1 WHERE {
?x0 rdf:type foaf:Person.
?x0 rdfs:label "Tom Cruise"@en.
?x0 rdfs:comment ?x1.
}

Traceback (most recent call last):
File "main.py", line 210, in
results = sparql.query().convert()
File "build\bdist.win32\egg\SPARQLWrapper\Wrapper.py", line 567, in query
File "build\bdist.win32\egg\SPARQLWrapper\Wrapper.py", line 537, in _query
File "C:\Users\xbbl1wk\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", l
rlopen
return opener.open(url, data, timeout)
File "C:\Users\xbbl1wk\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", l
pen
response = self._open(req, data)
File "C:\Users\xbbl1wk\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", l
open
'_open', req)
File "C:\Users\xbbl1wk\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", l
call_chain
result = func(*args)
File "C:\Users\xbbl1wk\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", l
http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Users\xbbl1wk\AppData\Local\Continuum\Anaconda2\lib\urllib2.py", l
do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 10060] A connection attempt failed be
nected party did not properly respond after a period of time, or established
iled because connected host has failed to respond>

can you please help..

how to start a project

as there is no quepy.py file then how can we start a new project
I have tried with quepyapp.py file to start a new project but nothing happened

"$ quepy.py startapp dbpedia"
how to do this

How can the filtering option of sparql be done?

As of now there are only triples inside WHERE{}. Including this filtering can increase the semantics in the search.
eg) List the details of Actors other than Tom Cruise?
which filters Tom Cruise and displays the result of other actors.
Implementing this is a great achievement against keyword based which will only details of Tom Cruise which is opposite of what the user wants.

How to call quepy.install("") for multiple modules / languages?

I am trying to create my own RDF module based on dbpedia in Chinese.

In my dsl.py, we created something like:

HasKeyword.relation = "rdfs:label"
HasKeyword.language = "zh"

However, when I created two RDF modules simultaneously in the constructor of main class:

self.dbpedia = quepy.install("dbpedia")
self.zhwiki = quepy.install("zhwiki") # Chinese version of dbpedia

I found that the latter module that I created will always override the first one.

In particular, the dsl.py for dbpedia look likes:

HasKeyword.language = "en"

And the variable "HasKeyword.language" will be overrided as "zh"

Is there any good way to resolve it?

Unmaintained?

Unmaintained? Last commit to master was more than 1 year ago.

Unicode rears its ugly head

The query "What is Pokémon?" silently drops the é and then tells me there is no result in the database for "Pokmon". "What is Tyranitar?", on the other hand, got me this gem from Freebase:

are one of the 493 fictional species of Pokᅢᄅmon creatures from the multi-billion-dollar Pokᅢᄅmon media franchise, designed by Ken Sugimori. The purpose of Tyranitar in the games, anime, and manga, as with all other Pokᅢᄅmon, is to battle both wild Pokᅢᄅmon¬タヤuntamed creatures that characters encounter while embarking on various adventures and tamed Pokᅢᄅmon creatures owned by Pokᅢᄅmon trainer.

In case Github eats them, the two middle characters are U+FFC3 HALFWIDTH HANGUL LETTER AE and U+FFA9 HALFWIDTH HANGUL LETTER RIEUL - how U+00E9 LATIN SMALL LETTER E WITH ACUTE ended up as that is beyond me. (It may be a bug in the database, because the query "What is Pikachu?" gets back a correctly formatted page.)

Filtering (where clause), show multiple items and SERVICE clause to join is missing?

@j0hn @dmoisset I am trying to build SPARQL queries using QUEPY and was looking for any example where you guys have used FILTER clause. I did not find any. Could you please provide a sample code or a tutorial. This issue has also been reported by another user #44.
Moreover, I tried to build queries extracting multiple items but query is not being generated. For example, i was trying to generate query for "list proteins with symbols and chromosome where protein symbol is ACT" How can I build query like this?
3- To generate a federated query you have to join the query with SERVICE clause. Does quepy support for joining (SERVICE) clause.

Conflicting queries

I have been adding functions to, for example, ask the release date of a song. However, there are TWO other functions for this, except for different domains, movies and TV shows. How can we deal with this? Can you add some function that can determine whether the movies query yields no results, so try the TV show query, then the song query? Or is there a way to show all query results?

Missing wrapper on Windows install

To work on Windows, you'll need a quepy.bat wrapper for the quepy Python script. All the other things in my Scripts directory have them, but I'm not sure what is needed to get the installer to create it (or if you have to do it yourself). I installed using pip, not easy_install, if it makes a difference.

Word.prob is unused

Word.prob seems to be unused.
It should be checked that this is so and the "prob" attribute and related code removed.

Credit to @dmoisset for spotting it

installing from cheese shop is broken.

I have installed as so:
pip install quepy

Then:

sivan@metal:~/icrav/code$ quepy
Traceback (most recent call last):
File "/home/sivan/icrav-venv/bin/quepy", line 27, in
from docopt import docopt
ImportError: No module named docopt

It appears that this fixes it:
pip install docopt

so docopt needs to be added to the requirements.txt

Como agregar mas variables en el query? / How to Add more variables on query ?

Hola, Todos los ejemplos tienen la siguiente sintaxis
SELECT DISTINCT {select} ....
por ejemplo:
SELECT DISTINCT ?x1 WHERE {
?x0 rdf:type foaf:Person.
?x0 rdfs:label "Tom Cruise"@en.
?x0 rdfs:comment ?x1.
}

Mi pregunta es, si es posible agregar mas variables en el SELECT
por ejemplo:
SELECT DISTINCT ?x0 ?x1 WHERE {
?x0 rdf:type foaf:Person.
?x0 rdfs:label "Tom Cruise"@en.
?x0 rdfs:comment ?x1.
}

Saludos

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.