MCPcopy Create free account
hub / github.com/modelscope/modelscope / write

Method write

modelscope/models/nlp/mglm/data_utils/datasets.py:355–377  ·  view source on GitHub ↗

given a generator of metrics for each of the data points X_i, write the metrics, text, and labels to a csv file

(self, writer_gen=None, path=None, skip_header=False)

Source from the content-addressed store, hash-verified

353 return {'text': x, 'length': len(x), 'label': y}
354
355 def write(self, writer_gen=None, path=None, skip_header=False):
356 """
357 given a generator of metrics for each of the data points X_i,
358 write the metrics, text, and labels to a csv file
359 """
360 if path is None:
361 path = self.path + '.results'
362 print('generating csv at ' + path)
363 with open(path, 'w') as csvfile:
364 c = csv.writer(csvfile, delimiter=self.delim)
365 if writer_gen is not None:
366 # if first item of generator is a header of what the metrics mean then write header to csv file
367 if not skip_header:
368 header = (self.label_key, ) + tuple(
369 next(writer_gen)) + (self.text_key, )
370 c.writerow(header)
371 for i, row in enumerate(writer_gen):
372 row = (self.Y[i], ) + tuple(row) + (self.X[i], )
373 c.writerow(row)
374 else:
375 c.writerow([self.label_key, self.text_key])
376 for row in zip(self.Y, self.X):
377 c.writerow(row)
378
379
380class json_dataset(data.Dataset):

Callers 15

http_get_msFunction · 0.45
__getitem__Method · 0.45
dumpMethod · 0.45
video_mergerFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
save_pretrainedMethod · 0.45
save_checkpointFunction · 0.45
output_predictionMethod · 0.45
output_predictionMethod · 0.45
output_predictionMethod · 0.45
output_funcFunction · 0.45

Calls 1

printFunction · 0.85

Tested by

no test coverage detected