def createGraphForEventArtistsAndGenres(store,repo_name,events): count =0 allArtistUris = [] for event in events: eventAlreadyExists = sesame_repository.doesEventWithIdExist(repo_name,event["id"]) if not eventAlreadyExists: eventUriRef = URIRef("http://facebook.com/"+event["id"]) gevent = Graph(store=store,identifier=eventUriRef) if "eventdata" in event.keys(): if("description" in event["eventdata"].keys()): description = event["eventdata"]["description"] genres = dbpedia.extractMusicGenreNamesFromText(description) for dbpediaGenreUri in genres: gevent.add((eventUriRef,ns["genre"],URIRef(dbpediaGenreUri))) artists = dbpedia_spotlight.getArtistEntities(description) for artistUri in artists: gevent.add((eventUriRef,ns["relatedArtist"],URIRef(artistUri))) if artistUri not in allArtistUris: allArtistUris.append(artistUri) count = count+1 # if count==15: # break print "processed artists for "+str(count)+" out of "+str(len(events))+" events" # if count==2: # break #now add soundcloud tracks id data to all artists count = 0 soundcloudClient = soundcloud_get_tracks.getSoundcloudClient() for artistUri in allArtistUris: extractArtistInfoAndAddToGraph(store,artistUri,soundcloudClient) count = count+1 print "processed artist info for "+str(count)+" out of "+str(len(allArtistUris))+" artists"
def extractArtistsFromText(text): foundDbpediaArtists = dbpedia_spotlight.getArtistEntities(text) return foundDbpediaArtists