(csv_file, json_file)
| 57 | |
| 58 | |
| 59 | def preprocess(csv_file, json_file): |
| 60 | with open(json_file, "w") as fout: |
| 61 | with open(csv_file, 'rb') as fin: |
| 62 | lines = csv.reader(fin) |
| 63 | for items in lines: |
| 64 | text_data = convert_multi_slots_to_single_slots(items[1:]) |
| 65 | text_data = clean_str(text_data) |
| 66 | sample = dict() |
| 67 | sample['doc_label'] = [items[0]] |
| 68 | sample['doc_token'] = text_data.split(" ") |
| 69 | sample['doc_keyword'] = [] |
| 70 | sample['doc_topic'] = [] |
| 71 | json_str = json.dumps(sample, ensure_ascii=False) |
| 72 | fout.write(json_str) |
| 73 | |
| 74 | |
| 75 | if __name__ == '__main__': |
no test coverage detected