model=ModelFactory( match_models=['bow', 'tfidf', 'ngram_tfidf', 'bert', 'w2v'] 输出:{'bow':vector, 'tfidf':vector, .....} or 输出:{'bow': (vector1, vector2), 'tfidf': (vector1, vector2), .....}
| 14 | from textmatch.models.text_embedding.model_factory_sklearn import ModelFactory |
| 15 | |
| 16 | class TextEmbedding(): |
| 17 | ''' |
| 18 | model=ModelFactory( match_models=['bow', 'tfidf', 'ngram_tfidf', 'bert', 'w2v'] |
| 19 | 输出:{'bow':vector, 'tfidf':vector, .....} |
| 20 | or |
| 21 | 输出:{'bow': (vector1, vector2), 'tfidf': (vector1, vector2), .....} |
| 22 | ''' |
| 23 | def __init__(self, model=ModelFactory, match_models=['bow'], words_dict=None, update=True): |
| 24 | self.model = model |
| 25 | self.words_dict = words_dict |
| 26 | self._init_model( self.words_dict, match_models, update=update) |
| 27 | |
| 28 | def _init_model(self, words_dict, match_models, update=True): |
| 29 | self.mf = self.model( match_models=match_models ) |
| 30 | self.mf.init(words_dict=words_dict, update=update) |
| 31 | |
| 32 | def predict(self, words, word_id=None): |
| 33 | return self.mf.predict_emb(words, word_id) |
| 34 | |
| 35 | |
| 36 |
no outgoing calls
no test coverage detected