def set_solr_properties(self):
'''
Determine Solr iteration, position and score.
'''
if not [f for f in self.features if f.startswith('match_str_solr')]:
return
# Solr iteration
self.match_str_solr_query_0 = 1 if self.query_id == 0 else 0
self.match_str_solr_query_1 = 1 if self.query_id == 1 else 0
self.match_str_solr_query_2 = 1 if self.query_id == 2 else 0
self.match_str_solr_query_3 = 1 if self.query_id == 3 else 0
self.match_str_solr_substitution = 1 if self.query_iteration == 1 else 0
# Solr position (relative to other remaining candidates)
pos = self.cand_list.filtered_candidates.index(self)
self.match_str_solr_position = 1.0 - math.tanh(pos * 0.25)
# Solr score (relative to other remaining candidates)
if not hasattr(self.cand_list, 'max_score'):
self.cand_list.set_max_score()
if self.cand_list.max_score:
self.match_str_solr_score = (self.document.get('score') /
float(self.cand_list.max_score))
评论列表
文章目录