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

Method vote

textmatch/core/qa_match.py:32–46  ·  view source on GitHub ↗
(self, res, vote_threshold=0.75, key_weight = {'bow': 1, 'tfidf': 1, 'ngram_tfidf': 1})

Source from the content-addressed store, hash-verified

30 return x / float(np.sum( list(key_weight.values()) ))
31
32 def vote(self, res, vote_threshold=0.75, key_weight = {'bow': 1, 'tfidf': 1, 'ngram_tfidf': 1}):
33 qa_hit = {}
34 for key, value in res.items(): # { 'bow':['q1':0.5, 'q2':0.3...], 'tf-idf'....}
35 for qa_id, qa_score in value:
36 if qa_id not in qa_hit.keys():
37 qa_hit[qa_id] = 0
38 if qa_score>0.5:
39 qa_hit[qa_id] += 1 * key_weight[key]
40 qa_res = {}
41 for qa_id, qa_score in qa_hit.items():
42 qa_score = self._normalize( qa_score,key_weight )
43 qa_hit[qa_id] = qa_score
44 if qa_score>=vote_threshold:
45 qa_res[qa_id] = qa_score
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 = {}

Callers 3

predictMethod · 0.45
predictMethod · 0.45
predictMethod · 0.45

Calls 1

_normalizeMethod · 0.95

Tested by

no test coverage detected