MCPcopy Create free account
hub / github.com/MachineLP/TextMatch / score

Method score

textmatch/core/qa_match.py:48–61  ·  view source on GitHub ↗
(self, res, score_threshold=0.625, key_weight = {'bow': 1, 'tfidf': 1, 'ngram_tfidf': 1})

Source from the content-addressed store, hash-verified

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
64class QMatch(QAMatchBase):

Callers 3

predictMethod · 0.45
predictMethod · 0.45
predictMethod · 0.45

Calls 1

_normalizeMethod · 0.95

Tested by

no test coverage detected