-
Notifications
You must be signed in to change notification settings - Fork 5
/
Q7-RDFframes.py
24 lines (16 loc) · 1.07 KB
/
Q7-RDFframes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
''' Get information about the Films in DBpedia: actor, director, country, producer,
language, title, genre, story, studio . Filter on country, studio and genre, runtime. '''
from rdfframes.knowledge_graph import KnowledgeGraph
graph = KnowledgeGraph(graph_name='dbpedia')
def expand_filter_expand():
films = graph.entities('dbpo:Film', entities_col_name='film')\
.expand('film', [('dbpp:starring', 'actor'), ('dbpp:country', 'movie_country')])\
.expand('film', [ ('dbpp:genre', 'genre')])\
.expand('film', [ ('dbpp:director','director'), ('dbpp:producer', 'producer'), ('dbpp:language', 'language'),
('dbpp:story','story') ,('dbpp:runtime', 'runtime'), ('dbpp:studio' ,'studio'),
('dbpp:title', 'title')])\
.filter({'movie_country': [' IN (dbpr:United_States, dbpr:India)']})\
.filter({'genre': ['IN (dbpr:Film_score, dbpr:Soundtrack, dbpr:Rock_music, dbpr:House_music, dbpr:Dubstep)']})\
.filter({'studio': ['!= "Eskay Movies"']})
print(films.to_sparql())
expand_filter_expand()