|  | @@ -36,7 +36,10 @@ class NLPFunction(object):
 | 
	
		
			
				|  |  |              text_dict['text_a'],
 | 
	
		
			
				|  |  |              text_dict['text_b']
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  | -        return score_tensor.squeeze().tolist()
 | 
	
		
			
				|  |  | +        response = {
 | 
	
		
			
				|  |  | +            "score": score_tensor.squeeze().tolist()
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return response
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def base_list_similarity(self, pair_list_dict):
 | 
	
		
			
				|  |  |          """
 | 
	
	
		
			
				|  | @@ -47,7 +50,10 @@ class NLPFunction(object):
 | 
	
		
			
				|  |  |              pair_list_dict['text_list_a'],
 | 
	
		
			
				|  |  |              pair_list_dict['text_list_b']
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  | -        return score_tensor.tolist()
 | 
	
		
			
				|  |  | +        response = {
 | 
	
		
			
				|  |  | +            "score_list_list": score_tensor.tolist()
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return response
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def max_cross_similarity(self, data):
 | 
	
		
			
				|  |  |          """
 | 
	
	
		
			
				|  | @@ -57,25 +63,36 @@ class NLPFunction(object):
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  |          score_list_max = []
 | 
	
		
			
				|  |  |          text_list_max = []
 | 
	
		
			
				|  |  | -        score_array = self.base_list_similarity(data)
 | 
	
		
			
				|  |  | +        score_array = self.base_list_similarity(data)['score_list_list']
 | 
	
		
			
				|  |  |          text_list_a, text_list_b = data['text_list_a'], data['text_list_b']
 | 
	
		
			
				|  |  |          for i, row in enumerate(score_array):
 | 
	
		
			
				|  |  |              max_index = np.argmax(row)
 | 
	
		
			
				|  |  |              max_value = row[max_index]
 | 
	
		
			
				|  |  |              score_list_max.append(max_value)
 | 
	
		
			
				|  |  |              text_list_max.append(text_list_b[max_index])
 | 
	
		
			
				|  |  | -        return score_list_max, text_list_max, score_array
 | 
	
		
			
				|  |  | +        response = {
 | 
	
		
			
				|  |  | +            'score_list_max': score_list_max,
 | 
	
		
			
				|  |  | +            'text_list_max': text_list_max,
 | 
	
		
			
				|  |  | +            'score_list_list': score_array,
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return response
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def mean_cross_similarity(self, data):
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  |          :param data:
 | 
	
		
			
				|  |  |          :return:
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  | -        score_list_max, text_list_max, score_array = self.max_cross_similarity(data)
 | 
	
		
			
				|  |  | +        resp = self.max_cross_similarity(data)
 | 
	
		
			
				|  |  | +        score_list_max, text_list_max, score_array = resp['score_list_max'], resp['text_list_max'], resp['score_list_list']
 | 
	
		
			
				|  |  |          score_tensor = torch.tensor(score_array)
 | 
	
		
			
				|  |  |          score_res = torch.mean(score_tensor, dim=1)
 | 
	
		
			
				|  |  |          score_list = score_res.tolist()
 | 
	
		
			
				|  |  | -        return score_list, text_list_max, score_array
 | 
	
		
			
				|  |  | +        response = {
 | 
	
		
			
				|  |  | +            'score_list_mean': score_list,
 | 
	
		
			
				|  |  | +            'text_list_max': text_list_max,
 | 
	
		
			
				|  |  | +            'score_list_list': score_array,
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return response
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def avg_cross_similarity(self, data):
 | 
	
		
			
				|  |  |          """
 | 
	
	
		
			
				|  | @@ -84,9 +101,17 @@ class NLPFunction(object):
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  |          score_list_b = data['score_list_b']
 | 
	
		
			
				|  |  |          symbol = data['symbol']
 | 
	
		
			
				|  |  | -        score_list_max, text_list_max, score_array = self.max_cross_similarity(data)
 | 
	
		
			
				|  |  | +        # score_list_max, text_list_max, score_array = self.max_cross_similarity(data)
 | 
	
		
			
				|  |  | +        resp = self.max_cross_similarity(data)
 | 
	
		
			
				|  |  | +        score_list_max, text_list_max, score_array = resp['score_list_max'], resp['text_list_max'], resp[
 | 
	
		
			
				|  |  | +            'score_list_list']
 | 
	
		
			
				|  |  |          score_attn, score_norm, score_pred = score_to_attention(score_list_b, symbol=symbol)
 | 
	
		
			
				|  |  |          score_tensor = torch.tensor(score_array)
 | 
	
		
			
				|  |  |          score_res = torch.matmul(score_tensor, score_attn.transpose(0, 1))
 | 
	
		
			
				|  |  |          score_list = score_res.squeeze(-1).tolist()
 | 
	
		
			
				|  |  | -        return score_list, text_list_max, score_array
 | 
	
		
			
				|  |  | +        response = {
 | 
	
		
			
				|  |  | +            'score_list_avg': score_list,
 | 
	
		
			
				|  |  | +            'text_list_max': text_list_max,
 | 
	
		
			
				|  |  | +            'score_list_list': score_array,
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return response
 |