用于问句句匹配 input: words output: {'id0':0.2, 'id1':0.5, ...}
| 62 | |
| 63 | |
| 64 | class 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 | |
| 82 | class AMatch(QAMatchBase): |
no outgoing calls