MCPcopy Create free account
hub / github.com/Tencent/NeuralNLP-NeuralClassifier / preprocess

Function preprocess

dataset/data_preprocessor.py:59–72  ·  view source on GitHub ↗
(csv_file, json_file)

Source from the content-addressed store, hash-verified

57
58
59def 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
75if __name__ == '__main__':

Callers 1

Calls 2

clean_strFunction · 0.85

Tested by

no test coverage detected