def _parse_response_content_for_predictions(self, question_number, response):
"""
Parses the json representation of the docs from the HTTP response and returns it as list predictions
with scores (and confidences if they exist)
:param str question_number: used as qid
:param requests.Response response:
:return: list of feature vectors
:rtype: list(list(str))
"""
response_content = response.json()
results = []
if response_content['response']['numFound'] > 0:
for doc in response_content['response']['docs']:
if "ranker.confidence" in doc:
conf_score = doc["ranker.confidence"]
else:
conf_score = None
results.append(Prediction(qid=question_number, aid=doc[self.DOC_ID_FIELD_NAME], rank_score=doc['score'],
conf_score=conf_score))
else:
self.logger.warn('Empty response: %s' % vars(response))
return results
评论列表
文章目录