예제 #1
0
    def interpret(self, match):
        #print(dir(match), match.director, match.words)
        movie = IsMovie() + DirectedBy(match.director)

        movie_name = NameOf(movie)
        print(movie_name)
        return movie_name, "enum"
예제 #2
0
 def interpret(self, match):
     movie_names = NameOf(LabelOf(match.keyword))
     print(movie_names)
     return movie_names, ("define", "MoviesKeywordQuestion")
예제 #3
0
    def interpret(self, match):
        movie = IsMovie() + HasActor(match.actor)
        movie_name = NameOf(movie)
        name_dir = ''.join(match.actor.nodes[0][1][1].split('"')[:-1])
        names = name_dir.split()
        if u"recent" in [k.lemma for k in match.words]:
            movie_name.head = "a.name,a.surname,a.title"

            if len(names) == 1:
                movie_name.nodes = [
                    u' name like "' + names + '" and  b.year>YEAR(curdate())-2'
                ]
            else:
                movie_name.nodes = [
                    u' name like "' + u" ".join(names[:-1]) +
                    u'" and surname like "' + names[-1] +
                    '" and  b.year>YEAR(curdate())-2'
                ]
            movie_name.head = u"a.title"
            movie_name.tables = [
                "actors as a left join movies as b on(a.movie_id=b.id) ",
                "actresses as a left join movies as b on(a.movie_id=b.id) "
            ]
            #print("definition ",definition)

        else:
            movie_name.tables = ["actors", "actresses"]
            movie_name.head = "title,name,surname"
            if len(names) == 1:
                movie_name.nodes = [u' name like "' + names + '"']
            else:
                movie_name.nodes = [
                    u' name like "' + u" ".join(names[:-1]) +
                    u'" and surname like "' + names[-1] + '"'
                ]
        return movie_name, ("enum", "ActedOnQuestion")
예제 #4
0
 def interpret(self, match):
     author = NameOf(IsPerson() + AuthorOf(match.book))
     return author, "literal"
예제 #5
0
 def interpret(self, match):
     ground = IsStadium() + GroundOf(match.team)
     ground_name = NameOf(ground)
     return ground_name, "literal"
예제 #6
0
 def interpret(self, match):
     memberStation = IsCareerStation() + IsTeamOf(match.team) + HasYear(
         match.year)
     member = IsPerson() + IsCareerStationOf(memberStation)
     member_name = NameOf(member)
     return member_name, "enum"
예제 #7
0
 def interpret(self, match):
     team = IsTeam() + MostSuccessfulOf(match.league)
     team_name = NameOf(team)
     return team_name, "literal"
예제 #8
0
 def interpret(self, match):
     name = match.company.tokens
     company = IsCompany() + HasKeyword(name)
     products = DevelopedBy(company)
     labels = NameOf(products)
     return labels, "enum"
예제 #9
0
 def interpret(self, match):
     _movie, i, j = match.movie
     director = IsPerson() + DirectorOf(_movie)
     director_name = NameOf(director)
     return director_name, ReturnValue(i, j)
예제 #10
0
 def interpret(self, match):
     _movie, i, j = match.movie
     actor = NameOf(IsPerson() + StarsIn(_movie))
     return actor, ReturnValue(i, j)
예제 #11
0
 def interpret(self, match):
     _actor, i, j = match.actor
     movie = IsMovie() + HasActor(_actor)
     movie_name = NameOf(movie)
     return movie_name, ReturnValue(i, j)
예제 #12
0
 def interpret(self, match):
     _author, i, j = match.author
     book = IsBook() + HasAuthor(_author)
     book_name = NameOf(book)
     return book_name, ReturnValue(i, j)
예제 #13
0
 def interpret(self, match):
     _book, i, j = match.book
     author = NameOf(IsPerson() + AuthorOf(_book))
     return author, ReturnValue(i, j)
예제 #14
0
 def interpret(self, match):
     director = IsDirector() + DirectorOf(match.movie)
     director_name = NameOf(director)
     return director_name, "literal"
예제 #15
0
 def interpret(self, match):
     name = match.company.tokens
     company = IsCompany() + HasKeyword(name)
     ownedCompanies = OwnedBy(company)
     label = NameOf(ownedCompanies)
     return label, "enum"
예제 #16
0
    def interpret(self, match):
        movie_name = NameOf(Follows(match.movie))

        print(movie_name)
        return movie_name, "enum"
예제 #17
0
 def interpret(self, match):
     location = LocationOf(match.thing)
     location_name = NameOf(location)
     return location_name
예제 #18
0
 def interpret(self, match):
     manager = IsPerson() + ManagerOf(match.team)
     manager_name = NameOf(manager)
     return manager_name, "literal"
예제 #19
0
 def interpret(self, match):
     movie = IsMovie()
     name = NameOf(movie)
     return name, "enum"
예제 #20
0
 def interpret(self, match):
     league = IsLeague() + IsCountryLeagueOf(match.country)
     team = IsTeam() + MostSuccessfulOf(league)
     team_name = NameOf(team)
     return team_name, "literal"
예제 #21
0
 def interpret(self, match):
     album = IsAlbum() + ProducedBy(match.band)
     name = NameOf(album)
     return name, "enum"
예제 #22
0
 def interpret(self, match):
     chairman = IsPerson() + ChairmanOf(match.team)
     chairman_name = NameOf(chairman)
     return chairman_name, "literal"
예제 #23
0
 def interpret(self, match):
     movie = IsMovie() + HasActor(match.actor)
     movie_name = NameOf(movie)
     print(movie_name.__dict__)
     return movie_name, "enum"
예제 #24
0
 def interpret(self, match):
     _band_name, i, j = match.band
     album = IsAlbum() + ProducedBy(_band_name)
     name = NameOf(album)
     return name, ReturnValue(i, j)
예제 #25
0
 def interpret(self, match):
     actor = NameOf(IsPerson() + StarsIn(match.movie))
     print(actor)
     return actor, "enum"
예제 #26
0
 def interpret(self, match):
     book = IsBook() + HasAuthor(match.author)
     book_name = NameOf(book)
     return book_name, "enum"
예제 #27
0
    def interpret(self, match):
        print('match')
        print(match.__dict__)

        print('match._match')
        print(match._match.__dict__)

        print('match.target')
        print(match.target.__dict__)

        # match.target exists just because of the Group(Movie(), "target")
        print('match.target.tokens')
        print(match.target.tokens)

        print('haskeyword')
        print(HasKeyword(match.target.tokens).__dict__)

        movie = IsMovie()
        movie_name = NameOf(movie)
        """
        {'nodes': [[(u'rdf:type', u'dbpedia-owl:Film'), ('foaf:name', 1)]], 'fixedtyperelation': u'rdf:type', 'head': 0, 'fixedtype': u'dbpedia-owl:Film'}
        """
        print('movie (ismovie)')
        print(movie.__dict__)
        """
        {'nodes': [[(u'rdf:type', u'dbpedia-owl:Film'), ('foaf:name', 1)], []], 'head': 1}
        """
        print('moviename (nameof(ismovie))')
        print(movie_name.__dict__)

        print('words are classes, not just simple texts')
        first_word = match.words[
            0]  # {'lemma': u'list', 'token': u'list', 'pos': u'NN', 'prob': None}
        second_word = match.words[
            1]  # {'lemma': u'movie', 'token': u'movies', 'pos': u'NNS', 'prob': None}
        print('first word')
        print(first_word.__dict__)
        print('second word')
        print(second_word.__dict__)

        print(match.target.tokens)

        matched_lemmas = [k.lemma for k in match.words]
        recent = u"recent" in matched_lemmas
        popular = u"popular" in matched_lemmas

        select_expressions = ["title"]

        if hasattr(match, 'genre'):
            tables = [u"genres"]
            condition_cols = [u"genre"]
            condition_values = [
                ''.join(match.genre.nodes[0][1][1].split('"')[:-1])
            ]
        else:
            tables = [u"title"]
            condition_cols = []
            condition_values = []
        generate_nodes_tables(movie_name,
                              tables,
                              select_expressions,
                              condition_cols=condition_cols,
                              condition_values=condition_values,
                              popular=popular,
                              recent=recent)
        movie_name.nodes[0] += " limit 10"  #[u'title like "'+match.movie+'"']
        print "nodes", movie_name.nodes
        print movie_name
        return movie_name, ("enum", "ListMoviesQuestion")