in comprehend_groundtruth_integration/src/comprehend_customer_scripts/GroundTruth/EntityRecognizer/groundtruth_format_conversion_handler.py [0:0]
def read_write_dataset_annotations(self, index, jsonLine):
with open(self.dataset_filename, 'a', encoding='utf8') as dataset, open(self.annotation_filename, 'a', encoding='utf8') as annotation_file:
datawriter = csv.writer(annotation_file, delimiter=',', lineterminator='\n')
source, annotations = self.convert_object.convert_to_dataset_annotations(index, jsonLine)
# write the document in the dataset file
source = json.dumps(source).strip('"')
dataset.write('"' + source + '"')
dataset.write("\n")
# write the annotations of each document in the annotations file
for entry in annotations:
datawriter.writerow(entry)