예제 #1
0
    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")
예제 #2
0
 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")
예제 #3
0
 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")
예제 #4
0
    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")
예제 #5
0
 def interpret(self, match):
     definition = DefinitionOf(match.person)
     return definition, "define"
예제 #6
0
 def interpret(self, match):
     label = DefinitionOf(match.thing)
     return label, "define"
예제 #7
0
 def interpret(self, match):
     thing = match.target.tokens
     target = HasKeyword(thing)
     definition = DefinitionOf(target)
     return definition, "define"
 def interpret(self, match):
     name = match.words.tokens
     return CategoryOf(name) + DefinitionOf(u"wd:Q6256")
예제 #9
0
 def interpret(self, match):
     _movie, i, j = match.movie
     definition = DefinitionOf(_movie)
     return definition, ReturnValue(i, j)
예제 #10
0
 def interpret(self, match):
     definition = DefinitionOf(match.movie)
     return definition, "define"