Beispiel #1
0
def search_song(song):
	#if songs_hash.has_key(song):return song
	max_cost=math.floor(len(song.decode('utf-8'))/3)+1
	#print max_cost
	related_songs=ldsearch.main(song,int(max_cost),'song')
	#print len(related_songs)
	rc_result=calPR.main_song(related_songs)
	#print rc_result
	return rc_result
Beispiel #2
0
def search(singer,song):
	
	if singer in singers_hash:
		songs=singers_hash[singer]
		#print song ,songs[0]
		if song in songs:
			return singer,song,'1'
		else:
			max_cost=math.floor(len(song.decode('utf-8')))-1
			related_songs=ldsearch.main(song,int(max_cost),'song')
			#for k in related_songs:print k[0]
			for j in related_songs:
				sub_song=j[0].encode('utf-8')
				if sub_song in songs:
					return singer,sub_song,'2'
				if song == sub_song:
					if song in songs_hash:
						return songs_hash[song][0],song,'3'
			rc_result=calPR.main_song(related_songs)
			#print rc_result.decode('utf-8')
			#try:
			return singer,singers_hash[singer][0],'4'
			#except:
				#return 'null',rc_result
	else:
		if song in songs_hash:
			singers=songs_hash[song]
			max_cost=(len(singer.decode('utf-8')))-1
			related_singers=ldsearch.main(singer,max_cost,'singer')
			for j in related_singers:
				sub_singer=j[0].encode('utf-8')
				
				if sub_singer in singers:
					
					return sub_singer,song,'5'
			rc_result=calPR.main_singer(related_singers)
			return rc_result,song,'6'
		else:
			return 'null','null','7'