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

Class TextEmbedding

textmatch/core/text_embedding.py:16–33  ·  view source on GitHub ↗

model=ModelFactory( match_models=['bow', 'tfidf', 'ngram_tfidf', 'bert', 'w2v'] 输出:{'bow':vector, 'tfidf':vector, .....} or 输出:{'bow': (vector1, vector2), 'tfidf': (vector1, vector2), .....}

Source from the content-addressed store, hash-verified

14from textmatch.models.text_embedding.model_factory_sklearn import ModelFactory
15
16class 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

Callers 5

dbscan_test.pyFile · 0.90
kmeans_test.pyFile · 0.90
faiss_test.pyFile · 0.90
pca_test.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected