query_lucene.py
def rerank_results(self, results, user_vector, user_gender, user_location, user_sentiment):
		"""
		reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
		:param results: the documents resulting from a query
		:param user_vector: the thematic vector of a user
		:param user_gender: the gender of a user
		:param user_location: the location of a user
		:param user_sentiment: the sentiment of a user
		:return: the reranked list of documents
		"""
		reranked = []
		user_vec = ProfileOneHotEncoder.add_info_to_vec(user_vector, user_gender, user_location,
		                                                user_sentiment).reshape(1, -1)
		for i in range(len(results)):
			doc_infos = Tweet.load(int(results[i]['TweetID']))
			if doc_infos is None:
				reranked.append({'doc': results[i], 'sim': 0.})
			else:
				doc_vector = ProfileOneHotEncoder.add_info_to_vec(doc_infos.vector, doc_infos.gender, doc_infos.country,
				                                                  doc_infos.sentiment).reshape(1, -1)
				sim = cosine_similarity(user_vec, doc_vector)
				reranked.append({'doc': doc_infos, 'sim': sim[0][0]})
		reranked = sorted(reranked, key=lambda k: k['sim'], reverse=True)
		return [x['doc'] for x in reranked]

		reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
		:param results: the documents resulting from a query
		:param user_vector: the thematic vector of a user
		:param user_gender: the gender of a user
		:param user_location: the location of a user
		:param user_sentiment: the sentiment of a user
		:return: the reranked list of documents
		
reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
def rerank_results(self, results, user_vector, user_gender, user_location, user_sentiment):
		reranked = []
		user_vec = ProfileOneHotEncoder.add_info_to_vec(user_vector, user_gender, user_location,
		                                                user_sentiment).reshape(1, -1)
		for i in range(len(results)):
			doc_infos = Tweet.load(int(results[i]['TweetID']))
			if doc_infos is None:
				reranked.append({'doc': results[i], 'sim': 0.})
			else:
				doc_vector = ProfileOneHotEncoder.add_info_to_vec(doc_infos.vector, doc_infos.gender, doc_infos.country,
				                                                  doc_infos.sentiment).reshape(1, -1)
				sim = cosine_similarity(user_vec, doc_vector)
				reranked.append({'doc': doc_infos, 'sim': sim[0][0]})
		reranked = sorted(reranked, key=lambda k: k['sim'], reverse=True)
		return [x['doc'] for x in reranked]
def rerank_results ( self , results , user_vector , user_gender , user_location , user_sentiment ) : reranked = [ ] user_vec = ProfileOneHotEncoder . add_info_to_vec ( user_vector , user_gender , user_location , user_sentiment ) . reshape ( 1 , - 1 ) for i in range ( len ( results ) ) : doc_infos = Tweet . load ( int ( results [ i ] [ 'TweetID' ] ) ) if doc_infos is None : reranked . append ( { 'doc' : results [ i ] , 'sim' : 0. } ) else : doc_vector = ProfileOneHotEncoder . add_info_to_vec ( doc_infos . vector , doc_infos . gender , doc_infos . country , doc_infos . sentiment ) . reshape ( 1 , - 1 ) sim = cosine_similarity ( user_vec , doc_vector ) reranked . append ( { 'doc' : doc_infos , 'sim' : sim [ 0 ] [ 0 ] } ) reranked = sorted ( reranked , key = lambda k : k [ 'sim' ] , reverse = True ) return [ x [ 'doc' ] for x in reranked ]
reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
"""
		reranks the results of a query by using the similarity between the user thematic vector and the vector from the tweets
		:param results: the documents resulting from a query
		:param user_vector: the thematic vector of a user
		:param user_gender: the gender of a user
		:param user_location: the location of a user
		:param user_sentiment: the sentiment of a user
		:return: the reranked list of documents
		"""
the reranked list of documents
the reranked list of documents
self
results
the documents resulting from a query
the documents resulting from a query
user_vector
the thematic vector of a user
the thematic vector of a user
user_gender
the gender of a user
the gender of a user
user_location
the location of a user
the location of a user
user_sentiment
the sentiment of a user
the sentiment of a user