utils_4.py 358 B

12345678
  1. def write_to_clf(clf_data, save_file):
  2. # Save dataset for text classification to file.
  3. """
  4. clf_data: List[List[str]] [[text1, label1],[text2,label2]...]
  5. file format: tsv, row: text + tab + label
  6. """
  7. with open(save_file, 'w', encoding='utf-8') as f:
  8. f.writelines("\n".join(["\t".join(str(r) for r in row) for row in clf_data]))