def output_preprocessed_data(self, json_input, file_name):
'''
Output preprocessed data into a file.
:param json_input: json formatted data generated from function str_process
:param file_name: output file name
:return: None
'''
rows = []
for sent in json_input['sentences']:
parsed_sent = " ".join([t['originalText'] + "/" + t['pos'] for t in sent['tokens']])
rows.append(parsed_sent)
output_file_path = self.output_folder + '/' + file_name
if os.path.exists(output_file_path):
open(output_file_path, 'w').close()
with open(output_file_path, 'a') as preprocessed_out:
for r in rows:
preprocessed_out.write(unidecode.unidecode(r) + "\n")
评论列表
文章目录