def __init__(self):
super().__init__()
stack = self._stack
# classes
self.classes_ = [1, 2, 3, 4, 5]
self.average_classes = [1, 2, 3, 4, 5]
# data
self.data_dir = 'data/yelp'
with temp_chdir(self.data_dir):
self.train_objs = JSONDecoder(stack.enter_context(open('train.json')))
self.train_docs = FieldExtractor(self.train_objs, 'text')
self.train_labels = np.fromiter(FieldExtractor(self.train_objs, 'stars'), 'int32')
self.val_objs = JSONDecoder(stack.enter_context(open('val.json')))
self.val_docs = FieldExtractor(self.val_objs, 'text')
self.val_labels = FieldExtractor(self.val_objs, 'stars')
self.test_objs = JSONDecoder(stack.enter_context(open('test.json')))
self.test_docs = FieldExtractor(self.test_objs, 'text')
self.test_labels = FieldExtractor(self.test_objs, 'stars')
评论列表
文章目录