Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, config_file):
self.config_file = config_file
self.config = json.loads( open(config_file).read() )
self.Letor07Path = self.config['data_dir'] #'/home/pangliang/matching/data/letor/r5w/'
self.word_dict, self.iword_dict = utils.read_word_dict(
filename=self.Letor07Path + '/word_dict.txt')
self.query_data = utils.read_data(
filename=self.Letor07Path + '/qid_query.txt')
self.doc_data = utils.read_data(
filename=self.Letor07Path + '/docid_doc.txt')
self.embed_dict = utils.read_embedding(
filename=self.Letor07Path + '/embed_wiki-pdc_d50_norm')
self.idf_dict = utils.read_embedding(
filename=self.Letor07Path + '/embed.idf')
self.feat_size = self.config['feat_size']
self._PAD_ = len(self.word_dict)
self.word_dict[self._PAD_] = '[PAD]'
self.iword_dict['[PAD]'] = self._PAD_
self.embed_dict[self._PAD_] = np.zeros((50, ), dtype=np.float32)
self.W_init_embed = np.float32(
np.random.uniform(-0.02, 0.02, [len(self.word_dict), 50]))
self.embedding = utils.convert_embed_2_numpy(
self.embed_dict, embed = self.W_init_embed)
def __init__(self, config_file):
self.config_file = config_file
self.config = json.loads( open(config_file).read() )
self.Letor07Path = self.config['data_dir'] #'/home/pangliang/matching/data/letor/r5w/'
self.word_dict, self.iword_dict = utils.read_word_dict(
filename=self.Letor07Path + '/word_dict.txt')
self.query_data = utils.read_data(
filename=self.Letor07Path + '/qid_query.txt')
self.doc_data = utils.read_data(
filename=self.Letor07Path + '/docid_doc.txt')
self.embed_dict = utils.read_embedding(
filename=self.Letor07Path + '/embed_wiki-pdc_d50_norm')
self.idf_dict = utils.read_embedding(
filename=self.Letor07Path + '/embed.idf')
self.feat_size = self.config['feat_size']
self._PAD_ = len(self.word_dict)
self.word_dict[self._PAD_] = '[PAD]'
self.iword_dict['[PAD]'] = self._PAD_
self.embed_dict[self._PAD_] = np.zeros((50, ), dtype=np.float32)
self.W_init_embed = np.float32(
np.random.uniform(-0.02, 0.02, [len(self.word_dict), 50]))
self.embedding = utils.convert_embed_2_numpy(
self.embed_dict, embed = self.W_init_embed)
self.W_init_idf = np.float32(
np.zeros([len(self.word_dict), 1]))