def removeFriend(self, user): userUri = user.get_profile().uri graph.remove((userUri, graph.ontologies['smdb']['isFriendsWith'], self.uri)) graph.remove((self.uri, graph.ontologies['smdb']['isFriendsWith'], userUri)) graph.commit()
def addReview(self, user, revID, text): userUri = user.get_profile().uri revUri = URIRef(self.uri + '#review-' + str(revID)) graph.add((revUri, graph.ontologies['rdf'].type, graph.ontologies['smdb']['MovieReview'])) graph.add((revUri, graph.ontologies['smdb']['id'], Literal(revID))) graph.add((revUri, graph.ontologies['smdb']['refersTo'], self.uri)) graph.add((revUri, graph.ontologies['smdb']['writtenByUser'], userUri)) graph.add((revUri, graph.ontologies['smdb']['reviewText'], Literal(text))) graph.commit()
def markSeen(self, user): userUri = user.get_profile().uri graph.add((userUri, graph.ontologies['smdb']['hasSeen'], self.uri)) graph.commit()
graph.add((album,ontologies['me']['Name'],Literal(album_name))) album_label = str(info['Artist']['Albums'][alb]) graph.add((album,ontologies['me']['Label'],Literal(album_label))) graph.add((artist,ontologies['me']['recorded'],album)) id_number += 1 except: continue #pprint(list(graph)) # just think .whatever((s, p, o)) # here we report on what we know #pprint(list(graph.subjects())) #pprint(list(graph.predicates())) #pprint(list(graph.objects())) # and other things that make sense # what do we know about pat? #pprint(list(graph.predicate_objects(ontologies['me']['event1']))) # who is what age? #pprint(list(graph.subject_objects(ontologies['me']['description']))) #print list(graph.query(""" SELECT ?cenas WHERE { ?cenas me:takes_place ?a . ?a me:Name "MusicBox" . } """, initNs=ontologies)) graph.commit()