quepy project uses python to do question answering (nl to mql) over freebasePosted by Elías Andrawos 3 years, 4 months ago Comments
quepy 0.2 now is able to generate queries in mql for the freebase knowledge base!
Quepy is a python framework in which you can specify how to handle questions (in natural language) in order to generate a database query that answers them.
Freebase is a HUGE database that contains A LOT of enciclopedic information about everything.
See the link?
>>> import quepy
>>> freebase = quepy.install("freebase")
>>> _, query, _ = freebase.get_query("Who is the creator of The Walking Dead?")
>>> print query
"/type/object/name": "The Walking Dead",
If you take this query to Freebase's query editor you will get the expected answer: "Frank Darabont" (of course! didn't you know? :P).
Would you like to try it live? Check out the demo!
If you have never seen the query language generated, it's called MQL, and it's the only query language accepted by Freebase. Since this release Quepy is able to generate MQL, and therefore able to interface with Freebase, w00t!
does it comes with a pony too? what's the catch?
Quepy doesn't do magic, for every kind of question that Quepy can answer there's a question pattern and a handler to produce the desired interpretation.
Quepy's question patterns are like regular expressions, but enriched with syntactic information, allowing a rich expressiveness. Check out this example
Quepy's question handlers use a user defined domain specific language (DSL) that has limited expressiveness but is very intuitively understood. Check out this other example
In Quepy's jargon, the pattern + handler together are known as a Question Template.
So the catch is that Quepy it's no good for open domain question answering, because every kind of question has to be programmed, and there are too many of them (and some could be ambiguous without context).
On the bright side:
If it takes you 2 hours to finish a Question Template, it will take you 20 hours to finish 10 Question Templates. This means that you can build a question answering system on a predictable budget... a real one, like the ones the software industry uses. No rocket science here.
The people doing the Question Templates don't really need to know python, or linguistics, or even the syntax of the query language that Quepy generates. They just need to get used to Quepy's conventions and have seen some examples. In this sense, Quepy is quite accessible.
still have your attention?
Great! You can find a tutorial here: http://quepy.readthedocs.org/en/latest/tutorial.html
The full code here: http://github.com/machinalis/quepy
And the full documentation here: http://quepy.readthedocs.org/
Knock yourself out!
If you are around the States feel free to invite us for a beer and talk!
see you soon at pydata NYC :)