Closed iScienceLuvr closed 8 years ago
It seems nobody has seen this thread? @j0hn @rafacarrascosa etc. have you seen?
@iScienceLuvr I'm really sorry for taking so long to answer :S
You can use the QuepyApp.get_queries
method to iterate over all interpretations of a question and then implement whatever policy you want in case more than two queries match.
You might want to checkout this option too to choose the preference between question templates (templates are tried in order, from higher weight to lower), this could help to implement simpler policies in case more than two question templates match.
Cheers!
@rafacarrascosa is there docs for both of these functions? I am not understanding how to use them.
Kind of...
For get_queries
: You have the docstrings and a use case for it's sister function get_query
on main.py.
For weight
: It's not documented, but is simple to use:
class FoundationQuestion(QuestionTemplate):
"""
Regex for questions about the creation of a band.
Ex: "When was Pink Floyd founded?"
"When was Korn formed?"
"""
weight = 1.5 # By default is 1, so this template is used before all others
regex = Pos("WRB") + Lemma("be") + Band() + \
(Lemma("form") | Lemma("found")) + Question(Pos("."))
def interpret(self, match):
active_years = ActiveYears(match.band)
return active_years, "literal"
You can add weight
as shown above, if you don't it will be 1
by default.
@rafacarrascosa ah, so I use get_queries instead of get_query in main.py and it will do all three?
@iScienceLuvr list(get_queries(question))
if a list in which get_query(question)
is the first element.
So if you replace that in main.py
you should put everything below that line in a for loop, so that you can print all interpretations to the question.
Try playing with it for a while, perhaps in the python interpreter or a in a ipython notebook to get the hang of it.
@rafacarrascosa thanks! you can close
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?