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"
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")
def interpret(self, match): movie = IsMovie() + HasActor(match.actor) movie_name = NameOf(movie) print(movie_name.__dict__) return movie_name, "enum"
def interpret(self, match): name = match.words.tokens return IsMovie() + HasName(name)
def interpret(self, match): movie = IsMovie() name = NameOf(movie) return name, "enum"
def interpret(self, match): _director, i, j = match.director movie = IsMovie() + DirectedBy(_director) movie_name = LabelOf(movie) return movie_name, ReturnValue(i, j)
def interpret(self, match): _actor, i, j = match.actor movie = IsMovie() + HasActor(_actor) movie_name = NameOf(movie) return movie_name, ReturnValue(i, j)
def interpret(self, match): movie = IsMovie() + DirectedBy(match.director) movie_name = LabelOf(movie) return movie_name, "enum"
def interpret(self, match): name = match.words.tokens exp = IsMovie() exp.tables = ["movies"] return IsMovie() + HasName(name)
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")
def interpret(self, match): movie = IsMovie() + HasActor(match.actor) movie_name = LabelOf(movie) return movie_name, "enum"