def addFriend(self, user):
		userUri = user.get_profile().uri
		
		graph.add((userUri, graph.ontologies['smdb']['isFriendsWith'], self.uri))
		graph.add((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()
示例#4
0
albums_folder = '/Users/joaorodrigues/Documents/5_ano/ws/Projecto/Projecto_WS/Data/albums/'
repeat = False
id_number = 1

for filename in os.listdir(events_folder)[1:]:
	f = open("%s/%s" % (events_folder,filename), 'r')
	rdf = ''
	for line in f:
		rdf +=line
	xml = parseString(rdf)
	descriptions = xml.getElementsByTagName("rdf:RDF")[0]
	for description in descriptions.getElementsByTagName("rdf:Description"):
		if description.getAttribute("rdf:about")[:32] == "http://lastfm.rdfize.com/events/":
			event_id = description.getAttribute("rdf:about")[32:]
			event = ontologies['me'][event_id]	
			graph.add((event,ontologies['rdf']['type'],ontologies['me']['Event'])) 		
			event_name = getText(description.getElementsByTagName("rdfs:label")[0].childNodes).replace('\"',' ')
			graph.add((event,ontologies['me']['Name'],Literal(event_name)))
			event_date = getText(description.getElementsByTagName("terms:date")[0].childNodes)
			ev_date = ontologies['me'][str(id_number)]
			graph.add((ev_date,ontologies['rdf']['type'],ontologies['me']['Date'])) 	
			d = event_date.split(",")
			graph.add((ev_date,ontologies['me']['DayName'],Literal(get_day(d[0]))))
			dt = d[1].split()
			day = int(dt[0])
			graph.add((ev_date,ontologies['me']['DayNumber'],Literal(day)))
			month_nb,month_name = get_month(dt[1])
			graph.add((ev_date,ontologies['me']['MonthNumber'],Literal(month_nb)))
			graph.add((ev_date,ontologies['me']['MonthName'],Literal(month_name)))
			year = int(dt[2])
			graph.add((ev_date,ontologies['me']['Year'],Literal(year)))