Exemplo n.º 1
0
def suggest(q):
	ml = []
	for result in topNQueries(q):
		# print result
		# print '='*50
		# print result
		# print 'If you like \"%s\" by %s, you should read:'%(result[0],result[1])
		reco = ha.recommendations(result[3])
		if reco[1] == None:
			continue

		l = list()
		for bk in reco[1]:
			d = dict([('book', bk[0]), ('author', bk[1]), ('link', bk[2])])
			l += [d]

		ml += [l]

	print json.dumps(ml)
Exemplo n.º 2
0
def suggest(q):
	f = sys.stdout#('reco_%s.txt'%('_'.join(q.split())),'w')
	g = open('mrr.txt','w') #most recent recommendations
	for result in topNQueries(q):
		# print result
		# print '='*50
		# print result
		# print 'If you like \"%s\" by %s, you should read:'%(result[0],result[1])
		reco = ha.recommendations(result[3])
		if reco[1] == None:
			continue
		f.write('If you like \"%s\" by %s, you should read:\n'%(result[0],result[1]))
		g.write('%s\n%s\n\n'%(result[0],result[1]))
		for bk in reco[1]:
			# print '\t- \"%s\" by %s'%(bk[0],bk[1])
			# print '\t(%s)'%bk[2]
			f.write('\n\t- \"%s\" by %s\n'%(bk[0],bk[1]))
			f.write('\t (%s)\n'%bk[2])
			g.write('%s\n'%bk[0])
			g.write('%s\n'%bk[1])
			g.write('%s\n\n'%bk[2])