def set_embeddings_model(self, model=None, term_acceptance_re=re.compile('[a-z]{3,}')):
        '''

        :param model: gensim word2vec.Word2Vec model
        :param term_acceptance_re : SRE_Pattern, Regular expression to identify
            valid terms, default re.compile('[a-z]{3,}')
        :return: EmbeddingsResolver
        '''
        if self.embeddings_ is not None:
            raise Exception("You have already set embeddings by running set_embeddings or set_embeddings_model.")
        self.word2vec_model_ = model
        if term_acceptance_re is not None:
            acceptable_terms = set([t for t in self.corpus_.get_terms() if term_acceptance_re.match(t)])
        else:
            acceptable_terms = set(self.corpus_.get_terms())
        model = Word2VecFromParsedCorpus(self.corpus_, model).train()
        self.corpus_ = self.corpus_.remove_terms(set(self.corpus_.get_terms()) - acceptable_terms)
        weight_list = [model[word] for word in model.wv.vocab]
        self.embeddings_ = np.stack(weight_list)
        self.vocab_ = model.wv.vocab
        return self
def set_embeddings_model ( self , model = None , term_acceptance_re = re . compile ( '[a-z]{3,}' ) ) : if self . embeddings_ is not None : raise Exception ( "You have already set embeddings by running set_embeddings or set_embeddings_model." ) self . word2vec_model_ = model if term_acceptance_re is not None : acceptable_terms = set ( [ t for t in self . corpus_ . get_terms ( ) if term_acceptance_re . match ( t ) ] ) else : acceptable_terms = set ( self . corpus_ . get_terms ( ) ) model = Word2VecFromParsedCorpus ( self . corpus_ , model ) . train ( ) self . corpus_ = self . corpus_ . remove_terms ( set ( self . corpus_ . get_terms ( ) ) - acceptable_terms ) weight_list = [ model [ word ] for word in model . wv . vocab ] self . embeddings_ = np . stack ( weight_list ) self . vocab_ = model . wv . vocab return self
:param model: gensim word2vec.Word2Vec model
        :param term_acceptance_re : SRE_Pattern, Regular expression to identify
            valid terms, default re.compile('[a-z]{3,}')
        :return: EmbeddingsResolver