def __init__(self, origin_path=get_current_path('data/rnn.csv'), train_path=get_current_path('data/rnn_train.csv'), model_path=get_current_path('models/rnn')): super(TrainRNN, self).__init__(origin_path, train_path, model_path) # Load "Penn Treebank" dataset self.corpus = Corpus() self.ids = self.corpus.get_data(self.train_path, batch_size) self.vocab_size = len(self.corpus.dictionary) self.num_batches = self.ids.size(1) // seq_length self.dict_path = get_current_path('models/rnn_dict')
def __init__(self, search_list, *args): """ Keyword arguments: rnnlm -- 语言模型,RNN+LSTM question -- 候选生成问句 """ self.rnnlm = torch.load(get_current_path(args[0])) with open(get_current_path(args[1]), mode='rb') as f: self.dict = pickle.load(f) self.s1, self.s2, self.s3 = '', '', '' for index, i in enumerate(search_list): if index == 0: self.s1 = i elif index == 1: self.s2 = i elif index == 2: self.s3 = i self.questions = searchs2templates(s1=self.s1, s2=self.s2, s3=self.s3)
def __init__(self, search_list, svm_path): """ Keyword arguments: clf -- 分类器,svm x1 -- x1,查询词1 x2 -- x2,查询词2 x3 -- x3,查询词3 """ self.x1, self.x2, self.x3 = '', '', '' self.clf = joblib.load(get_current_path(svm_path)) for index, i in enumerate(search_list): if index == 0: self.x1 = i elif index == 1: self.x2 = i elif index == 2: self.x3 = i
def __init__(self, search_list, w2v_path, random): """ Keyword arguments: w2v -- 词嵌入,word2vec templates -- 搜索序列和模板号 """ self.x1, self.x2, self.x3 = '', '', '' self.w2v = Word2Vec.load(get_current_path(w2v_path)) for index, i in enumerate(search_list): if index == 0: self.x1 = i elif index == 1: self.x2 = i elif index == 2: self.x3 = i self.templates = templates(x1=self.x1, x2=self.x2, x3=self.x3) self.random = random
def __init__(self, origin_path=get_current_path('data/svm.csv'), train_path=get_current_path('data/svm_train.csv'), model_path=get_current_path('models/svm')): super(TrainSVM, self).__init__(origin_path, train_path, model_path)
def __init__(self, origin_path=get_current_path('data/w2v.csv'), train_path=get_current_path('data/w2v_train.csv'), model_path=get_current_path('models/w2v')): super(TrainW2V, self).__init__(origin_path, train_path, model_path)