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

Class QMatch

textmatch/core/qa_match.py:64–79  ·  view source on GitHub ↗

用于问句句匹配 input: words output: {'id0':0.2, 'id1':0.5, ...}

Source from the content-addressed store, hash-verified

62
63
64class QMatch(QAMatchBase):
65 '''用于问句句匹配
66 input: words
67 output: {'id0':0.2, 'id1':0.5, ...}
68 '''
69 def __init__(self, q_dict, model_factory=ModelFactory, match_models=['bow', 'tfidf', 'ngram_tfidf']):
70 super().__init__(model_factory)
71 self.q_dict = q_dict
72 self._init_model( self.q_dict, match_models=match_models )
73
74 def predict(self, words, match_strategy='vote', vote_threshold=0.75, key_weight = {'bow': 1, 'tfidf': 1, 'ngram_tfidf': 1}):
75 res = self._predict( words )
76 if match_strategy == 'vote':
77 return self.vote(res, vote_threshold, key_weight)[0]
78 if match_strategy == 'score':
79 return self.score(res, vote_threshold, key_weight)[0]
80
81
82class AMatch(QAMatchBase):

Callers 2

test_q_matchFunction · 0.90
text_match_recallFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_q_matchFunction · 0.72
text_match_recallFunction · 0.72