def interpret(self, match): definition = DefinitionOf(match.genre) #print("Match ",dir(match)) matched_lemmas = [k.lemma for k in match.words] recent = u"recent" in matched_lemmas popular = u"popular" in matched_lemmas if recent or popular: genre_name = ''.join(match.genre.nodes[0][1][1].split('"')[:-1]) generate_nodes_tables(definition, ["genres"], ["title"], condition_cols=["genre"], condition_values=[genre_name], popular=popular, recent=recent) #definition.nodes = [u' lower(a.genre) like "%'+genre_name+'%" and b.year>YEAR(curdate())-2'] #definition.head= u"a.title" #definition.tables = ["genres as a left join movies as b on(a.movie_id=b.id) "] #print("definition ",definition) else: genre_name = ''.join(match.genre.nodes[0][1][1].split('"')[:-1]) definition.nodes = [u' lower(genre) like "%' + genre_name + '%"'] definition.head = u"title" definition.tables = ["genres"] #print("definition ",definition) return definition, ("define", "RecentMoviesKeyQuestion")
def interpret(self, match): definition = DefinitionOf(match.keyword) print('aaa') #print("Match ",dir(match)) #print (match.words) #print (match.keyword.nodes) if u"recent" in [k.lemma for k in match.words]: keyword_name = ''.join( match.keyword.nodes[0][1][1].split('"')[:-1]) if keyword_name.find(" ") > -1: definition.nodes = [ u' lower(a.keyword) like "%' + '%" or lower(keyword) like "%'.join(keyword_name.split()) + '%" and b.year>YEAR(curdate())-2' ] else: definition.nodes = [ u'lower(a.keyword) like "%' + keyword_name + '%" and b.year>YEAR(curdate())-2' ] definition.head = u"a.title" definition.tables = [ "keywords as a left join movies as b on(a.movie_id=b.id) " ] #print("definition ",definition) else: keyword_name = ''.join( match.keyword.nodes[0][1][1].split('"')[:-1]) if keyword_name.find(" ") > -1: definition.nodes = [ u'lower(keyword) like "%' + u'%" or lower(keyword) like "%'.join( keyword_name.split()) + u'%"' ] else: definition.nodes = [ u'lower(keyword) like "%' + keyword_name + u'%"' ] print definition.nodes definition.head = u"title" definition.tables = ["keywords"] #print("definition ",definition) return definition, ("define", "MoviesKeywordQuestion")
def interpret(self, match): print("halllo") definition = DefinitionOf(match.movie) #print("Match ",match.movie) movie_name = ''.join(match.movie.nodes[0][1][1].split('"')[:-1]) definition.nodes = [u' title like "%' + movie_name + '%"'] definition.head = u"plot" definition.tables = ["plot"] #print("definition ",definition) return definition, ("define", "PlotOfQuestion")
def interpret(self, match): definition = DefinitionOf(match.actor) #print("Match ",match.movie) actor_name = ''.join(match.actor.nodes[0][1][1].split('"')[:-1]) print("Actor name ", actor_name) definition.nodes = [ u' concat(name, " ", surname) like concat("%", replace("' + actor_name + '", " ", "%"), "%")' ] # what to extract definition.head = u" distinct name, surname, title" definition.tables = ["actors", "actresses"] #print("definition ",definition) return definition, ("define", "WhoIsActorQuestion")