(self, res, score_threshold=0.625, key_weight = {'bow': 1, 'tfidf': 1, 'ngram_tfidf': 1})
| 46 | return [qa_res, qa_hit] |
| 47 | |
| 48 | def score(self, res, score_threshold=0.625, key_weight = {'bow': 1, 'tfidf': 1, 'ngram_tfidf': 1}): |
| 49 | qa_hit = {} |
| 50 | for key,value in res.items(): # { 'bow':['q1':0.5, 'q2':0.3...], 'tf-idf'....} |
| 51 | for qa_id, qa_score in value: |
| 52 | if qa_id not in qa_hit.keys(): |
| 53 | qa_hit[qa_id] = 0 |
| 54 | qa_hit[qa_id] += qa_score * key_weight[key] |
| 55 | qa_res = {} |
| 56 | for qa_id,qa_score in qa_hit.items(): |
| 57 | qa_score = self._normalize( qa_score,key_weight ) |
| 58 | qa_hit[qa_id] = qa_score |
| 59 | if qa_score>=score_threshold: |
| 60 | qa_res[qa_id] = qa_score |
| 61 | return [qa_res, qa_hit] |
| 62 | |
| 63 | |
| 64 | class QMatch(QAMatchBase): |
no test coverage detected