def selectTopStationTags(self, data): """ selects top tags when given a list of stations parameters ---------- data: a list of artists returns: top 3 tags for each artist """ db = DatabaseWrapper() taglist = [] output = [] for station in data: topTags = db.getTagsForStation(station[0]) taglist.append(topTags) if len(taglist) > 2: # calculate set differences output.append(list(set(taglist[0]) - (set(taglist[1] + taglist[2])))[:3]) # if the first set difference is empty, just return the first three tags if output[0] == []: output[0] = taglist[0][:3] output.append(list(set(taglist[1]) - (set(output[0] + taglist[2])))[:3]) output.append(list(set(taglist[2]) - (set(output[1] + output[0])))[:3]) else: print "Not enough tags to calculate tag difference" output = [[], [], []] return output